/
crc_scales.m
121 lines (118 loc) · 3.4 KB
/
crc_scales.m
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
function [scale] = crc_scales(D,indchan)
% Get the scale of one channel depending on its units or its type. Set the
% channels units or types before hand using SPM8 to use it.
%_______________________________________________________________________
% Copyright (C) 2011 Cyclotron Research Centre
% Written by J. Schrouff, 2011.
% Cyclotron Research Centre, University of Liege, Belgium
% $Id$
if nargin<1
D = crc_eeg_load;
end
if nargin<2
%get the scale(j)es of all channels
indchan=1:nchannels(D);
end
scale=ones(numel(indchan),1);
def=crc_get_defaults('scales');
for j=1:numel(indchan)
if any(indchan(j)==emgchannels(D)) %strfind(testcond{:},'EMG')
unemg=units(D,indchan(j));
try
scale(j)=eval(unemg{1});
catch
if strcmpi(unemg{1},'V')
scale(j)=def.emg;
else
scale(j)=1;
end
end
elseif any(indchan(j)==eogchannels(D)) %strfind(testcond{:},'EOG')
unemg=units(D,indchan(j));
try
scale(j)=eval(unemg{1});
catch
if strcmpi(unemg{1},'V')
scale(j)=def.eog;
else
scale(j)=1;
end
end
elseif any(indchan(j)==ecgchannels(D)) %strfind(testcond{:},'ECG')
unemg=units(D,indchan(j));
try
scale(j)=eval(unemg{1});
catch
if strcmpi(unemg{1},'V')
scale(j)=def.ecg;
else
scale(j)=1;
end
end
elseif any(indchan(j)==meegchannels(D)) %'EEG', 'MEGMAG', MEGPLANAR','LFP'
chtyp=chantype(D,indchan(j));
if strcmpi(chtyp,'EEG')
unemg=units(D,indchan(j));
try
scale(j)=eval(unemg{1});
catch
if strcmpi(unemg{1},'V')
scale(j)=def.eeg;
else
scale(j)=1;
end
end
elseif strcmpi(chtyp,'MEGMAG')
unemg=units(D,indchan(j));
try
scale(j)=eval(unemg{1});
catch
if strcmpi(unemg{1},'T')
scale(j)=def.megmag;
else
scale(j)=1;
end
end
elseif strcmpi(chtyp,'MEGPLANAR')
unemg=units(D,indchan(j));
try
scale(j)=eval(unemg{1});
catch
if strcmpi(unemg{1},'T/m')
scale(j)=def.magplan;
else
scale(j)=1;
end
end
elseif strcmpi(chtyp,'LFP')
unemg=units(D,indchan(j));
try
scale(j)=eval(unemg{1});
catch
if strcmpi(unemg{1},'V')
scale(j)=def.lfp;
else
scale(j)=10 ;
end
end
end
else
chtyp=chantype(D,indchan(j));
if strcmpi(chtyp,'other')
unemg=units(D,indchan(j));
try
scale(j)=eval(unemg{1});
catch
if strcmpi(unemg{1},'V')
scale(j)=def.other;
else
scale(j)=1;
end
end
else
disp('Unknown type of channel, please edit')
disp('Assuming scale is one')
scale(j)=1;
end
end
end