Skip to content

Commit 10294b1

Browse files
committed
SPM8 r3408
1 parent f4c048c commit 10294b1

File tree

483 files changed

+27728
-13743
lines changed

Some content is hidden

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

483 files changed

+27728
-13743
lines changed

@file_array/private/file2mat.mexa64

0 Bytes
Binary file not shown.

@file_array/private/file2mat.mexglx

0 Bytes
Binary file not shown.

@file_array/private/file2mat.mexmaci

3.96 KB
Binary file not shown.
0 Bytes
Binary file not shown.

@file_array/private/file2mat.mexw32

1.5 KB
Binary file not shown.

@file_array/private/file2mat.mexw64

512 Bytes
Binary file not shown.

@file_array/private/mat2file.mexmaci

-8 Bytes
Binary file not shown.

@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 3081 2009-04-22 20:15:38Z guillaume $
11+
% $Id: export.m 3332 2009-08-25 13:50:08Z guillaume $
1212

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

@@ -20,7 +20,7 @@
2020

2121
case 'patch'
2222
if isfield(this,'vertices')
23-
s.vertices = subsref(this, substruct('.', 'vertices'));
23+
s.vertices = double(subsref(this, substruct('.', 'vertices')));
2424
end
2525
if isfield(this,'faces')
2626
s.faces = subsref(this, substruct('.', 'faces'));

@gifti/save.m

+175-11
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,60 @@ function save(this,filename,encoding)
44
% this - GIfTI object
55
% filename - name of GIfTI file that will be created
66
% encoding - optional argument to specify encoding format, among
7-
% ASCII, Base64Binary, GZipBase64Binary, ExternalFileBinary
7+
% ASCII, Base64Binary, GZipBase64Binary, ExternalFileBinary,
8+
% Collada (.dae)
89
%__________________________________________________________________________
910
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
1011

1112
% Guillaume Flandin
12-
% $Id: save.m 2076 2008-09-10 12:34:08Z guillaume $
13+
% $Id: save.m 3290 2009-07-27 18:11:52Z guillaume $
1314

1415
error(nargchk(1,3,nargin));
1516

16-
% Open file for writing
17+
% Check filename and file format
1718
%--------------------------------------------------------------------------
19+
ext = '.gii';
1820
if nargin == 1
1921
filename = 'untitled.gii';
2022
else
23+
if nargin == 3 && strcmpi(encoding,'collada')
24+
ext = '.dae';
25+
end
2126
[p,f,e] = fileparts(filename);
22-
if ~ismember(lower(e),{'.gii'})
23-
e = '.gii';
27+
if ~ismember(lower(e),{ext})
28+
e = ext;
2429
end
2530
filename = fullfile(p,[f e]);
2631
end
2732

33+
% Open file for writing
34+
%--------------------------------------------------------------------------
2835
fid = fopen(filename,'wt');
2936
if fid == -1
3037
error('Unable to write file %s: permission denied.',filename);
3138
end
3239

40+
% Write file
41+
%--------------------------------------------------------------------------
42+
switch ext
43+
case '.gii'
44+
if nargin < 3, encoding = 'GZipBase64Binary'; end
45+
fid = save_gii(fid,this,encoding);
46+
case '.dae'
47+
fid = save_dae(fid,this);
48+
otherwise
49+
error('Unknown file format.');
50+
end
51+
52+
% Close file
53+
%--------------------------------------------------------------------------
54+
fclose(fid);
55+
56+
%==========================================================================
57+
% function fid = save_gii(fid,this,encoding)
58+
%==========================================================================
59+
function fid = save_gii(fid,this,encoding)
60+
3361
% Defaults for DataArray's attributes
3462
%--------------------------------------------------------------------------
3563
[unused,unused,mach] = fopen(fid);
@@ -40,11 +68,7 @@ function save(this,filename,encoding)
4068
else
4169
error('[GIFTI] Unknown byte order "%s".',mach);
4270
end
43-
if nargin > 2
44-
def.Encoding = encoding;
45-
else
46-
def.Encoding = 'GZipBase64Binary';
47-
end
71+
def.Encoding = encoding;
4872
def.Intent = 'NIFTI_INTENT_NONE';
4973
def.DataType = 'NIFTI_TYPE_FLOAT32';
5074
def.ExternalFileName = '';
@@ -214,4 +238,144 @@ function save(this,filename,encoding)
214238
end
215239

216240
fprintf(fid,'</GIFTI>\n');
217-
fclose(fid);
241+
242+
%==========================================================================
243+
% function fid = save_dae(fid,this)
244+
%==========================================================================
245+
function fid = save_dae(fid,this)
246+
247+
o = inline('blanks(x*3)');
248+
249+
% Split the mesh into connected components
250+
%--------------------------------------------------------------------------
251+
s = struct(this);
252+
try
253+
C = spm_mesh_label(s.faces);
254+
d = [];
255+
for i=1:numel(unique(C))
256+
d(i).faces = s.faces(C==i,:);
257+
u = unique(d(i).faces);
258+
d(i).vertices = s.vertices(u,:);
259+
a = 1:max(d(i).faces(:));
260+
a(u) = 1:size(d(i).vertices,1);
261+
%a = sparse(1,double(u),1:1:size(d(i).vertices,1));
262+
d(i).faces = a(d(i).faces);
263+
end
264+
s = d;
265+
end
266+
267+
% Prolog & root of the Collada XML file
268+
%--------------------------------------------------------------------------
269+
fprintf(fid,'<?xml version="1.0"?>\n');
270+
fprintf(fid,'<COLLADA xmlns="http://www.collada.org/2008/03/COLLADASchema" version="1.5.0">\n');
271+
272+
% Assets
273+
%--------------------------------------------------------------------------
274+
fprintf(fid,'%s<asset>\n',o(1));
275+
fprintf(fid,'%s<contributor>\n',o(2));
276+
fprintf(fid,'%s<author_website>%s</author_website>\n',o(3),...
277+
'http://www.fil.ion.ucl.ac.uk/spm/');
278+
fprintf(fid,'%s<authoring_tool>%s</authoring_tool>\n',o(3),spm('Ver'));
279+
fprintf(fid,'%s</contributor>\n',o(2));
280+
fprintf(fid,'%s<created>%s</created>\n',o(2),datestr(now,'yyyy-mm-ddTHH:MM:SSZ'));
281+
fprintf(fid,'%s<modified>%s</modified>\n',o(2),datestr(now,'yyyy-mm-ddTHH:MM:SSZ'));
282+
fprintf(fid,'%s<unit name="millimeter" meter="0.001"/>\n',o(2));
283+
fprintf(fid,'%s<up_axis>Z_UP</up_axis>\n',o(2));
284+
fprintf(fid,'%s</asset>\n',o(1));
285+
286+
% Image, Materials, Effects
287+
%--------------------------------------------------------------------------
288+
%fprintf(fid,'%s<library_images/>\n',o(1));
289+
290+
fprintf(fid,'%s<library_materials>\n',o(1));
291+
for i=1:numel(s)
292+
fprintf(fid,'%s<material id="material%d" name="material%d">\n',o(2),i,i);
293+
fprintf(fid,'%s<instance_effect url="#material%d-effect"/>\n',o(3),i);
294+
fprintf(fid,'%s</material>\n',o(2));
295+
end
296+
fprintf(fid,'%s</library_materials>\n',o(1));
297+
298+
fprintf(fid,'%s<library_effects>\n',o(1));
299+
for i=1:numel(s)
300+
fprintf(fid,'%s<effect id="material%d-effect" name="material%d-effect">\n',o(2),i,i);
301+
fprintf(fid,'%s<profile_COMMON>\n',o(3));
302+
fprintf(fid,'%s<technique sid="COMMON">\n',o(4));
303+
fprintf(fid,'%s<lambert>\n',o(5));
304+
fprintf(fid,'%s<emission>\n',o(6));
305+
fprintf(fid,'%s<color>%f %f %f %d</color>\n',o(7),[0 0 0 1]);
306+
fprintf(fid,'%s</emission>\n',o(6));
307+
fprintf(fid,'%s<ambient>\n',o(6));
308+
fprintf(fid,'%s<color>%f %f %f %d</color>\n',o(7),[0 0 0 1]);
309+
fprintf(fid,'%s</ambient>\n',o(6));
310+
fprintf(fid,'%s<diffuse>\n',o(6));
311+
fprintf(fid,'%s<color>%f %f %f %d</color>\n',o(7),[0.5 0.5 0.5 1]);
312+
fprintf(fid,'%s</diffuse>\n',o(6));
313+
fprintf(fid,'%s<transparent>\n',o(6));
314+
fprintf(fid,'%s<color>%d %d %d %d</color>\n',o(7),[1 1 1 1]);
315+
fprintf(fid,'%s</transparent>\n',o(6));
316+
fprintf(fid,'%s<transparency>\n',o(6));
317+
fprintf(fid,'%s<float>%f</float>\n',o(7),0);
318+
fprintf(fid,'%s</transparency>\n',o(6));
319+
fprintf(fid,'%s</lambert>\n',o(5));
320+
fprintf(fid,'%s</technique>\n',o(4));
321+
fprintf(fid,'%s</profile_COMMON>\n',o(3));
322+
fprintf(fid,'%s</effect>\n',o(2));
323+
end
324+
fprintf(fid,'%s</library_effects>\n',o(1));
325+
326+
% Geometry
327+
%--------------------------------------------------------------------------
328+
fprintf(fid,'%s<library_geometries>\n',o(1));
329+
for i=1:numel(s)
330+
fprintf(fid,'%s<geometry id="shape%d" name="shape%d">\n',o(2),i,i);
331+
fprintf(fid,'%s<mesh>\n',o(3));
332+
fprintf(fid,'%s<source id="shape%d-positions">\n',o(4),i);
333+
fprintf(fid,'%s<float_array id="shape%d-positions-array" count="%d">',o(5),i,numel(s(i).vertices));
334+
fprintf(fid,'%f ',repmat(s(i).vertices',1,[]));
335+
fprintf(fid,'</float_array>\n');
336+
fprintf(fid,'%s<technique_common>\n',o(5));
337+
fprintf(fid,'%s<accessor count="%d" offset="0" source="#shape%d-positions-array" stride="3">\n',o(6),size(s(i).vertices,1),i);
338+
fprintf(fid,'%s<param name="X" type="float" />\n',o(7));
339+
fprintf(fid,'%s<param name="Y" type="float" />\n',o(7));
340+
fprintf(fid,'%s<param name="Z" type="float" />\n',o(7));
341+
fprintf(fid,'%s</accessor>\n',o(6));
342+
fprintf(fid,'%s</technique_common>\n',o(5));
343+
fprintf(fid,'%s</source>\n',o(4));
344+
fprintf(fid,'%s<vertices id="shape%d-vertices">\n',o(4),i);
345+
fprintf(fid,'%s<input semantic="POSITION" source="#shape%d-positions"/>\n',o(5),i);
346+
fprintf(fid,'%s</vertices>\n',o(4));
347+
fprintf(fid,'%s<triangles material="material%d" count="%d">\n',o(4),i,size(s(i).faces,1));
348+
fprintf(fid,'%s<input semantic="VERTEX" source="#shape%d-vertices" offset="0"/>\n',o(5),i);
349+
fprintf(fid,'%s<p>',o(5));
350+
fprintf(fid,'%d ',repmat(s(i).faces',1,[])-1);
351+
fprintf(fid,'</p>\n');
352+
fprintf(fid,'%s</triangles>\n',o(4));
353+
fprintf(fid,'%s</mesh>\n',o(3));
354+
fprintf(fid,'%s</geometry>\n',o(2));
355+
end
356+
fprintf(fid,'%s</library_geometries>\n',o(1));
357+
358+
% Scene
359+
%--------------------------------------------------------------------------
360+
fprintf(fid,'%s<library_visual_scenes>\n',o(1));
361+
fprintf(fid,'%s<visual_scene id="VisualSceneNode" name="SceneNode">\n',o(2));
362+
for i=1:numel(s)
363+
fprintf(fid,'%s<node id="node%d">\n',o(3),i);
364+
fprintf(fid,'%s<instance_geometry url="#shape%d">\n',o(4),i);
365+
fprintf(fid,'%s<bind_material>\n',o(5));
366+
fprintf(fid,'%s<technique_common>\n',o(6));
367+
fprintf(fid,'%s<instance_material symbol="material%d" target="#material%d"/>\n',o(7),i,i);
368+
fprintf(fid,'%s</technique_common>\n',o(6));
369+
fprintf(fid,'%s</bind_material>\n',o(5));
370+
fprintf(fid,'%s</instance_geometry>\n',o(4));
371+
fprintf(fid,'%s</node>\n',o(3));
372+
end
373+
fprintf(fid,'%s</visual_scene>\n',o(2));
374+
fprintf(fid,'%s</library_visual_scenes>\n',o(1));
375+
fprintf(fid,'%s<scene>\n',o(1));
376+
fprintf(fid,'%s<instance_visual_scene url="#VisualSceneNode" />\n',o(2));
377+
fprintf(fid,'%s</scene>\n',o(1));
378+
379+
% End of XML
380+
%--------------------------------------------------------------------------
381+
fprintf(fid,'</COLLADA>\n');

@meeg/check.m

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

1313
% Vladimir Litvak
14-
% $Id: check.m 2720 2009-02-09 19:50:46Z vladimir $
14+
% $Id: check.m 3196 2009-06-11 12:54:47Z vladimir $
15+
16+
if nargin == 1
17+
option = 'basic';
18+
end
1519

1620
[ok, this] = checkmeeg(struct(this), option);
1721

@meeg/clone.m

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
function new = clone(this, fnamedat, dim)
1+
function new = clone(this, fnamedat, dim, reset)
22
% Creates a copy of the object with a new, empty data file,
33
% possibly changing dimensions
4-
% FORMAT new = clone(this, fnamedat, dim)
4+
% FORMAT new = clone(this, fnamedat, dim, reset)
5+
% reset - 0 (default) do not reset channel or trial info unless dimensions
6+
% change, 1 - reset channels only, 2 - trials only, 3 both
57
% Note that when fnamedat comes with a path, the cloned meeg object uses
68
% it. Otherwise, its path is by definition that of the meeg object to be
79
% cloned.
810
% _________________________________________________________________________
911
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
1012

1113
% Stefan Kiebel, Vladimir Litvak
12-
% $Id: clone.m 2476 2008-11-18 12:58:57Z christophe $
14+
% $Id: clone.m 3350 2009-09-03 13:19:20Z vladimir $
15+
16+
if nargin < 4
17+
reset = 0;
18+
end
1319

1420
if nargin < 3
1521
if ~strcmp(transformtype(this), 'TF')
@@ -39,6 +45,10 @@
3945
d(end, end, end, end) = 0;
4046
nsampl = dim(3);
4147
ntrial = dim(4);
48+
49+
if ~strncmpi(transformtype(new), 'TF',2)
50+
new = transformtype(new, 'TF');
51+
end
4252
else
4353
error('Dimensions different from 3 or 4 are not supported.');
4454
end
@@ -52,14 +62,14 @@
5262
new.path = pth;
5363

5464
% ensure consistency
55-
if dim(1) ~= nchannels(this)
65+
if (dim(1) ~= nchannels(this)) || ismember(reset, [1 3])
5666
new.channels = [];
5767
for i = 1:dim(1)
5868
new.channels(i).label = ['Ch' num2str(i)];
5969
end
6070
end
6171

62-
if ntrial ~= ntrials(this)
72+
if ntrial ~= ntrials(this) || ismember(reset, [2 3])
6373
new.trials = repmat(struct('label', 'Undefined'), 1, ntrial);
6474
end
6575

@meeg/condlist.m

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

88
% Vladimir Litvak
9-
% $Id: condlist.m 3046 2009-04-02 14:28:31Z vladimir $
9+
% $Id: condlist.m 3254 2009-07-07 15:18:54Z vladimir $
1010

1111
res = getset(this, 'trials', 'label');
1212
if ~iscell(res)
@@ -23,7 +23,7 @@
2323

2424
if numel(res)>1 && isfield(this.other, 'condlist') &&...
2525
iscell(this.other.condlist) && ~isempty(this.other.condlist)
26-
[sel1, sel2] = spm_match_str(this.other.condlist, res);
26+
[sel1, sel2] = match_str(this.other.condlist, res);
2727
res = res([sel2(:)' setdiff(1:numel(res), sel2)]);
2828
end
2929
else

0 commit comments

Comments
 (0)