https://github.com/simkind/Patch-clamp-analysis
Tip revision: bde5c7399d9f7c789feec0ee26ab5dad4a661d90 authored by simkind on 13 January 2021, 04:40:28 UTC
Create How to use.md
Create How to use.md
Tip revision: bde5c73
halfwidth.m
% threshold = peak_amps(i)/2 + bl
% pklocation = peak_times(i)/(si/1000) % need to go back to points
function [halfspikewidth, backward_time, forward_time] = halfwidth(threshold, pklocation,data,si)
forward = [];
counter = 1;
while isempty(forward)
if data(pklocation+counter) <= threshold
forward = pklocation+counter;
end
counter = counter + 1;
if counter >= length(data(pklocation:end))
break
end
end
backward = [];
counter = 1;
while isempty(backward)
if data(pklocation-counter) <= threshold
backward = pklocation-counter;
end
counter = counter + 1;
if counter >= length(data(1:pklocation))
break
end
end
if ~isempty(backward) || ~isempty(forward)
halfspikewidth = (forward - backward)*(si/1000);
else
halfspikewidth = [];
end
backward_time = backward*(si/1000);
forward_time = forward*(si/1000);
end