function [pscs_liveinterval_preinduc,pscs_liveinterval_postinduc,numtrials_liveinterval_preinduc,numtrials_liveinterval_postinduc,livetrials_preinduc,livetrials_postinduc,...
    latencies_liveinterval_preinduc,latencies_liveinterval_postinduc,critlogical_liveinterval_preinduc,critlogical_liveinterval_postinduc,asynchtraces_liveinterval_preinduc,...
    asynchtraces_liveinterval_postinduc, asynchcriteria_liveinterval_preinduc,asynchcriteria_liveinterval_postinduc,rawtraces_liveinterval_preinduc,rawtraces_liveinterval_postinduc,...
    tooshorttomeasure,tooshorttomeasurenames]=find_time_windows(general_time_window_before, general_time_window_after,specific_time_window_before, specific_time_window_after,...
    minutes_per_trial, patchtitle, tooshorttomeasurenames, ensure_equal_lengths, lookat_preinduc_ao_induc_ao_postinduc, interval_selection_method, pscs_fullepoch_preinduc,...
    pscs_fullepoch_postinduc, numtrials_fullepoch_preinduc, numtrials_fullepoch_postinduc, latencies_fullepoch_preinduc,...
    latencies_fullepoch_postinduc, critlogical_fullepoch_preinduc, critlogical_fullepoch_postinduc,asynchtraces_fullepoch_preinduc,asynchtraces_fullepoch_postinduc,...
    asynchcriteria_fullepoch_preinduc, asynchcriteria_fullepoch_postinduc,rawtraces_fullepoch_preinduc,rawtraces_fullepoch_postinduc)
%description: finds time windows from the appropriate epoch(s) within which to analyze trials.  builds the preinduction and postinduction windows
 %separately.  variables containing values for an unselected epoch are returned empty.
%called by: analyze_across_expts
%calls: no custom functions
%notes:  the old way -- tenminutesworth=round(10/general_info_files{i,5});minutesneg10tozero=preinduction_psc(:,(end-tenminutesworth):end);minutes20to30postinduc=postinduction_psc(:,(tenminutesworth*2):(tenminutesworth*3));
%code confirmed date:

tooshorttomeasure=0;

%what trials should be live?
switch interval_selection_method
    case 1 %all trials
        livetrials_preinduc=[1:numtrials_fullepoch_preinduc];
        livetrials_postinduc=[1:numtrials_fullepoch_postinduc];
    case 2 %general windows
        general_trials_window_before=round(inv(minutes_per_trial)*general_time_window_before);
        general_trials_window_before=[general_trials_window_before(1):general_trials_window_before(2)];
        livetrials_preinduc_generalwindow=numtrials_fullepoch_preinduc+general_trials_window_before;
        if livetrials_preinduc_generalwindow(1)<1,disp(strcat('Insufficient preinduction expt duration to measure ', patchtitle)),tooshorttomeasure=1;tooshorttomeasurenames=[tooshorttomeasurenames,patchtitle];return,end
        general_trials_window_after=round(inv(minutes_per_trial)*general_time_window_after);
        general_trials_window_after=[general_trials_window_after(1):general_trials_window_after(2)];
        livetrials_postinduc_generalwindow=general_trials_window_after;
        if livetrials_postinduc_generalwindow(end)>numtrials_fullepoch_postinduc,disp(strcat('Insufficent postinduction expt duration to measure ',patchtitle)),tooshorttomeasure=1;tooshorttomeasurenames=[tooshorttomeasurenames,patchtitle];return,end
        %equalize lengths if needed -- only applicable to general windows
        if lookat_preinduc_ao_induc_ao_postinduc==7 && interval_selection_method==2 && ensure_equal_lengths &&(length(livetrials_preinduc_generalwindow)~=length(livetrials_postinduc_generalwindow))
            beflengen=length(livetrials_preinduc_generalwindow);aflengen=length(livetrials_postinduc_generalwindow);
            holddgen=[beflengen aflengen];
            livetrials_preinduc_generalwindow=livetrials_preinduc_generalwindow(end-(holddgen((beflengen>aflengen)+1)-1):end)
            livetrials_postinduc_generalwindow=livetrials_postinduc_generalwindow(1:holddgen((beflengen>aflengen)+1))
        end
        livetrials_preinduc=livetrials_preinduc_generalwindow;
        livetrials_postinduc=livetrials_postinduc_generalwindow;
    case {3,4} %specific windows
        specific_trials_window_before=round(inv(minutes_per_trial)*specific_time_window_before);
        specific_trials_window_before=[specific_trials_window_before(1):specific_trials_window_before(2)];
        livetrials_preinduc_specificwindow=numtrials_fullepoch_preinduc+specific_trials_window_before;
        specific_trials_window_after=round(inv(minutes_per_trial)*specific_time_window_after);
        if interval_selection_method==3 %specific windows, contiguously
            livetrials_postinduc_specificwindow=[1:specific_trials_window_after(end)];
        elseif interval_selection_method==4 %specific window, skipping trials after induction but before postinduction window
            specific_trials_window_after=[specific_trials_window_after(1):specific_trials_window_after(2)];
            livetrials_postinduc_specificwindow=specific_trials_window_after;
        end
        livetrials_preinduc=livetrials_preinduc_specificwindow;
        livetrials_postinduc=livetrials_postinduc_specificwindow; 
end

%create the liveinterval variables for preinduction
if any(lookat_preinduc_ao_induc_ao_postinduc==[1 7])
    pscs_liveinterval_preinduc=pscs_fullepoch_preinduc(:,livetrials_preinduc);
    numtrials_liveinterval_preinduc=size(pscs_liveinterval_preinduc,2);
    latencies_liveinterval_preinduc=latencies_fullepoch_preinduc(:,livetrials_preinduc);
    critlogical_liveinterval_preinduc=critlogical_fullepoch_preinduc(:,livetrials_preinduc);
    if ~isempty(asynchtraces_fullepoch_preinduc)
        asynchtraces_liveinterval_preinduc=asynchtraces_fullepoch_preinduc(:,livetrials_preinduc);
        asynchcriteria_liveinterval_preinduc=asynchcriteria_fullepoch_preinduc(:,livetrials_preinduc);
    else
        asynchtraces_liveinterval_preinduc=[];asynchcriteria_liveinterval_preinduc=[];
    end
    if ~isempty(rawtraces_fullepoch_preinduc)
        rawtraces_liveinterval_preinduc=rawtraces_fullepoch_preinduc(:,livetrials_preinduc);
    else
        rawtraces_liveinterval_preinduc=[];
    end
else
    livetrials_preinduc=[];
    pscs_liveinterval_preinduc=[];
    numtrials_liveinterval_preinduc=0;
    latencies_liveinterval_preinduc=[];
    critlogical_liveinterval_preinduc=[];
    asynchtraces_liveinterval_preinduc=[];
    asynchcriteria_liveinterval_preinduc=[];
    rawtraces_liveinterval_preinduc=[];    
end

%create the liveinterval variables for postinduction
if any (lookat_preinduc_ao_induc_ao_postinduc==[3 7])
    pscs_liveinterval_postinduc=pscs_fullepoch_postinduc(:,livetrials_postinduc);
    numtrials_liveinterval_postinduc=size(pscs_liveinterval_postinduc,2);
    latencies_liveinterval_postinduc=latencies_fullepoch_postinduc(:,livetrials_postinduc);
    critlogical_liveinterval_postinduc=critlogical_fullepoch_postinduc(:,livetrials_postinduc);
    if ~isempty(asynchtraces_fullepoch_postinduc)
        asynchtraces_liveinterval_postinduc=asynchtraces_fullepoch_postinduc(:,livetrials_postinduc);
        asynchcriteria_liveinterval_postinduc=asynchcriteria_fullepoch_postinduc(:,livetrials_postinduc);
    else
        asynchtraces_liveinterval_postinduc=[];asynchcriteria_liveinterval_postinduc=[];
    end
    if ~isempty(rawtraces_fullepoch_postinduc)
        rawtraces_liveinterval_postinduc=rawtraces_fullepoch_postinduc(:,livetrials_postinduc);
    else
        rawtraces_liveinterval_postinduc=[];
    end
else
    livetrials_postinduc=[];
    pscs_liveinterval_postinduc=[];
    numtrials_liveinterval_postinduc=0;
    latencies_liveinterval_postinduc=[];
    critlogical_liveinterval_postinduc=[];
    asynchtraces_liveinterval_postinduc=[];
    asynchcriteria_liveinterval_postinduc=[];
    rawtraces_liveinterval_postinduc=[];
end
end