function test_std_specplot;

readsamplestudy2;
% scan all designs

% generate 32 figures
conds = { 'apart' 'together' };
stats = { 'off' 'on' };
plotsubjects = { 'off' 'on' };
tmpchanlocs = ALLEEG(1).chanlocs(3:9);
channels = { { 'AF3' } { tmpchanlocs.labels } };
eegvers = eeg_getversion;

for iDesign = 2:length(STUDY.design)
    STUDY = std_selectdesign(STUDY, ALLEEG, iDesign);
    
    % skip some designs for EEGLAB 9
    % ------------------------------
    skipdesign = 0;
    if eegvers(1) == '9'
        if any(cellfun(@iscell, STUDY.design(design).variable(2).value)) || any(cellfun(@iscell, STUDY.design(design).variable(1).value))
            skipdesign = 1;
        end;
        if ~isempty(STUDY.design(design).variable(1).value) && isnumeric(STUDY.design(design).variable(1).value{1}) && ...
                any(cellfun(@length, STUDY.design(design).variable(1).value) > 1)
                    skipdesign = 1; % combined indep. var. values
        end;
        if ~isempty(STUDY.design(design).variable(2).value) && isnumeric(STUDY.design(design).variable(2).value{1}) && ...
                any(cellfun(@length, STUDY.design(design).variable(2).value) > 1)
                    skipdesign = 1;% combined indep. var. values
        end;
        if any(cellfun(@(x)(isempty(x{1})), { STUDY.design(design).cell.trials })) % design with empty trials
            skipdesign = 1;
        end;
    end;
    if length(STUDY.design(iDesign).variable) < 2
        skipdesign = 1;
    end;
    
    if ~skipdesign
        [STUDY ALLEEG] = std_precomp(STUDY, ALLEEG, {},'interp','on','allcomps','on','recompute','on','spec','on', 'specparams', { 'specmode' 'fft' });

        nCond = fastif(length(STUDY.design(iDesign).variable(2).value) > 1, 2, 1);
        nGrp  = fastif(length(STUDY.design(iDesign).variable(2).value) > 1, 2, 1);
        for chans = 1:2
            for ps = 1:2
                for c1 = 1:nCond
                    for c2 = 1:nCond
                        for s1 = 1:nGrp
                            for s2 = 1:nGrp
                                { 'channels', channels{chans}, 'plotsubjects', plotsubjects{ps}, 'condstats', stats{s1}, 'groupstats', stats{s2}, 'plotgroups', conds{c1}, 'plotconditions', conds{c2}, 'threshold', NaN };

                                STUDY = std_specplot(STUDY, ALLEEG, 'channels', channels{chans}, 'plotsubjects', plotsubjects{ps}, 'condstats', stats{s1}, 'groupstats', stats{s2}, 'plotgroups', conds{c1}, 'plotconditions', conds{c2}, 'threshold', NaN);
                                if (strcmpi(stats{s1}, 'on') || strcmpi(stats{s2}, 'on'))
                                    STUDY = std_specplot(STUDY, ALLEEG, 'channels', channels{chans}, 'plotsubjects', plotsubjects{ps}, 'condstats', stats{s1}, 'groupstats', stats{s2}, 'plotgroups', conds{c1}, 'plotconditions', conds{c2}, 'threshold', 0.05);
                                end;
                                close; close;
                            end;
                        end;
                    end;
                end;
            end;
        end;
    end;
end;
