Skip to content

Commit 9d20829

Browse files
committed
SPM8 r3684
1 parent 10294b1 commit 9d20829

File tree

454 files changed

+24783
-13318
lines changed

Some content is hidden

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

454 files changed

+24783
-13318
lines changed

@file_array/subsref.m

+85-66
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,92 @@
11
function varargout=subsref(obj,subs)
22
% SUBSREF Subscripted reference
33
% An overloaded function...
4-
% _________________________________________________________________________________
4+
%__________________________________________________________________________
55
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
66

77
%
8-
% $Id: subsref.m 2781 2009-02-24 17:56:05Z guillaume $
8+
% $Id: subsref.m 3418 2009-09-25 11:06:39Z guillaume $
99

1010

11-
if isempty(subs)
12-
return;
13-
end;
14-
15-
if ~strcmp(subs(1).type,'()'),
16-
if strcmp(subs(1).type,'.'),
17-
%error('Attempt to reference field of non-structure array.');
18-
%if numel(struct(obj))~=1,
19-
% error('Can only access the fields of simple file_array objects.');
20-
%end;
11+
if isempty(subs), return; end
2112

13+
switch subs(1).type
14+
case '{}'
15+
error('Cell contents reference from a non-cell array object.');
16+
case '.'
2217
varargout = access_fields(obj,subs);
2318
return;
24-
end;
25-
if strcmp(subs.type,'{}'), error('Cell contents reference from a non-cell array object.'); end;
26-
end;
19+
end
2720

28-
if numel(subs)~=1, error('Expression too complicated');end;
21+
if numel(subs)~=1, error('Expression too complicated'); end;
2922

3023
dim = [size(obj) ones(1,16)];
31-
nd = max(find(dim>1))-1;
24+
nd = find(dim>1,1,'last')-1;
3225
sobj = struct(obj);
3326

34-
if length(subs.subs) < nd,
27+
if ~numel(subs.subs)
28+
[subs.subs{1:nd+1}] = deal(':');
29+
elseif length(subs.subs) < nd
3530
l = length(subs.subs);
3631
dim = [dim(1:(l-1)) prod(dim(l:end))];
37-
if numel(sobj) ~= 1,
32+
if numel(sobj) ~= 1
3833
error('Can only reshape simple file_array objects.');
3934
else
40-
if numel(sobj.scl_slope)>1 || numel(sobj.scl_inter)>1,
35+
if numel(sobj.scl_slope)>1 || numel(sobj.scl_inter)>1
4136
error('Can not reshape file_array objects with multiple slopes and intercepts.');
42-
end;
37+
end
4338
sobj.dim = dim;
44-
end;
45-
end;
39+
end
40+
end
4641

4742
do = ones(16,1);
48-
args = {};
49-
for i=1:length(subs.subs),
50-
if ischar(subs.subs{i}),
51-
if ~strcmp(subs.subs{i},':'), error('This shouldn''t happen....'); end;
52-
args{i} = 1:dim(i);
43+
args = cell(1,length(subs.subs));
44+
for i=1:length(subs.subs)
45+
if ischar(subs.subs{i})
46+
if ~strcmp(subs.subs{i},':'), error('This shouldn''t happen....'); end
47+
if length(subs.subs) == 1
48+
args{i} = 1:prod(dim); % possible overflow when int32()
49+
k = 0;
50+
for j=1:length(sobj)
51+
sobj(j).dim = [prod(sobj(j).dim) 1];
52+
sobj(j).pos = [k+1 1];
53+
k = k + sobj(j).dim(1);
54+
end
55+
else
56+
args{i} = 1:dim(i);
57+
end
5358
else
5459
args{i} = subs.subs{i};
55-
end;
60+
end
5661
do(i) = length(args{i});
57-
end;
62+
end
5863

59-
if length(sobj)==1,
64+
if length(sobj)==1
6065
t = subfun(sobj,args{:});
6166
else
62-
t = zeros(do');
63-
for j=1:length(sobj),
67+
dt = datatypes;
68+
dt = dt([dt.code]==sobj(1).dtype); % assuming identical datatypes
69+
t = zeros(do',func2str(dt.conv));
70+
for j=1:length(sobj)
6471
ps = [sobj(j).pos ones(1,length(args))];
6572
dm = [sobj(j).dim ones(1,length(args))];
66-
for i=1:length(args),
73+
for i=1:length(args)
6774
msk = find(args{i}>=ps(i) & args{i}<(ps(i)+dm(i)));
6875
args2{i} = msk;
6976
args3{i} = double(args{i}(msk))-ps(i)+1;
70-
end;
77+
end
7178

7279
t = subsasgn(t,struct('type','()','subs',{args2}),subfun(sobj(j),args3{:}));
7380
end
7481
end
7582
varargout = {t};
76-
return;
7783

84+
85+
%==========================================================================
86+
% function t = subfun(sobj,varargin)
87+
%==========================================================================
7888
function t = subfun(sobj,varargin)
89+
7990
%sobj.dim = [sobj.dim ones(1,16)];
8091
try
8192
args = cell(size(varargin));
@@ -89,56 +100,62 @@
89100
if ~isempty(sobj.scl_slope) || ~isempty(sobj.scl_inter)
90101
slope = 1;
91102
inter = 0;
92-
if ~isempty(sobj.scl_slope), slope = sobj.scl_slope; end;
93-
if ~isempty(sobj.scl_inter), inter = sobj.scl_inter; end;
94-
if numel(slope)>1,
103+
if ~isempty(sobj.scl_slope), slope = sobj.scl_slope; end
104+
if ~isempty(sobj.scl_inter), inter = sobj.scl_inter; end
105+
if numel(slope)>1
95106
slope = resize_scales(slope,sobj.dim,varargin);
96107
t = double(t).*slope;
97108
else
98109
t = double(t)*slope;
99-
end;
100-
if numel(inter)>1,
110+
end
111+
if numel(inter)>1
101112
inter = resize_scales(inter,sobj.dim,varargin);
102113
end;
103114
t = t + inter;
104-
end;
105-
return;
115+
end
116+
106117

118+
%==========================================================================
119+
% function c = access_fields(obj,subs)
120+
%==========================================================================
107121
function c = access_fields(obj,subs)
108-
%error('Attempt to reference field of non-structure array.');
109-
%if numel(struct(obj))~=1,
110-
% error('Can only access the fields of simple file_array objects.');
111-
%end;
112-
c = {};
122+
113123
sobj = struct(obj);
114-
for i=1:numel(sobj),
124+
c = cell(1,numel(sobj));
125+
for i=1:numel(sobj)
115126
%obj = class(sobj(i),'file_array');
116127
obj = sobj(i);
117128
switch(subs(1).subs)
118-
case 'fname', t = fname(obj);
119-
case 'dtype', t = dtype(obj);
120-
case 'offset', t = offset(obj);
121-
case 'dim', t = dim(obj);
122-
case 'scl_slope', t = scl_slope(obj);
123-
case 'scl_inter', t = scl_inter(obj);
124-
case 'permission',t = permission(obj);
125-
otherwise, error(['Reference to non-existent field "' subs(1).subs '".']);
126-
end;
127-
if numel(subs)>1,
129+
case 'fname', t = fname(obj);
130+
case 'dtype', t = dtype(obj);
131+
case 'offset', t = offset(obj);
132+
case 'dim', t = dim(obj);
133+
case 'scl_slope', t = scl_slope(obj);
134+
case 'scl_inter', t = scl_inter(obj);
135+
case 'permission', t = permission(obj);
136+
otherwise
137+
error(['Reference to non-existent field "' subs(1).subs '".']);
138+
end
139+
if numel(subs)>1
128140
t = subsref(t,subs(2:end));
129-
end;
141+
end
130142
c{i} = t;
131-
end;
132-
return;
143+
end
133144

145+
146+
%==========================================================================
147+
% function val = multifile2mat(sobj,varargin)
148+
%==========================================================================
134149
function val = multifile2mat(sobj,varargin)
150+
135151
% Convert subscripts into linear index
136-
[indx2{1:length(varargin)}] = ndgrid(varargin{:});
152+
[indx2{1:length(varargin)}] = ndgrid(varargin{:},1);
137153
ind = sub2ind(sobj.dim,indx2{:});
138154

139155
% Work out the partition
140156
dt = datatypes;
141-
sz = dt([dt.code]==sobj.dtype).size;
157+
dt = dt([dt.code]==sobj.dtype);
158+
sz = dt.size;
142159
mem = 400*1024*1024; % in bytes, has to be a multiple of 16 (max([dt.size]))
143160
s = ceil(prod(sobj.dim) * sz / mem);
144161

@@ -149,10 +166,12 @@
149166

150167
% Read data in relevant partitions
151168
obj = sobj;
152-
val = zeros(1,length(x));
169+
val = zeros(length(x),1,func2str(dt.conv));
153170
for i=reshape(find(c),1,[])
154171
obj.offset = sobj.offset + mem*(i-1);
155172
obj.dim = [1 min(mem/sz, prod(sobj.dim)-(i-1)*mem/sz)];
156173
val(cc(i)+1:cc(i+1)) = file2mat(obj,int32(1),int32(x(y==i)));
157174
end
158-
val = reshape(val,cellfun('length',varargin));
175+
r = cellfun('length',varargin);
176+
if numel(r) == 1, r = [r 1]; end
177+
val = reshape(val,r);

@gifti/export.m

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

1010
% Guillaume Flandin
11-
% $Id: export.m 3332 2009-08-25 13:50:08Z guillaume $
11+
% $Id: export.m 3578 2009-11-18 16:19:45Z guillaume $
1212

1313
if numel(this) > 1, warning('Only handle scalar objects yet.'); end
1414

@@ -26,7 +26,7 @@
2626
s.faces = subsref(this, substruct('.', 'faces'));
2727
end
2828
if isfield(this,'cdata')
29-
s.facevertexcdata = subsref(this, substruct('.', 'cdata'));
29+
s.facevertexcdata = double(subsref(this, substruct('.', 'cdata')));
3030
end
3131
try, s; catch, s = struct([]); end
3232

@gifti/plot.m

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

66
% Guillaume Flandin
7-
% $Id: plot.m 2076 2008-09-10 12:34:08Z guillaume $
7+
% $Id: plot.m 3556 2009-11-11 18:20:34Z guillaume $
88

99
% if ishandle(varargin{1})
1010
% h = figure(varargin{1});
@@ -32,6 +32,11 @@
3232
h = gcf;
3333
cdata = subsref(varargin{2},struct('type','.','subs','cdata'));
3434
end
35+
if nargin > 2
36+
indc = varargin{3};
37+
else
38+
indc = 1;
39+
end
3540
end
3641

3742
hp = patch(struct(...
@@ -41,7 +46,7 @@
4146
'EdgeColor', 'none');
4247

4348
if ~isempty(cdata)
44-
set(hp,'FaceVertexCData',cdata(:), 'FaceColor','interp')
49+
set(hp,'FaceVertexCData',cdata(:,indc), 'FaceColor','interp')
4550
end
4651

4752
axis equal;

@gifti/private/isintent.m

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

1111
% Guillaume Flandin
12-
% $Id: isintent.m 2076 2008-09-10 12:34:08Z guillaume $
12+
% $Id: isintent.m 3556 2009-11-11 18:20:34Z guillaume $
1313

1414
a = [];
1515
b = [];
@@ -40,7 +40,7 @@
4040
a(end+1) = loc;
4141
b(end+1) = i;
4242
end
43-
case {'LABEL', 'SHAPE', 'TIME_SERIES', 'RGB_VECTOR', ...
43+
case {'NONE', 'LABEL', 'SHAPE', 'TIME_SERIES', 'RGB_VECTOR', ...
4444
'RGBA_VECTOR' c{:}}
4545
[tf, loc] = ismember('cdata',intent);
4646
if tf

@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 3290 2009-07-27 18:11:52Z guillaume $
13+
% $Id: save.m 3556 2009-11-11 18:20:34Z guillaume $
1414

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

@@ -60,15 +60,15 @@ function save(this,filename,encoding)
6060

6161
% Defaults for DataArray's attributes
6262
%--------------------------------------------------------------------------
63-
[unused,unused,mach] = fopen(fid);
63+
[unused,unused,mach] = fopen(fid);
6464
if ~isempty(strmatch('ieee-be',mach))
6565
def.Endian = 'BigEndian';
6666
elseif ~isempty(strmatch('ieee-le',mach))
6767
def.Endian = 'LittleEndian';
6868
else
6969
error('[GIFTI] Unknown byte order "%s".',mach);
7070
end
71-
def.Encoding = encoding;
71+
def.Encoding = encoding;
7272
def.Intent = 'NIFTI_INTENT_NONE';
7373
def.DataType = 'NIFTI_TYPE_FLOAT32';
7474
def.ExternalFileName = '';

@gifti/subsasgn.m

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

66
% Guillaume Flandin
7-
% $Id: subsasgn.m 2687 2009-02-04 17:14:42Z guillaume $
7+
% $Id: subsasgn.m 3556 2009-11-11 18:20:34Z guillaume $
88

99
switch subs(1).type
1010
case '.'
@@ -35,7 +35,7 @@
3535
in = 'NIFTI_INTENT_VECTOR';
3636
dt = 'NIFTI_TYPE_FLOAT32';
3737
case 'cdata'
38-
in = 'NIFTI_INTENT_SHAPE';
38+
in = 'NIFTI_INTENT_NONE';
3939
dt = 'NIFTI_TYPE_FLOAT32';
4040
otherwise
4141
error('This should not happen.');
@@ -60,12 +60,15 @@
6060
this.data{n}.data = int32(builtin('subsasgn',this.data{n}.data,subs(2:end),A-1));
6161
else
6262
this.data{n}.data = int32(A - 1);
63+
this.data{n}.attributes.Dim = size(A);
6364
end
6465
else
6566
if length(subs) > 1
6667
this.data{n}.data = single(builtin('subsasgn',this.data{n}.data,subs(2:end),A));
68+
this.data{n}.attributes.Dim = size(this.data{n}.data);
6769
else
6870
this.data{n}.data = single(A);
71+
this.data{n}.attributes.Dim = size(A);
6972
end
7073
end
7174
end

@meeg/fiducials.m

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

77
% Vladimir Litvak
8-
% $Id $
8+
% $Id: fiducials.m 3589 2009-11-20 17:17:41Z guillaume $
99

1010
switch nargin
1111
case 1

@meeg/frequencies.m

+3-3
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 3350 2009-09-03 13:19:20Z vladimir $
8+
% $Id: frequencies.m 3579 2009-11-18 16:21:55Z vladimir $
99

1010
if nargin < 3
1111
if strncmpi(transformtype(this), 'TF',2)
@@ -27,10 +27,10 @@
2727
end
2828

2929
if isempty(ind) || isequal(ind, ':')
30-
ind = 1:size(this, 2);
30+
ind = 1:size(this.data.y, 2);
3131
end
3232

33-
if length(ind)~=length(f) || max(ind)>size(this, 2)
33+
if length(ind)~=length(f) || max(ind)>size(this.data.y, 2)
3434
error('Wrong frequency axis or indices');
3535
end
3636

0 commit comments

Comments
 (0)