function convert_stored_matrix %takes the files processed data from the experimental files (created by create_storage_matrices, patchfile_analysis, and its calles) and presents it in useful formats %this is the file to use for looking closely at an individual experiment %called from command line %calls stsd_simple_plotter_generic_converted,stsd_grid_plotter_generic,stsd_grid_plotter_irreg_spaced,stsd_grid_plotter_raw2,stsd_grid_plotter_raw2007,analyze_stored_controls,histogram_breakdown_dwn,... % stsd_grid_plotter_irreg_spaced_probabilities,stsd_grid_plotter_regularly_spaced_probabilities,sd_response_comparisons,concise_historian,stsd_statistics,stsd_spreadsheet_storer,multipeak_plotter,... % rectangles_with_error_bars, though some of these are archaic clear all,close all,tic [hy,files_to_analyze,presynaptic_side,postsynaptic_side,trials_to_remove,epoch_dividers,age_and_types,analyze_raw,raw_axis,excluding_failure_waveforms,detection_threshold,indivmode_raw,... raw_comparison_format,raw_movie_format,meanmode_raw,raw_include_SD,NLize_raw,analyze_extracted_grid,indiv_grid_plots,show_rectangular,analyze_extracted_simple,... indiv_simple_plots,analyze_first_pulse_only,minutes_per_trial,analyze_probabilities,NLize_extracted,analyze_controls,analyze_histograms,analyze_spontaneous,analyze_induction,analyze_statistics,... analyze_oa_ob_ab,activate_concise_historian,make_stsd_spreadsheets,analyze_fitted_curves,use_only_fitted_values,analyze_multipeaks,analyze_means_and_sems,show_raw_colorcode_bar,... extendedrawaxis_followinglastpulse,parameter_colors]=convert_stored_matrix_parametersfile; samples_per_ms=10; number_of_epochs=length(epoch_dividers)+1; basic_pathname=('H:\extracted_values_modulebayHD\'); stimulated_recorded={{'pre-' 'post-'} {'pre' 'post'}}; synapse_in_question=strcat(stimulated_recorded{1}(presynaptic_side),stimulated_recorded{2}(postsynaptic_side)); stsd_parameters={'PSC','charge','latency','risetime','decaytime','asynchronous'}; epochal_colormaps={'jet','cool','flag','prism','hsv','autumn','hot'}; conjoined_filename=''; for j=1:length(files_to_analyze) conjoined_filename=strcat(conjoined_filename,files_to_analyze{j}); end %setting some variables if ~isempty(hy) if size(hy,1)==1 permutations_of_IPIs=length(hy); %this is for the stimphil 6 type stimuli being used now (feb/march 2006) with two IPIs, the first variable and the second fixed else permutations_of_IPIs=hy(1,:) %this is for stimphil 0 or 1 type stimuli max_length_raw=samples_per_ms*max(((hy(1,:)-1).*hy(3,:))+hy(2,:)); min_length_raw=samples_per_ms*min(hy(2,:)); end else permutations_of_IPIs=1;max_length_raw=1500;min_length_raw=1500; end %importing the raw (if indicated) and extracted matrices, as well as, possibly, matrices for some specialty variables if analyze_raw plain_rawmatrix=[]; for barbapapa=1:length(files_to_analyze) raw_pathname=strcat(basic_pathname,files_to_analyze{barbapapa},'____raw'); temp_plain_rawmatrix=load(raw_pathname); if postsynaptic_side==1, temp_plain_rawmatrix=temp_plain_rawmatrix(:,1:2:end);else temp_plain_rawmatrix=temp_plain_rawmatrix(:,2:2:end);,end %removing the traces from the not-cared-about neuron if ~isempty(trials_to_remove{barbapapa}) temp_plain_rawmatrix(:,trials_to_remove{barbapapa})=[]; end plain_rawmatrix=[plain_rawmatrix temp_plain_rawmatrix]; end number_of_trials=size(plain_rawmatrix,2) if isempty(hy) azaz_record=[];%ones(1,number_of_trials); elseif size(hy,1)==1 azaz_record=plain_rawmatrix(1:2,:)' %for stim_phil 6 type hy else azaz_record=plain_rawmatrix(1:length(hy(1,:)),:)'; %for stim_phil 1 type hy end if find(~azaz_record),find(~azaz_record),error('azaz problems'),end else azaz_record=[]; end plain_extractedmatrix=[]; for barbamama=1:length(files_to_analyze) temp_plain_extractedmatrix=[]; for barbarella=1:length(stsd_parameters) extracted_pathname=strcat(basic_pathname,files_to_analyze{barbamama},'__',synapse_in_question{1},stsd_parameters{barbarella}); temp_plain_extractedmatrix(:,:,barbarella)=load(extracted_pathname); end temp_plain_extractedmatrix(:,trials_to_remove{barbamama},:)=[]; plain_extractedmatrix=[plain_extractedmatrix temp_plain_extractedmatrix]; end if size(hy,1)==1,number_of_APs=size(plain_extractedmatrix,1)-2;else number_of_APs=size(hy,2)+1;end,number_of_IPIs=number_of_APs-1;number_of_trials=size(plain_extractedmatrix,2); if NLize_extracted for cherry=1:size(plain_extractedmatrix,3) %for each parameter orange=size(plain_extractedmatrix,1); %the total number of rows for banana=1:(size(plain_extractedmatrix,1)-(size(hy,2)+1)) %for each row after the IPIs and the first row of values (the _o values) plain_extractedmatrix(orange,:,cherry)=plain_extractedmatrix(orange,:,cherry)./plain_extractedmatrix(size(hy,2)+1,:,cherry); %could add a correction to remove NaNs orange=orange-1; end end end if ~isempty(hy) if size(hy,1)==1 azaz_record_extrac=plain_extractedmatrix(1:2,:,1)'; %as of march 7, 2006, taking the first *two* rows because now using a 3 pulse train (first IPI variable, second fixed at 50ms) if analyze_raw, if find(azaz_record_extrac~=azaz_record),error('mismatch between record of IPI durations from raw and from extracted files'),end,end for parameter=1:length(stsd_parameters) maxes_and_mins(1,parameter)=max(max(plain_extractedmatrix(3:end,:,parameter))); maxes_and_mins(2,parameter)=min(min(plain_extractedmatrix(3:end,:,parameter))); maxes_and_mins_naught(1,parameter)=max(max(plain_extractedmatrix(3,:,parameter))); maxes_and_mins_naught(2,parameter)=min(min(plain_extractedmatrix(3,:,parameter))); maxes_and_mins_nonnaught(1,parameter)=max(max(plain_extractedmatrix(4:end,:,parameter))); maxes_and_mins_nonnaught(2,parameter)=min(min(plain_extractedmatrix(4:end,:,parameter))); end else azaz_record=(plain_extractedmatrix(1:length(hy(1,:)),:,1))' for parameter=1:length(stsd_parameters) maxes_and_mins(1,parameter)=max(max(plain_extractedmatrix(length(hy(1,:))+1:end,:,parameter))); maxes_and_mins(2,parameter)=min(min(plain_extractedmatrix(length(hy(1,:))+1:end,:,parameter))); maxes_and_mins_naught(1,parameter)=max(max(plain_extractedmatrix(length(hy(1,:))+1,:,parameter))); maxes_and_mins_naught(2,parameter)=min(min(plain_extractedmatrix(length(hy(1,:))+1,:,parameter))); maxes_and_mins_nonnaught(1,parameter)=max(max(plain_extractedmatrix(length(hy(1,:))+1:end,:,parameter))); %need to clarify this -- what is added to hy? maxes_and_mins_nonnaught(2,parameter)=min(min(plain_extractedmatrix(length(hy(1,:))+1:end,:,parameter))); end end else for parameter=1:length(stsd_parameters) maxes_and_mins(1,parameter)=max(max(plain_extractedmatrix(:,:,parameter))); maxes_and_mins(2,parameter)=min(min(plain_extractedmatrix(:,:,parameter))); maxes_and_mins_naught(1,parameter)=max(max(plain_extractedmatrix(1,:,parameter))); maxes_and_mins_naught(2,parameter)=min(min(plain_extractedmatrix(1,:,parameter))); maxes_and_mins_nonnaught(1,parameter)=max(max(plain_extractedmatrix(1,:,parameter))); %need to clarify this -- what is added to hy? maxes_and_mins_nonnaught(2,parameter)=min(min(plain_extractedmatrix(1,:,parameter))); end end fit_array=[]; %will be passed empty if fitted cures are not analyzed if analyze_fitted_curves for fit=1:length(files_to_analyze) temp_fit_array=load(strcat(basic_pathname,files_to_analyze{fit},'__fit_vals')); temp_fit_array(:,trials_to_remove{fit})=[]; fit_array=[fit_array temp_fit_array]; end fit_extractedmatrix=plain_extractedmatrix; interval=size(fit_array,1)/number_of_APs; for i=1:size(plain_extractedmatrix,2) for j=1:size(azaz_record,2)+1 fit_extractedmatrix(j+number_of_APs-1,i,1)=-1*(fit_array((j*interval)-4,i)); %PSC %MUST CHANGE to the proper value given that rise duration and decay duration will now be stored from iterative_curve_fit fit_extractedmatrix(j+number_of_APs-1,i,2)=-1*(fit_array((j*interval)-3,i)); %Q fit_extractedmatrix(j+number_of_APs-1,i,3)=.1*(fit_array((j*interval)-5,i)); %latency fit_extractedmatrix(j+number_of_APs-1,i,4)=fit_array((j*interval)-1,i);%/(-1*(fit_array((j*interval)-4,i)));%rise duration (?NLize to amplitude) fit_extractedmatrix(j+number_of_APs-1,i,5)=fit_array(j*interval,i)/(-1*(fit_array((j*interval)-4,i))); %half decay duration (?NLize to amplitude) fit_extractedmatrix(j+number_of_APs-1,i,6)=nan; end end if use_only_fitted_values,plain_extractedmatrix=fit_extractedmatrix;end end if analyze_probabilities|analyze_extracted_grid detection_criterion_matrix=[]; for dcz=1:length(files_to_analyze) temp_crit_array=load(strcat(basic_pathname,files_to_analyze{dcz},'__criterion_vals')); temp_crit_array(:,trials_to_remove{dcz})=[]; detection_criterion_matrix=[detection_criterion_matrix temp_crit_array]; end [latenciez,critz]=find_detection_crits_and_latencies_generalizedform(detection_criterion_matrix,detection_threshold,numberofAPs); plain_extractedmatrix(3:end,:,3)=latenciez/10; %'compressing' the compression matrix into the max in each segment % maxed_dcm=[]; % dcmrows=size(detection_criterion_matrix,1)/3 % maxed_dcm=max(detection_criterion_matrix(1:dcmrows,:)); % maxed_dcm=[maxed_dcm;max(detection_criterion_matrix(dcmrows+1:2*dcmrows,:))]; % maxed_dcm=[maxed_dcm;max(detection_criterion_matrix(2*dcmrows+1:end,:))]; % maxed_dcm(maxed_dcm<1.5)=nan; %removing failures, as designated by the criterion matrix threshold %for i=1:6,a=plain_extractedmatrix(3:end,:,i); a(isnan(maxed_dcm))=nan; plain_extractedmatrix(3:end,:,i)=a;end % %figure(2),plot(plain_extractedmatrix(3,:,1),'ks'),hold on % plain_matrix=plain_extractedmatrix; % for i=1:6,a=plain_extractedmatrix(4,:,i); a(isnan(maxed_dcm(1,:)))=nan; plain_extractedmatrix(4,:,i)=a;end %removing _a if _o failed that trial % for i=1:6,a=plain_extractedmatrix(5,:,i); a(isnan(maxed_dcm(2,:)))=nan; plain_extractedmatrix(5,:,i)=a;end % plotting the relations of rise time, latency and size % clrz={'k' 'b' 'r'} % for i=1:3 % %subplot(1,3,1) % %plot(plain_extractedmatrix(~isnan(plain_extractedmatrix(i+2,:,1))),plain_extractedmatrix(~isnan(plain_extractedmatrix(i+2,:,3))),'o','markerfacecolor',clrz{i},'markeredgecolor',clrz{i},'markersize',12), hold on, title('PSC v. latency','fontweight','bold','fontsize',20) % %subplot(1,3,2) % % normalizedrise=(plain_extractedmatrix(i+2,:,4))./(plain_extractedmatrix(i+2,:,1)) % plot(plain_extractedmatrix(i+2,:,1),plain_extractedmatrix(i+2,:,4),'o','markerfacecolor',clrz{i},'markeredgecolor',clrz{i},'markersize',12), hold on, title('PSC v. rise duration','fontweight','bold','fontsize',20) % %subplot(1,3,3) % %plot(plain_extractedmatrix(i+2,:,3),plain_extractedmatrix(i+2,:,4),'o','markerfacecolor',clrz{i},'markeredgecolor',clrz{i},'markersize',12), hold on, title('latency v. rise duration','fontweight','bold','fontsize',20) % end end if analyze_multipeaks multipeak_matrix=[]; for multimer=1:length(files_to_analyze) multipeak_pathname=strcat(basic_pathname,files_to_analyze{multimer},'__multipeak_vals'); temp_multipeakmatrix=load(multipeak_pathname); if ~isempty(trials_to_remove{multimer}) temp_multipeakmatrix(:,trials_to_remove{multimer})=[]; end if size(temp_multipeakmatrix,1)>size(multipeak_matrix,1) %correcting size, bc the number of multipeaks can't be predicted in advance multipeak_matrix=cat(1,multipeak_matrix,repmat(nan,(size(temp_multipeakmatrix,1)-size(multipeak_matrix,1)),size(multipeak_matrix,2))); elseif size(multipeak_matrix,1)>size(temp_multipeakmatrix,1) temp_multipeakmatrix=cat(1,temp_multipeakmatrix,repmat(nan,(size(multipeak_matrix,1)-size(temp_multipeakmatrix,1)),size(temp_multipeakmatrix,2))); end multipeak_matrix=[multipeak_matrix temp_multipeakmatrix]; end end %analyzing if analyze_extracted_simple stsd_simple_plotter_generic_converted(permutations_of_IPIs,number_of_APs,number_of_trials,conjoined_filename,hy,age_and_types,stsd_parameters,epoch_dividers,... indiv_simple_plots,NLize_extracted,plain_extractedmatrix,azaz_record,synapse_in_question{1},maxes_and_mins,number_of_IPIs,analyze_first_pulse_only,minutes_per_trial) end if analyze_extracted_grid if size(hy,1)~=1 stsd_grid_plotter_generic(permutations_of_IPIs,azaz_record,number_of_APs,number_of_trials,conjoined_filename,hy,age_and_types,epoch_dividers,parameter_colors,... NLize_extracted,indiv_grid_plots,show_rectangular,stsd_parameters,synapse_in_question{1},maxes_and_mins_naught,maxes_and_mins_nonnaught,plain_extractedmatrix,... number_of_IPIs,epochal_colormaps) else stsd_grid_plotter_irreg_spaced(plain_extractedmatrix,conjoined_filename,hy,epoch_dividers,parameter_colors,stsd_parameters,number_of_IPIs,detection_criterion_matrix,fit_array) end end if analyze_raw if size(hy,1)~=1 stsd_grid_plotter_raw2(plain_rawmatrix,azaz_record,permutations_of_IPIs,number_of_APs,max_length_raw,number_of_trials,conjoined_filename,NLize_raw,postsynaptic_side,hy,... age_and_types,raw_axis,min_length_raw,meanmode_raw,raw_include_SD,indivmode_raw,raw_movie_format,raw_comparison_format,epoch_dividers,parameter_colors,... synapse_in_question{1},samples_per_ms,epochal_colormaps,fit_array,analyze_fitted_curves) else stsd_grid_plotter_raw_flat_hy(plain_rawmatrix,azaz_record,conjoined_filename,NLize_raw,hy,raw_axis,meanmode_raw,raw_include_SD,indivmode_raw,raw_movie_format,... raw_comparison_format,epoch_dividers,parameter_colors,samples_per_ms,epochal_colormaps,plain_extractedmatrix,excluding_failure_waveforms,fit_array,analyze_fitted_curves,... show_raw_colorcode_bar,extendedrawaxis_followinglastpulse) end end if analyze_controls, analyze_stored_controls(files_to_analyze,trials_to_remove,epoch_dividers,basic_pathname,parameter_colors,synapse_in_question,conjoined_filename),end %use a different color for each epoch if analyze_histograms histogram_breakdown_dwn(plain_extractedmatrix,conjoined_filename,hy,epoch_dividers,parameter_colors,stsd_parameters,number_of_IPIs,fit_array) end if analyze_probabilities if size(hy,1)==1 stsd_grid_plotter_irreg_spaced_probabilities(plain_extractedmatrix,conjoined_filename,hy,epoch_dividers,parameter_colors,stsd_parameters,number_of_IPIs,detection_criterion_matrix) else stsd_grid_plotter_regularly_spaced_probabilities(plain_extractedmatrix,conjoined_filename,hy,epoch_dividers,parameter_colors,stsd_parameters,number_of_IPIs) end end if analyze_oa_ob_ab sd_response_comparisons(plain_extractedmatrix,conjoined_filename,hy,epoch_dividers,parameter_colors,stsd_parameters,number_of_IPIs) end if activate_concise_historian concise_historian(plain_extractedmatrix,conjoined_filename,hy,epoch_dividers,parameter_colors,stsd_parameters,number_of_IPIs) end if analyze_spontaneous,end %combine all the recorded spontaneous activity and calculate cumulative pdf for IEI for each epoch, plot epochs overlaying in diff colors, then same for event size if analyze_induction,end %this may have to be done separately as the file names will be different etc. if analyze_statistics, stsd_stats=stsd_statistics(plain_extractedmatrix, epoch_dividers, stsd_parameters,length(stsd_parameters),number_of_IPIs,number_of_trials,... conjoined_filename,parameter_colors), end if make_stsd_spreadsheets, stsd_spreadsheet_storer(plain_extractedmatrix,azaz_record,synapse_in_question{1},number_of_IPIs,hy,permutations_of_IPIs,number_of_APs,number_of_trials,... conjoined_filename,stsd_parameters,epoch_dividers,files_to_analyze),end if analyze_multipeaks multipeak_plotter(multipeak_matrix,azaz_record,epoch_dividers,hy,conjoined_filename,samples_per_ms) end if analyze_means_and_sems rectangles_with_error_bars(azaz_record(:,2),epoch_dividers,critz,plain_extractedmatrix,hy) end toc