function simple_sd_solutions(array_of_charges_cell_array,case_numbers_and_trialcountmats,critz_cell_array,pscmat_cell_array,rawmat_cell_array,special_firstwaveforms_cell_array,...
    special_immedpostvarIPIwaveforms_cell_array,minutespertrial)
%called from command line, used in building the single-syn short-term dynamics figure

linewidth=2;
spacer=repmat(nan,1,10);

displaySDwaveforms=1;
    rungs_plot_sd_vals=1;
cumulative_comparisons=0;
cumulative_shortlong_comparisons=0;
analyze_sd_temporally=0;
    use_psc_instead_of_charge=0;
    
IPI_class1=[25 50];    %100 ms is omitted due to variable behavior
IPI_class2=[150 200 400 800];

successes=[1 3 5 7 8 9 10 11 12 15];    %numbered here according to the 15 usable cases
failures=[2 4 6 13 14];                      
succs_and_fails=[1 2 5 7 8 9 10 12 14 15 25 26 27 28 30];   %numbered here according to the original numbers from analyze_across_sd_stdp_expts
clr=colors_for_stdp_expts(size(case_numbers_and_trialcountmats,2));
close all

sd_diff_times=[];
for expt=1:15    
%     rawmat=rawmat_cell_array{succs_and_fails(expt)};
    pscmat=pscmat_cell_array{succs_and_fails(expt)};
    array_of_charges=array_of_charges_cell_array{succs_and_fails(expt)};
    crit=critz_cell_array{succs_and_fails(expt)};
    num_trials=size(pscmat,2);num_APs=size(pscmat,1)-2;
    lastpreinductrial=case_numbers_and_trialcountmats(5,expt);lastpostinductrial=case_numbers_and_trialcountmats(6,expt)+lastpreinductrial;
    preinduc_trials=[1:lastpreinductrial];postinduc_trials=[(lastpreinductrial+1):lastpostinductrial];
    if num_APs==3,IPI_of_interest=1;elseif num_APs==4,IPI_of_interest=2;end
    IPIs=pscmat(IPI_of_interest,:);
    IPI_class_membership=class_membership_assigner(IPI_class1,IPI_class2,IPIs);
   
    if displaySDwaveforms
       figure(100+succs_and_fails(expt));
       preinduc_first_waves=special_firstwaveforms_cell_array{1,succs_and_fails(expt)};
       postinduc_first_waves=special_firstwaveforms_cell_array{2,succs_and_fails(expt)};
       preinduc_postvarIPI_waves=special_immedpostvarIPIwaveforms_cell_array{1,succs_and_fails(expt)};
       postinduc_postvarIPI_waves=special_immedpostvarIPIwaveforms_cell_array{2,succs_and_fails(expt)};
       preinduc_shortvar=[];preinduc_longvar=[];
       for trial=1:lastpreinductrial
            if IPI_class_membership(trial)==1
                preinduc_shortvar=[preinduc_shortvar;preinduc_postvarIPI_waves(:,trial)'];
            elseif IPI_class_membership(trial)==2
                preinduc_longvar=[preinduc_longvar;preinduc_postvarIPI_waves(:,trial)'];
            end
        end
        postinduc_shortvar=[];postinduc_longvar=[];
       for trial=(lastpreinductrial+1):lastpostinductrial
           if IPI_class_membership(trial)==1
                postinduc_shortvar=[postinduc_shortvar;postinduc_postvarIPI_waves(:,trial-lastpreinductrial)'];
            elseif IPI_class_membership(trial)==2
                postinduc_longvar=[postinduc_longvar;postinduc_postvarIPI_waves(:,trial-lastpreinductrial)'];
            end
        end
        preinduc_with_var=[mean(preinduc_first_waves') spacer mean(preinduc_shortvar) spacer mean(preinduc_longvar)];
        postinduc_with_var=[mean(postinduc_first_waves') spacer mean(postinduc_shortvar) spacer mean(postinduc_longvar)];
        subplot(2,2,[1:2]),hold on
        plot(preinduc_with_var,'k','linewidth',linewidth)
        plot(postinduc_with_var,'color',clr(expt,:),'linewidth',linewidth)
        
        if rungs_plot_sd_vals & find(expt==successes) 
            figure(200), hold on
            a=mean(sum(preinduc_first_waves));b=mean(sum(preinduc_shortvar'));c=mean(sum(preinduc_longvar'));
            means_pre=[a/a b/a c/a];
            generalized_rung_plotter(means_pre+2*find(expt==successes) ,[nan nan nan],[nan nan nan],'k',0)
            d=mean(sum(postinduc_first_waves));e=mean(sum(postinduc_shortvar'));f=mean(sum(postinduc_longvar'));
            means_post=[d/d e/d f/d];
            generalized_rung_plotter(means_post+2*find(expt==successes) ,[nan nan nan],[nan nan nan],clr(expt,:),0)
            
        end
        
	end
    
    if cumulative_comparisons
        figure(200+succs_and_fails(expt));
        
        befo=array_of_charges(1,preinduc_trials);%red
        befa=array_of_charges(2,preinduc_trials);%green
        afo=array_of_charges(1,postinduc_trials);%blue
        afa=array_of_charges(2,postinduc_trials);%magenta
        
        maxxer=max([befo befa afo afa]');
                
        subplot(2,2,1),hold on,cumulative_histogram(befo,'r');cumulative_histogram(befa,'g');[h,p]=kstest2(befo,befa);ylabel(strcat('KS p:',num2str(p))),set(gca,'ytick',[0 1]),xlim([-.1*maxxer 1.1*maxxer]),title('Bef o v bef a'),xlabel(strcat('case',num2str(succs_and_fails(expt))))
        subplot(2,2,2),hold on,cumulative_histogram(befa,'g');cumulative_histogram(afa,'m');[h,p]=kstest2(befa,afa);ylabel(strcat('KS p:',num2str(p))),set(gca,'ytick',[0 1]),xlim([-.1*maxxer 1.1*maxxer]),title('Bef a v af a'),xlabel(strcat('case',num2str(succs_and_fails(expt))))
        subplot(2,2,3),hold on,cumulative_histogram(befo,'r');cumulative_histogram(afo,'b');[h,p]=kstest2(befo,afo);ylabel(strcat('KS p:',num2str(p))),set(gca,'ytick',[0 1]),xlim([-.1*maxxer 1.1*maxxer]),title('Bef o v af o'),xlabel(strcat('case',num2str(succs_and_fails(expt))))
        subplot(2,2,4),hold on,cumulative_histogram(afo,'b');cumulative_histogram(afa,'m');[h,p]=kstest2(afo,afa);ylabel(strcat('KS p:',num2str(p))),set(gca,'ytick',[0 1]),xlim([-.1*maxxer 1.1*maxxer]),title('Af o v af a'),xlabel(strcat('case',num2str(succs_and_fails(expt))))
         
%         figure(300+succs_and_fails(expt)), hold on    %if the below lines are used to look at potency, crit must be used to convert failures in array_of_charges to 0
%         plot(befo(find(befo&befa)),befa(find(befo&befa)),'ro'),
%         [p,s]=polyfit(befo(find(befo&befa)),befa(find(befo&befa)),1)
%         plot([0 max(befo(find(befo&befa)))],[p(2) p(2)+p(1)*max(befo(find(befo&befa)))],'color','r','linewidth',.1)
%         plot(afo(find(afo&afa)),afa(find(afo&afa)),'go')
%         [p,s]=polyfit(afo(find(afo&afa)),afa(find(afo&afa)),1)
%         plot([0 max(afo(find(afo&afa)))],[p(2) p(2)+p(1)*max(afo(find(afo&afa)))],'color','g','linewidth',.1)
        
    end
    if cumulative_shortlong_comparisons
        figure(300+succs_and_fails(expt))
       
        befo=array_of_charges(1,preinduc_trials);%red
        afo=array_of_charges(1,postinduc_trials);%green
        %befvarshort=((IPI_of_interest+1)
        %afvarshort=
        %befvarlong=
        %afvarlong=
        
    end
    if analyze_sd_temporally
        
        %array_of_charges(find(~crit))=0;    %easy way to check potency over time       --  for sd over time analysis of the varshort and varlong values for potency and reliability
        %array_of_charges=crit;  %easy way to check reliability over time
        
		time_axis=[-1*(case_numbers_and_trialcountmats(5,expt)-1):case_numbers_and_trialcountmats(6,expt)]*(minutespertrial(expt));
        [processed_sd,sd_ratio,sd_ratio_diff_time]=analyze_sd_over_time(time_axis,pscmat,crit,succs_and_fails(expt),minutespertrial(expt),num2str(succs_and_fails(expt)),array_of_charges,use_psc_instead_of_charge);
        
        sd_diff_times=[sd_diff_times sd_ratio_diff_time];
        
        %also consider sd over time analysis of the PSCo,PSCa50 cases shown as cum histograms above (from the 2007 cases) -- psco as one variable tracked over time, psca50 as the other
	end
   %------
	%generalized_rung_plotter(mean_values,upper_limits,lower_limits,casecolor,x_offset)
end