function [presyn_I_Na_present_thistrial]=presyn_I_Na_checker(stim_indices,presyn_trace,presyn_pulse_duration,trial) %this uses the method from bump_counter, viz., converting values to 1 or 0 based on being greater or less than the preceding value, respectively %the number of consecutive decreases then increases are used to determine whether there was in fact I_Na %this yes/no is returned for each presynaptic pulse consecutive_ups=2; consecutive_downs=2; sodium_current_present=[]; for i=1:length(stim_indices) current_trace=presyn_trace(stim_indices(i):stim_indices(i)+(presyn_pulse_duration-1)); %convert to binary -- 1 means that bin is greater than the bin after it, 0 means it is less than the bin after it (if equal to bin after it?) fromstart=current_trace(1:end-1); tofinish=current_trace(2:end); does_it_dip_then_rise=fromstart>tofinish; %determine if there is a dip-then-rise; if so, this is taken to be sodium current spotter=0; for k=consecutive_downs+1:length(does_it_dip_then_rise)-consecutive_ups if all(does_it_dip_then_rise(k-consecutive_downs:k-1)) if ~any(does_it_dip_then_rise(k:k+(consecutive_ups-1))) spotter=1; break end end end %if ~spotter, figure, plot(current_trace), title('no sodium current'), disp(strcat('Trial #',num2str(trial),'Pulse #',num2str(i))),error('s'), end sodium_current_present=[sodium_current_present; spotter]; end presyn_I_Na_present_thistrial=sodium_current_present;