function g20230316_kerAMI_paper_figs(dir_zenodo)
% function g20230316_kerAMI_paper_figs(dir_zenodo)
%
% 1. Description:
%      It generates all the figures of the study by: Osses A., Spinelli E., 
%        Meunier F, Gaudrain E, and Varnet L (2023). Prosodic cues to word 
%        boundaries in a segmentation task using reverse correlation. 
%        Submitted to JASA-EL.
%
%      Run this script and follow the instructions on the screen.
%      
%      Before running this script, make sure you have the most recent version
%        of the fastACI toolbox (v1.3 or later) from https://github.com/aosses-tue/fastACI
%        After download, initialise the toolbox by running startup_fastACI.
%
% % Stand-alone example (Alejandro's computer):
%   dir_zenodo = '/home/alejandro/Documents/Databases/data/Osses-et-al-2023-JASA-EL-kerAMI/';
%   g20230316_kerAMI_paper_figs(dir_zenodo);
%
% % Stand-alone example assuming that the script is located on the Zenodo folder:
%   g20230316_kerAMI_paper_figs;
%
% Author: Alejandro Osses
% Source: Private fastACI_sim repository. Snapshot on 25/04/2023
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

close all

do_run_experiment = 0;

do_fig1 = 0; % histograms
do_fig2 = 0; % spectrograms LAMI + kernels
do_fig1_suppl = 0; % extra fig
do_fig2_suppl = 0; % extra fig

list_figures = {'do_fig1';'do_fig2';'do_fig1_suppl'; 'do_fig2_suppl'};
for i = 1:length(list_figures)
    fprintf('Enter %.0f to %s\n',i,list_figures{i});
end
bInput = input('Which table/figure you want to obtain (enter the corresponding number)?: ');

switch list_figures{bInput}
    case 'do_fig1'
        do_fig1 = 1;
    case 'do_fig2'
        do_fig2 = 1;
    case 'do_fig1_suppl'
        do_fig1_suppl = 1;
    case 'do_fig2_suppl'
        do_fig2_suppl = 1;
end

if nargin == 0
    bZenodo = input('Enter 1=zenodo (directory will be automatically obtained); 0=local: ');
    
    if bZenodo
        dir_zenodo = [fileparts(mfilename('fullpath')) filesep];
    end
else
    bZenodo = 1;
end
bLocal = ~bZenodo;

f0s = [210 216];
sd = 100;
f0_sd = f0s*(2^(sd/1200))-f0s;
max_f0s = 2.2*f0_sd;

% if bZenodo
%     dir_zenodo = '/home/alejandro/Documents/Databases/data/Osses-et-al-2023-JASA-EL-kerAMI/';
% end

if do_run_experiment
    experiment = 'segmentation';
    Subject_ID = 'SXXX';
    Condition = 'LAMI';
    fastACI_experiment(experiment,Subject_ID,Condition);
end

if do_fig1
    if bLocal
        data = publ_osses2023a_JASA_EL_figs('fig1');
    end
    if bZenodo
        data = publ_osses2023a_JASA_EL_figs('fig1','zenodo','dir_zenodo',dir_zenodo);
    end
end
if do_fig2
    if bLocal
        data = publ_osses2023a_JASA_EL_figs('fig2');
    end
    if bZenodo
        data = publ_osses2023a_JASA_EL_figs('fig2','zenodo','dir_zenodo',dir_zenodo);
    end
end
if do_fig1_suppl
    % Missing: weights departing significantly from zero
    if bLocal
        data = publ_osses2023a_JASA_EL_figs('fig1_suppl');
    end
    if bZenodo
        data = publ_osses2023a_JASA_EL_figs('fig1_suppl','zenodo','dir_zenodo',dir_zenodo);
    end
end
if do_fig2_suppl
    % Missing: weights departing significantly from zero
    if bLocal
        data = publ_osses2023a_JASA_EL_figs('fig2_suppl');
    end
    if bZenodo
        data = publ_osses2023a_JASA_EL_figs('fig2_suppl','zenodo','dir_zenodo',dir_zenodo);
    end
end
h = data.h;
hname = data.hname;

dir_out = fastACI_paths('dir_output');
for i = 1:length(h)
    opts = [];
    opts.format = 'epsc';
    Saveas(h(i),[dir_out hname{i}],opts);
end