-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGetPeriod.m
More file actions
61 lines (50 loc) · 1.67 KB
/
GetPeriod.m
File metadata and controls
61 lines (50 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
function [s,rates, ratesProtrusion, ratesRetraction] = GetPeriod(moviename)
%[peakLocMin,peakMagMin, peakLocMax, peakMagMax] = GetPeriod(doPlot)
if nargin < 1
doPlot = 0;
end
[FileName,PathName] = uigetfile('*.csv','Select the csv data file');
s = dlmread([PathName FileName]);
s = s';
NumSamples = size(s,2);
sel=(max(s)-min(s))/4
[peakLocMax, peakMagMax] = peakfinder(s,sel,mean(s),1);
[peakLocMin, peakMagMin] = peakfinder(s,sel,mean(s),-1);
extremaI = sort(horzcat(peakLocMax, peakLocMin));
extrema = s(extremaI)
dt = diff(extremaI)
ds = diff(extrema)
rates=ds./dt %scale from pixels to microns
ratesProtrusion = rates(rates>0)
ratesRetraction = rates(rates<0)
plot(s,'r.-')
hold on
plot(peaks,'bo','MarkerFaceColor','b')
hold off
dlmwrite(strcat('C:\Users\Olena\Documents\FiloDataProcessing2015\', moviename, 'rates', '.csv'),[ratesProtrusion,ratesRetraction]);
%
%meanT = zeros(NumSamples,1);
%steT = zeros(NumSamples,1);
%hold off
%title(['Mean period = ' num2str(meanT(i)) '; Standard error = ' num2str(steT(i))])
% for i = 1:NumSamples
% Idx = find(s(:,i) ~= 0, 1, 'last');
% s_old = [s(1:Idx,i); s(Idx:(-1):1,i)];
% sf = fft(s_old);
% m = 50;
% sf(2+m:end-m) = 0;
% s_new = ifft(sf);
% s_new = s_new(1:end/2);
% peaks = peakfinder(s_new);
% T_All = peaks(2:end) - peaks(1:end-1);
% meanT(i) = mean(T_All);
% steT(i) = std(T_All)/sqrt(numel(T_All)-1);
% if doPlot
% plot(s(1:Idx,i),'r.-')
% hold on
% plot(peaks, s(peaks,i),'bo','MarkerFaceColor','b')
% hold off
% title(['Mean period = ' num2str(meanT(i)) '; Standard error = ' num2str(steT(i))])
% waitforbuttonpress
% end
end