function [pscs_fullepoch_preinduc, pscs_fullepoch_postinduc, criteria_fullepoch_preinduc, criteria_fullepoch_postinduc,asynchtraces_fullepoch_preinduc, asynchtraces_fullepoch_postinduc,...
    asynchcriteria_fullepoch_preinduc, asynchcriteria_fullepoch_postinduc,rawtraces_fullepoch_preinduc,rawtraces_fullepoch_postinduc, preinduc_presyn_pulse_duration,...
    postind_presyn_pulse_duration, raw_induction_trace, induction_peaks, induction_pulse_duration, induction_sampling_rate, patchtitle, general_info_files, casecolor]=...
    retrieve_extracted_data(lookat_preinduc_ao_induc_ao_postinduc, careful_charge_calculator_yesno, careful_asynch_measurement_yesno, presentcase, preinduction_files, induction_files,...
    postinduction_files)
%description: receives filename(s), which resulted from a query of the database, as input.  loads the data from the corresponding text files, which were created
%by create_storage_matrices and patchfile_analysis, then does basic preprocessing to prepare the data for analysis by the callees of analyze_across_expts
%called by: analyze_across_expts
%calls: 
%notes: variables for epochs that are not to be analyzed are returned as empty vectors
%code confirmed date:

%initializing
pscs_fullepoch_preinduc=[];criteria_fullepoch_preinduc=[];rawtraces_fullepoch_preinduc=[];preinduc_presyn_pulse_duration=[];asynchtraces_fullepoch_preinduc=[];asynchcriteria_fullepoch_preinduc=[];
pscs_fullepoch_postinduc=[];criteria_fullepoch_postinduc=[];rawtraces_fullepoch_postinduc=[];postind_presyn_pulse_duration=[];asynchtraces_fullepoch_postinduc=[];asynchcriteria_fullepoch_postinduc=[];
patchtitle='';

if ismac, paththismachine='~/dwn_data_analysis_system/';  elseif isunix, paththismachine='~/Desktop/dwn_produ/'; end 

if lookat_preinduc_ao_induc_ao_postinduc==1 || lookat_preinduc_ao_induc_ao_postinduc==7  %load the preinduction files
    namestartzpreinduc=findstr(preinduction_files{presentcase,1},'[');nameendzpreinduc=findstr(preinduction_files{presentcase,1},']');
    skipstartzpreinduc=findstr(preinduction_files{presentcase,2},'[');skipendzpreinduc=findstr(preinduction_files{presentcase,2},']');
    suffixpreinduc=strrep(preinduction_files{presentcase,3},'[','');suffixpreinduc=strrep(suffixpreinduc,']','');
    for presentpreinducfile=1:length(namestartzpreinduc)
        current_load_file_preinduc=preinduction_files{presentcase,1}((namestartzpreinduc(presentpreinducfile)+1):(nameendzpreinduc(presentpreinducfile)-1));
        current_delete_columns_preinduc=str2num(preinduction_files{presentcase,2}((skipstartzpreinduc(presentpreinducfile)+1):(skipendzpreinduc(presentpreinducfile)-1)));
        a=load(strcat(paththismachine,'extracted_values_dwn/',current_load_file_preinduc,'__pre-postPSC',suffixpreinduc));
        a(:,current_delete_columns_preinduc)=[]; 
        pscs_fullepoch_preinduc=[pscs_fullepoch_preinduc a];
        %b=load(strcat(paththismachine,'extracted_values_dwn/',current_load_file_preinduc,'__criterion_vals',suffixpreinduc));
        b=load(strcat(paththismachine,'extracted_values_dwn/',current_load_file_preinduc,'__criteria_for_latency',suffixpreinduc));
        b(:,current_delete_columns_preinduc)=[];
        criteria_fullepoch_preinduc=[criteria_fullepoch_preinduc b];
        if careful_charge_calculator_yesno
            preraw=load(strcat(paththismachine,'extracted_values_dwn/',current_load_file_preinduc,'____raw',suffixpreinduc));
            %figure(100+presentcase),plot(preraw(:,1),'k'),hold on  %a small plot to check that the presyn trace to confirm that the startpoint is the same for each expt
            %figure(presentcase),plot(preraw(:,2),'k'),hold on, title(current_load_file_preinduc)%plot of the postsyn trace to overlay preinduction and postinduction to confirm the amplitude scaling is the same for each
            preraw=preraw(:,2:2:end);
            preraw(:,current_delete_columns_preinduc)=[];
            rawtraces_fullepoch_preinduc=[rawtraces_fullepoch_preinduc preraw];
            vinn=create_basic_text_file_justforstimduration(current_load_file_preinduc);    %extracting pulse durations directly from the hdf file
            preinduc_presyn_pulse_duration=[preinduc_presyn_pulse_duration vinn];
        end
        if careful_asynch_measurement_yesno
            prerawasynchtracecrit=load(strcat(paththismachine,'extracted_values_dwn/',current_load_file_preinduc,'__asynch_criterion_vals',suffixpreinduc));
            prerawasynchtrace=prerawasynchtracecrit(:,[1:2:end]);
            prerawasynchtrace(:,current_delete_columns_preinduc)=[];
            asynchtraces_fullepoch_preinduc=[asynchtraces_fullepoch_preinduc prerawasynchtrace];
            prerawasynchcriterion=prerawasynchtracecrit(:,[2:2:end]);
            prerawasynchcriterion(:,current_delete_columns_preinduc)=[];
            asynchcriteria_fullepoch_preinduc=[asynchcriteria_fullepoch_preinduc prerawasynchcriterion]; 
        end
        %x=load(strcat(paththismachine,'extracted_values_dwn/',current_load_file_preinduc,'__presyn_I_Na_array'));
        %if~all(all(x)),disp(current_load_file_preinduc),error('Problem with presynaptic sodium current'), end
    end
    if length(preinduc_presyn_pulse_duration)>1,preinduc_presyn_pulse_duration=max(preinduc_presyn_pulse_duration),end
    if size(pscs_fullepoch_preinduc,2)~=size(criteria_fullepoch_preinduc,2),disp(preinduction_files{presentcase,1}),error('preinduction criterion/psc size mismatch'),end;
    preinduction_patchtitle=strcat(preinduction_files{presentcase,1},preinduction_files{presentcase,3});
    patchtitle=preinduction_patchtitle;
    casecolor=str2num(preinduction_files{presentcase,7});
    general_info_files=preinduction_files;
end

if any(lookat_preinduc_ao_induc_ao_postinduc==[2 7])    %load the induction files
    induction_file_name=induction_files{presentcase,1};induction_file_name=strrep(induction_file_name,'[','');induction_file_name=strrep(induction_file_name,']','');
    [raw_induction_trace,induction_peaks,induction_pulse_duration,induction_sampling_rate]=create_basic_text_file_justforrealtime(induction_file_name,1);
    if length(induction_peaks)~=60,error('error in count of induction peaks'),end
    if lookat_preinduc_ao_induc_ao_postinduc==2
        casecolor=str2num(induction_files{presentcase,4});
        general_info_files=induction_files;
    end
    patchtitle=strcat(patchtitle,induction_files{presentcase,1});
else
    raw_induction_trace=[];induction_peaks=[];induction_pulse_duration=[];induction_sampling_rate=[];
end

if lookat_preinduc_ao_induc_ao_postinduc==3 || lookat_preinduc_ao_induc_ao_postinduc==7  %load the postinduction files
    namestartzpostinduc=findstr(postinduction_files{presentcase,1},'[');nameendzpostinduc=findstr(postinduction_files{presentcase,1},']');
    skipstartzpostinduc=findstr(postinduction_files{presentcase,2},'[');skipendzpostinduc=findstr(postinduction_files{presentcase,2},']');
    suffixpostinduc=strrep(postinduction_files{presentcase,3},'[','');suffixpostinduc=strrep(suffixpostinduc,']','');
    for presentpostinducfile=1:length(namestartzpostinduc)
        current_load_file_postinduc=postinduction_files{presentcase,1}((namestartzpostinduc(presentpostinducfile)+1):(nameendzpostinduc(presentpostinducfile)-1));
        current_delete_columns_postinduc=str2num(postinduction_files{presentcase,2}((skipstartzpostinduc(presentpostinducfile)+1):(skipendzpostinduc(presentpostinducfile)-1)));
        c=load(strcat(paththismachine,'extracted_values_dwn/',current_load_file_postinduc,'__pre-postPSC',suffixpostinduc));
        c(:,current_delete_columns_postinduc)=[];
        pscs_fullepoch_postinduc=[pscs_fullepoch_postinduc c];
        %d=load(strcat(paththismachine,'extracted_values_dwn/',current_load_file_postinduc,'__criterion_vals',suffixpostinduc));
        d=load(strcat(paththismachine,'extracted_values_dwn/',current_load_file_postinduc,'__criteria_for_latency',suffixpostinduc));
        d(:,current_delete_columns_postinduc)=[];
        criteria_fullepoch_postinduc=[criteria_fullepoch_postinduc d];
        if careful_charge_calculator_yesno
            postraw=load(strcat(paththismachine,'extracted_values_dwn/',current_load_file_postinduc,'____raw',suffixpostinduc));
            %figure(100+presentcase),plot(postraw(:,1),'r'),hold on  %a small plot to check that the presyn trace to confirm that the startpoint is the same for each expt
            %figure(presentcase),plot(postraw(:,2),'r')    %plot of the postsyn trace to overlay preinduction and postinduction to confirm the amplitude scaling is the same for each
            postraw=postraw(:,2:2:end);
            postraw(:,current_delete_columns_postinduc)=[];
            rawtraces_fullepoch_postinduc=[rawtraces_fullepoch_postinduc postraw];
            ninn=create_basic_text_file_justforstimduration(current_load_file_postinduc);
            postind_presyn_pulse_duration=[postind_presyn_pulse_duration ninn];
        end
        if careful_asynch_measurement_yesno
            postrawasynchtracecrit=load(strcat(paththismachine,'extracted_values_dwn/',current_load_file_postinduc,'__asynch_criterion_vals',suffixpostinduc));
            postrawasynchtrace=postrawasynchtracecrit(:,[1:2:end]);
            postrawasynchtrace(:,current_delete_columns_postinduc)=[];
            asynchtraces_fullepoch_postinduc=[asynchtraces_fullepoch_postinduc postrawasynchtrace];
            postrawasynchcriterion=postrawasynchtracecrit(:,[2:2:end]);
            postrawasynchcriterion(:,current_delete_columns_postinduc)=[];
            asynchcriteria_fullepoch_postinduc=[asynchcriteria_fullepoch_postinduc postrawasynchcriterion]; 
        end
        %y=load(strcat(paththismachine,'extracted_values_dwn/',current_load_file_postinduc,'__presyn_I_Na_array'));
        %if~all(all(y)),disp(current_load_file_postinduc),error('Problem with presynaptic sodium current'), end
    end
    if length(postind_presyn_pulse_duration)>1,postind_presyn_pulse_duration=max(postind_presyn_pulse_duration),end
    if size(pscs_fullepoch_postinduc,2)~=size(criteria_fullepoch_postinduc,2),error('postinduction criterion/psc size mismatch'),end;
    postinduction_patchtitle=strcat(postinduction_files{presentcase,1},postinduction_files{presentcase,3});
    patchtitle=strcat(patchtitle,postinduction_patchtitle);
    casecolor=str2num(postinduction_files{presentcase,7});
    general_info_files=postinduction_files;
    if lookat_preinduc_ao_induc_ao_postinduc == 7
        if size(pscs_fullepoch_preinduc,1)~=size(pscs_fullepoch_postinduc,1),disp(preinduction_files{presentcase,1}),disp(postinduction_files{presentcase,1}),error('psc size mismatch'),end;
        if size(criteria_fullepoch_preinduc,1)~=size(criteria_fullepoch_postinduc,1),disp(preinduction_files{presentcase,1}),disp(postinduction_files{presentcase,1}),error('criterion size mismatch'),end;
    end
end