Skip to content

Commit 9dc2598

Browse files
committed
SPM8 r4290
1 parent d0afb4b commit 9dc2598

File tree

1,460 files changed

+65572
-31937
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,460 files changed

+65572
-31937
lines changed

@file_array/cat.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
66

77
%
8-
% $Id: cat.m 1143 2008-02-07 19:33:33Z spm $
8+
% $Id: cat.m 4136 2010-12-09 22:22:28Z guillaume $
99

1010

1111
if dr>32 || dr<0, error('Unknown command option.'); end;
@@ -36,5 +36,5 @@
3636
error('All matrices on a row in the bracketed expression must have the same number of rows.');
3737
else
3838
o = vertcat(tmp{:});
39-
o = class(o,'file_array');
39+
o = file_array(o);
4040
end;

@file_array/disp.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function disp(obj)
44
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
55

66
%
7-
% $Id: disp.m 1143 2008-02-07 19:33:33Z spm $
7+
% $Id: disp.m 4136 2010-12-09 22:22:28Z guillaume $
88

99

1010
if numel(struct(obj))>1,
@@ -19,7 +19,7 @@ function disp(obj)
1919
fprintf('%d\n',sz(end));
2020
end;
2121
else
22-
display(mystruct(obj))
22+
disp(mystruct(obj))
2323
end;
2424
return;
2525
%=======================================================================

@file_array/file_array.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
1414

1515
%
16-
% $Id: file_array.m 1340 2008-04-09 17:11:23Z john $
16+
% $Id: file_array.m 4136 2010-12-09 22:22:28Z guillaume $
1717

1818

1919
if nargin==1
@@ -38,5 +38,5 @@
3838
if nargin>=7, a = permission(a,varargin{7}); end;
3939

4040
a.pos = ones(size(a.dim));
41-
a = class(a,'file_array');
41+
a = file_array(a);
4242

@file_array/private/datatypes.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
55

66
%
7-
% $Id: datatypes.m 1143 2008-02-07 19:33:33Z spm $
7+
% $Id: datatypes.m 4136 2010-12-09 22:22:28Z guillaume $
88

99

1010
persistent dtype
@@ -24,10 +24,10 @@
2424
1280,'UINT64' ,'uint64' ,@uint64 ,1,8 ,t,t,f
2525
16 ,'FLOAT32' ,'float32' ,@single ,1,4 ,f,f,t
2626
64 ,'FLOAT64' ,'double' ,@double ,1,8 ,f,f,t
27-
1536,'FLOAT128' ,'float128',@crash ,1,16 ,f,f,f
27+
1536,'FLOAT128' ,'float128',@error ,1,16 ,f,f,f
2828
32 ,'COMPLEX64' ,'float32' ,@single ,2,4 ,f,f,f
2929
1792,'COMPLEX128','double' ,@double ,2,8 ,f,f,f
30-
2048,'COMPLEX256','float128',@crash ,2,16 ,f,f,f
30+
2048,'COMPLEX256','float128',@error ,2,16 ,f,f,f
3131
128 ,'RGB24' ,'uint8' ,@uint8 ,3,1 ,t,t,f};
3232
dtype = struct(...
3333
'code' ,table(:,1),...

@file_array/subsasgn.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
55

66
%
7-
% $Id: subsasgn.m 1355 2008-04-10 10:52:35Z vladimir $
7+
% $Id: subsasgn.m 4136 2010-12-09 22:22:28Z guillaume $
88

99

1010
if isempty(subs)
@@ -47,7 +47,7 @@
4747
end;
4848

4949
dm = [dm ones(1,16)];
50-
do = ones(1,16);
50+
di = ones(1,16);
5151
args = {};
5252
for i=1:length(subs.subs),
5353
if ischar(subs.subs{i}),
@@ -56,7 +56,7 @@
5656
else
5757
args{i} = int32(subs.subs{i});
5858
end;
59-
do(i) = length(args{i});
59+
di(i) = length(args{i});
6060
end;
6161
for j=1:length(sobj),
6262
if strcmp(sobj(j).permission,'ro'),
@@ -69,7 +69,7 @@
6969
if numel(dat)~=1,
7070
subfun(sobj,double(dat),args{:});
7171
else
72-
dat1 = double(dat) + zeros(do);
72+
dat1 = double(dat) + zeros(di);
7373
subfun(sobj,dat1,args{:});
7474
end;
7575
else

@file_array/subsref.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
66

77
%
8-
% $Id: subsref.m 3958 2010-06-30 16:24:46Z guillaume $
8+
% $Id: subsref.m 4136 2010-12-09 22:22:28Z guillaume $
99

1010

1111
if isempty(subs), return; end
@@ -39,7 +39,7 @@
3939
end
4040
end
4141

42-
do = ones(16,1);
42+
di = ones(16,1);
4343
args = cell(1,length(subs.subs));
4444
for i=1:length(subs.subs)
4545
if ischar(subs.subs{i})
@@ -58,15 +58,15 @@
5858
else
5959
args{i} = subs.subs{i};
6060
end
61-
do(i) = length(args{i});
61+
di(i) = length(args{i});
6262
end
6363

6464
if length(sobj)==1
6565
t = subfun(sobj,args{:});
6666
else
6767
dt = datatypes;
6868
dt = dt([dt.code]==sobj(1).dtype); % assuming identical datatypes
69-
t = zeros(do',func2str(dt.conv));
69+
t = zeros(di',func2str(dt.conv));
7070
for j=1:length(sobj)
7171
ps = [sobj(j).pos ones(1,length(args))];
7272
dm = [sobj(j).dim ones(1,length(args))];

@gifti/display.m

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function display(this)
66
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
77

88
% Guillaume Flandin
9-
% $Id: display.m 2076 2008-09-10 12:34:08Z guillaume $
9+
% $Id: display.m 4182 2011-02-01 12:29:09Z guillaume $
1010

1111
display_name = inputname(1);
1212
if isempty(display_name)
@@ -17,6 +17,9 @@ function display(this)
1717
eval([display_name ' = struct(this);']);
1818
eval(['display(' display_name ');']);
1919
else
20+
disp(' ')
21+
disp([display_name ' =']);
22+
disp(' ');
2023
eval([display_name ' = this;']);
21-
eval(['builtin(''display'',' display_name ');']);
24+
eval(['disp(' display_name ');']);
2225
end

@gifti/private/read_gifti_file.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
88

99
% Guillaume Flandin
10-
% $Id: read_gifti_file.m 3999 2010-07-19 10:54:18Z guillaume $
10+
% $Id: read_gifti_file.m 4013 2010-07-22 17:12:45Z guillaume $
1111

1212
% Import XML-based GIfTI file
1313
%--------------------------------------------------------------------------
@@ -23,7 +23,7 @@
2323
error('[GIFTI] %s is not a GIFTI 1.0 file.', filename);
2424
end
2525
attr = cell2mat(attributes(t,'get',root(t)));
26-
attr = cell2struct({attr.val},strrep({attr.key},':','_'),2);
26+
attr = cell2struct({attr.val},strrep({attr.key},':','___'),2);
2727
if ~all(ismember({'Version','NumberOfDataArrays'},fieldnames(attr)))
2828
error('[GIFTI] Missing mandatory attributes for GIFTI root element.');
2929
end

@gifti/save.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function save(this,filename,encoding)
1010
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
1111

1212
% Guillaume Flandin
13-
% $Id: save.m 3999 2010-07-19 10:54:18Z guillaume $
13+
% $Id: save.m 4022 2010-07-28 12:50:20Z guillaume $
1414

1515
error(nargchk(1,3,nargin));
1616

@@ -66,9 +66,9 @@ function save(this,filename,encoding)
6666
% Defaults for DataArray's attributes
6767
%--------------------------------------------------------------------------
6868
[unused,unused,mach] = fopen(fid);
69-
if ~isempty(strmatch('ieee-be',mach))
69+
if strncmp('ieee-be',mach,7)
7070
def.Endian = 'BigEndian';
71-
elseif ~isempty(strmatch('ieee-le',mach))
71+
elseif strncmp('ieee-le',mach,7)
7272
def.Endian = 'LittleEndian';
7373
else
7474
error('[GIFTI] Unknown byte order "%s".',mach);

@gifti/subsref.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
55

66
% Guillaume Flandin
7-
% $Id: subsref.m 3999 2010-07-19 10:54:18Z guillaume $
7+
% $Id: subsref.m 4136 2010-12-09 22:22:28Z guillaume $
88

9-
if length(this) > 1
9+
if length(this) > 1 && ~strcmp(subs(1).type,'()')
1010
warning('Not implemented.');
1111
for i=1:numel(this)
1212
varargout{i} = subsref(this(i),subs);
1313
end
14+
return;
1415
end
1516

1617
switch subs(1).type

@meeg/badchannels.m

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@
55
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
66

77
% Stefan Kiebel
8-
% $Id: badchannels.m 3942 2010-06-21 14:03:28Z vladimir $
8+
% $Id: badchannels.m 4040 2010-08-20 23:25:46Z vladimir $
99

1010

11-
if length(varargin) == 2
11+
12+
if length(varargin) == 2 && ~isempty(varargin{1})
1213
% make sure that the two inputs for set are the same length
1314
if ~(length(varargin{2}) == 1 | (length(varargin{1}) == length(varargin{2})))
1415
error('Use either same vector length or scalar for value');
1516
end
1617
end
1718

18-
if numel(varargin) >= 1
19-
if ~(varargin{1} >= 1 & varargin{1} <= nchannels(this))
19+
if numel(varargin) >= 1 && ~isempty(varargin{1})
20+
if ~(all(varargin{1} >= 1) && all(varargin{1} <= nchannels(this)))
2021
error('Channel number of out range.');
2122
end
2223
end

@meeg/clone.m

+18-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
1212

1313
% Stefan Kiebel, Vladimir Litvak
14-
% $Id: clone.m 3807 2010-04-06 19:29:08Z vladimir $
14+
% $Id: clone.m 4207 2011-02-22 10:48:36Z christophe $
1515

1616
if nargin < 4
1717
reset = 0;
@@ -32,11 +32,26 @@
3232
if isempty(pth)
3333
pth = this.path;
3434
end
35-
newFileName = [fullfile(pth,fname),ext];
35+
newFileName = [fullfile(pth,fname),'.dat'];
3636
% copy the file_array
3737
d = this.data.y; %
3838
d.fname = newFileName;
39-
d.dim = dim;
39+
dim_o = d.dim;
40+
41+
% This takes care of an issue specific to data files with a scaling factor
42+
% which are not officially supported in SPM8 (float without scaling).
43+
% Also assuming scaling is the *same* for all channels...
44+
if dim(1)>dim_o(1) && length(d.scl_slope)>1
45+
% adding channel to montage and scl_slope defined for old montage
46+
% -> need to increase size of scl_slope
47+
v_slope = mode(d.scl_slope);
48+
if length(v_slope)>1
49+
warning(['Trying to guess the scaling factor for new channels.',...
50+
' This factor might be wrong now.']);
51+
end
52+
d.scl_slope = [d.scl_slope' ones(1,dim(1)-dim_o(1))*v_slope]';
53+
end
54+
d.dim = dim;
4055

4156
% physically initialise file
4257
if length(dim) == 3

@meeg/frequencies.m

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
66

77
% Stefan Kiebel
8-
% $Id: frequencies.m 3579 2009-11-18 16:21:55Z vladimir $
8+
% $Id: frequencies.m 4015 2010-07-23 16:35:03Z vladimir $
99

1010
if nargin < 3
1111
if strncmpi(transformtype(this), 'TF',2)
@@ -34,7 +34,11 @@
3434
error('Wrong frequency axis or indices');
3535
end
3636

37-
this.transform.frequencies(ind) = f;
37+
if length(ind) == size(this.data.y, 2)
38+
this.transform.frequencies = f;
39+
else
40+
this.transform.frequencies(ind) = f;
41+
end
3842

3943
res = this;
4044
end

@meeg/private/checkmeeg.m

+38-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
1010

1111
% Vladimir Litvak
12-
% $Id: checkmeeg.m 3978 2010-07-08 14:26:39Z vladimir $
12+
% $Id: checkmeeg.m 4207 2011-02-22 10:48:36Z christophe $
1313

1414
if nargin==1
1515
option = 'basic';
@@ -64,10 +64,24 @@
6464
end
6565

6666
for k = 1:Ntrials
67-
if isnumeric(meegstruct.trials(k).label)
68-
meegstruct.trials(k).label = num2str(meegstruct.trials(k).label);
67+
68+
label = meegstruct.trials(k).label;
69+
70+
if iscell(label) && numel(label) == 1
71+
label = label{1};
6972
end
7073

74+
if isnumeric(label)
75+
label = num2str(label);
76+
end
77+
78+
if isa(label, 'char')
79+
meegstruct.trials(k).label = label;
80+
else
81+
meegstruct.trials(k).label = 'Unknown';
82+
disp('checkmeeg: some trial labels were not strings, changing back to ''Unknown''');
83+
end
84+
7185
if length(meegstruct.trials(k).bad)>1 || ~ismember(meegstruct.trials(k).bad, [0, 1])
7286
disp(['checkmeeg: illegal value for bad flag in trial ' num2str(k) ', setting to zero.']);
7387
meegstruct.trials(k).bad = 0;
@@ -135,6 +149,11 @@
135149
else
136150
[meegstruct.channels(find(cellfun('isempty', {meegstruct.channels.bad}))).bad] = deal(0);
137151
end
152+
153+
for i = 1:Nchannels
154+
meegstruct.channels(i).bad = double(~~meegstruct.channels(i).bad);
155+
end
156+
138157
if ~isfield(meegstruct.channels, 'type')
139158
disp('checkmeeg: no channel type, assigning default');
140159
[meegstruct.channels.type] = deal('Other');
@@ -199,12 +218,20 @@
199218
end
200219

201220
if isa(meegstruct.data.y, 'file_array')
221+
% catching up (unlikely case) where filearray.fname is
222+
% different from data.fnamedat -> set data.fnamedat
223+
[junk, yfname, yext] = fileparts(meegstruct.data.y.fname);
224+
[junk, dfname, dext] = fileparts(meegstruct.data.fnamedat);
225+
if ~strcmp([yfname yext],[dfname dext])
226+
meegstruct.data.fnamedat = [yfname yext];
227+
end
228+
% save original file_array scale & offset, just in case
229+
sav_sc = meegstruct.data.y.scl_slope;
230+
sav_os = meegstruct.data.y.offset;
202231
try
203232
% Try reading data, i.e. check if it's a "good" filearray
204233
meegstruct.data.y(1, 1, 1);
205234
catch
206-
% save original file_array scale, just in case
207-
sav_sc = meegstruct.data.y.scl_slope;
208235
meegstruct.data.y = [];
209236
end
210237
end
@@ -235,9 +262,14 @@
235262
error('Unknown transform type');
236263
end
237264
% and restore original file_array scale, if available (exist) & useful (~=[])
238-
if exist('sav_sc','var') && ~isempty(sav_sc)
265+
if exist('sav_sc','var') && ~isempty(sav_sc) && ...
266+
size(meegstruct.data.y, 1) == length(sav_sc)
239267
meegstruct.data.y.scl_slope = sav_sc;
240268
end
269+
% and restore original file_array offset, if available (exist) & useful (~=0)
270+
if exist('sav_os','var') && sav_os
271+
meegstruct.data.y.offset = sav_os;
272+
end
241273

242274
end
243275

0 commit comments

Comments
 (0)