function cp_output_thistrial=changepoint_coordinator(changepoints_to_find, cp_output_thistrial, num_bootstrap_runs, num_permutations, cp_ID_method, bootstrap_style, APs_per_trial,...
    num_trials_first_epoch, time_axis, reliability, mean_potency, pscmat,critz,array_of_charges, processed_sd, sd_ratio, asynch_count_by_trial, bgrd_asynch_count_by_trial)
%description: reads changepoints_to_find to determine which change points will be obtained, feeds the relevant data to change_point_analysis_formal_method, 
 %returns results to analyze_across_expts
%called by: analyze_across_expts
%calls: change_point_analysis_formal_method
%notes: 
%code confirmed date:

if find(changepoints_to_find==1)
    [cp_occur_conf_rel,cp_rel,tempwin_rel]=change_point_analysis_formal_method(reliability,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_rel=cp_rel-num_trials_first_epoch;tempwin_rel=tempwin_rel-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_rel;cp_rel;tempwin_rel(1);tempwin_rel(2)];
end
if find(changepoints_to_find==2)
    [cp_occur_conf_pot,cp_pot,tempwin_pot]=change_point_analysis_formal_method(mean_potency,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_pot=cp_pot-num_trials_first_epoch;tempwin_pot=tempwin_pot-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_pot;cp_pot;tempwin_pot(1);tempwin_pot(2)];
end
if find(changepoints_to_find==3)
    mean_pot_without_zero=replace_zeros(mean_potency);
    [cp_occur_conf_mean_pot_without_zero,cp_mean_pot_without_zero,tempwin_mean_pot_without_zero]=change_point_analysis_formal_method(mean_pot_without_zero,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_mean_pot_without_zero=cp_mean_pot_without_zero-num_trials_first_epoch;tempwin_mean_pot_without_zero=tempwin_mean_pot_without_zero-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_mean_pot_without_zero;cp_mean_pot_without_zero;tempwin_mean_pot_without_zero(1);tempwin_mean_pot_without_zero(2)];
end
if find(changepoints_to_find==4)
    [cp_occur_conf_psc_o,cp_psc_o,tempwin_psc_o]=change_point_analysis_formal_method(pscmat(3,:),num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_psc_o=cp_psc_o-num_trials_first_epoch;tempwin_psc_o=tempwin_psc_o-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_psc_o;cp_psc_o;tempwin_psc_o(1);tempwin_psc_o(2)];
end
if find(changepoints_to_find==5)
    total_q=sum(array_of_charges);
    [cp_occur_conf_totalq,cp_totalq,tempwin_totalq]=change_point_analysis_formal_method(total_q,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_totalq=cp_totalq-num_trials_first_epoch;tempwin_totalq=tempwin_totalq-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_totalq;cp_totalq;tempwin_totalq(1);tempwin_totalq(2)];
end
if find(changepoints_to_find==6)
    max_q=max(array_of_charges);
    [cp_occur_conf_maxq,cp_maxq,tempwin_maxq]=change_point_analysis_formal_method(max_q,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_maxq=cp_maxq-num_trials_first_epoch;tempwin_maxq=tempwin_maxq-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_maxq;cp_maxq;tempwin_maxq(1);tempwin_maxq(2)];
end
if find(changepoints_to_find==7)
    q_o=array_of_charges(1,:);
    [cp_occur_conf_q_o,cp_q_o,tempwin_q_o]=change_point_analysis_formal_method(q_o,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_q_o=cp_q_o-num_trials_first_epoch;tempwin_q_o=tempwin_q_o-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_q_o;cp_q_o;tempwin_q_o(1);tempwin_q_o(2)];
end
if find(changepoints_to_find==8)
    q_a=array_of_charges(2,:);
    [cp_occur_conf_q_a,cp_q_a,tempwin_q_a]=change_point_analysis_formal_method(q_a,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_q_a=cp_q_a-num_trials_first_epoch;tempwin_q_a=tempwin_q_a-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_q_a;cp_q_a;tempwin_q_a(1);tempwin_q_a(2)];
end
if find(changepoints_to_find==9)
    q_b=array_of_charges(3,:);
    [cp_occur_conf_q_b,cp_q_b,tempwin_q_b]=change_point_analysis_formal_method(q_b,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_q_b=cp_q_b-num_trials_first_epoch;tempwin_q_b=tempwin_q_b-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_q_b;cp_q_b;tempwin_q_b(1);tempwin_q_b(2)];
end
if find(changepoints_to_find==10)
    if APs_per_trial==4, q_c=array_of_charges(4,:); else q_c=rand(1,size(array_of_charges,2)); end  %for compat w/ expts w/ 3 APs/trial
    [cp_occur_conf_q_c,cp_q_c,tempwin_q_c]=change_point_analysis_formal_method(q_c,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_q_c=cp_q_c-num_trials_first_epoch;tempwin_q_c=tempwin_q_c-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_q_c;cp_q_c;tempwin_q_c(1);tempwin_q_c(2)];
end
if find(changepoints_to_find==11)
    [cp_occur_conf_processed_sd1,cp_processed_sd1,tempwin_processed_sd1]=change_point_analysis_formal_method(processed_sd(1,:),num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_processed_sd1=cp_processed_sd1-num_trials_first_epoch;tempwin_processed_sd1=tempwin_processed_sd1-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_processed_sd1;cp_processed_sd1;tempwin_processed_sd1(1);tempwin_processed_sd1(2)];
end
if find(changepoints_to_find==12)
    [cp_occur_conf_processed_sd2,cp_processed_sd2,tempwin_processed_sd2]=change_point_analysis_formal_method(processed_sd(2,:),num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_processed_sd2=cp_processed_sd2-num_trials_first_epoch;tempwin_processed_sd2=tempwin_processed_sd2-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_processed_sd2;cp_processed_sd2;tempwin_processed_sd2(1);tempwin_processed_sd2(2)];
end
if find(changepoints_to_find==13)
    [cp_occur_conf_sdratio,cp_sdratio,tempwin_sdratio]=change_point_analysis_formal_method(sd_ratio,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_sdratio=cp_sdratio-num_trials_first_epoch;tempwin_sdratio=tempwin_sdratio-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_sdratio;cp_sdratio;tempwin_sdratio(1);tempwin_sdratio(2)];
end
if find(changepoints_to_find==14)
    [cp_occur_conf_negsdratio,cp_negsdratio,tempwin_negsdratio]=change_point_analysis_formal_method(-1*sd_ratio,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_negsdratio=cp_negsdratio-num_trials_first_epoch;tempwin_negsdratio=tempwin_negsdratio-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_negsdratio;cp_negsdratio;tempwin_negsdratio(1);tempwin_negsdratio(2)];
end
if find(changepoints_to_find==15)
    [cp_occur_conf_asynch,cp_asynch,tempwin_asynch]=change_point_analysis_formal_method(asynch_count_by_trial,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_asynch=cp_asynch-num_trials_first_epoch;tempwin_asynch=tempwin_asynch-num_trials_first_epoch;
end
if find(changepoints_to_find==16)
    [cp_occur_conf_bgrdasynch,cp_bgrdasynch,tempwin_bgrdasynch]=change_point_analysis_formal_method(bgrd_asynch_count_by_trial,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_bgrdasynch=cp_bgrdasynch-num_trials_first_epoch;tempwin_bgrdasynch=tempwin_bgrdasynch-num_trials_first_epoch;
end
if find(changepoints_to_find==17)
    pr_o=critz(1,:);
    [cp_occur_conf_pr_o,cp_pr_o,tempwin_pr_o]=change_point_analysis_formal_method(pr_o,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_pr_o=cp_pr_o-num_trials_first_epoch;tempwin_pr_o=tempwin_pr_o-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_pr_o;cp_pr_o;tempwin_pr_o(1);tempwin_pr_o(2)];
end
if find(changepoints_to_find==18)
    pot_q_o=array_of_charges(1,:);pot_q_o(find(~critz(1,:)))=0;
    [cp_occur_conf_pot_q_o,cp_pot_q_o,tempwin_pot_q_o]=change_point_analysis_formal_method(pot_q_o,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_pot_q_o=cp_pot_q_o-num_trials_first_epoch;tempwin_pot_q_o=tempwin_pot_q_o-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_pot_q_o;cp_pot_q_o;tempwin_pot_q_o(1);tempwin_pot_q_o(2)];
end
if find(changepoints_to_find==19)
    pot_q_o=array_of_charges(1,:);pot_q_o(find(~critz(1,:)))=0;
    pot_q_o=replace_zeros(pot_q_o);
    [cp_occur_conf_pot_q_o,cp_pot_q_o,tempwin_pot_q_o]=change_point_analysis_formal_method(pot_q_o,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_pot_q_o=cp_pot_q_o-num_trials_first_epoch;tempwin_pot_q_o=tempwin_pot_q_o-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_pot_q_o;cp_pot_q_o;tempwin_pot_q_o(1);tempwin_pot_q_o(2)];
end
if find(changepoints_to_find==20)
    meanpotpostinduconly=mean_potency(find(~time_axis):end)
    [cp_occur_conf_postinducpotency,cp_postinducpotency,tempwin_postinducpotency]=change_point_analysis_formal_method(meanpotpostinduconly,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_postinducpotency=cp_postinducpotency-num_trials_first_epoch;tempwin_postinducpotency=tempwin_postinducpotency-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_postinducpotency;cp_postinducpotency;tempwin_postinducpotency(1);tempwin_postinducpotency(2)];
    meanpotpostinduconly=replace_zeros(meanpotpostinduconly)
    [cp_occur_conf_postinducpotency,cp_postinducpotency,tempwin_postinducpotency]=change_point_analysis_formal_method(meanpotpostinduconly,num_bootstrap_runs,num_permutations,cp_ID_method,bootstrap_style);
    cp_postinducpotency=cp_postinducpotency-num_trials_first_epoch;tempwin_postinducpotency=tempwin_postinducpotency-num_trials_first_epoch;
    cp_output_thistrial=[cp_output_thistrial;cp_occur_conf_postinducpotency;cp_postinducpotency;tempwin_postinducpotency(1);tempwin_postinducpotency(2)];
end
if find(changepoints_to_find==21)
   %             %---preinduc only, for stability checks
%             pscmat=pscmat(:,1:trialcountmat(1));
%             array_of_charges=array_of_charges(:,1:trialcountmat(1));
%             q_o=array_of_charges(1,:);
%             reliability=reliability(:,1:trialcountmat(1));
%             mean_potency=mean_potency(:,1:trialcountmat(1)); 
end

end