-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshiftPlotStart.m
More file actions
53 lines (49 loc) · 1.3 KB
/
shiftPlotStart.m
File metadata and controls
53 lines (49 loc) · 1.3 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
function [] = shiftPlotStart(data,LoadedDataFiles,options)
% extract overlapping section of array data for
% channels ch1, ch2; intialize ShiftInfo; plot
% data and attach ShiftInfo to plot as UserData
if nargin < 3
ch1 = 1; ch2 = 6;
plotAll = 0;
skip = 10;
di = 0;
else
ch1 = options.chPlot(1);
ch2 = options.chPlot(2);
plotAll = options.plotAll;
skip = options.skip;
di = options.di;
end
dt = LoadedDataFiles{1}.dt;
if plotAll
i1 = 1;
i2 = length(data);
else
ii = (1-isnan(data(ch1,1:skip:end))).* ...
(1-isnan(data(ch2,1:skip:end)));
if any(ii)
i1 = min(find(ii))*skip;
i2 = max(find(ii)-1)*skip;
else
i1 = 1;
i2 = length(data);
end
end
temp = data(ch1,i1:skip:i2);
d1bar = mean(temp(~isnan(temp)));
temp = data(ch2,i1:skip:i2);
d2bar = mean(temp(~isnan(temp)));
d = [data(ch1,i1:i2)-d1bar;data(ch2,i1:i2)-d2bar];
Names = cell(2,1);
name = LoadedDataFiles{1}.FileName;
ind = min(find(name=='.'));
Names{1} = name(1:ind-1);
name = LoadedDataFiles{2}.FileName;
ind = min(find(name=='.'));
Names{2} = name(1:ind-1);
rect = [100,100,1000,550];
ShiftInfo = struct('di',di,'i1',1,'i2',i2-i1+1,...
'Position',rect,'d',d,'subMean',0,'ShiftFile',2,...
'LoadedDataFiles',{LoadedDataFiles},'Names',{Names},...
'dt',dt);
shiftPlot(ShiftInfo);