Skip to content

Commit

Permalink
SPM8 r3408
Browse files Browse the repository at this point in the history
  • Loading branch information
SPMcentral committed Sep 16, 2009
1 parent f4c048c commit 10294b1
Show file tree
Hide file tree
Showing 483 changed files with 27,728 additions and 13,743 deletions.
Binary file modified @file_array/private/file2mat.mexa64
Binary file not shown.
Binary file modified @file_array/private/file2mat.mexglx
Binary file not shown.
Binary file modified @file_array/private/file2mat.mexmaci
Binary file not shown.
Binary file modified @file_array/private/file2mat.mexmaci64
Binary file not shown.
Binary file modified @file_array/private/file2mat.mexw32
Binary file not shown.
Binary file modified @file_array/private/file2mat.mexw64
Binary file not shown.
Binary file modified @file_array/private/mat2file.mexmaci
Binary file not shown.
4 changes: 2 additions & 2 deletions @gifti/export.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% Guillaume Flandin
% $Id: export.m 3081 2009-04-22 20:15:38Z guillaume $
% $Id: export.m 3332 2009-08-25 13:50:08Z guillaume $

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

Expand All @@ -20,7 +20,7 @@

case 'patch'
if isfield(this,'vertices')
s.vertices = subsref(this, substruct('.', 'vertices'));
s.vertices = double(subsref(this, substruct('.', 'vertices')));
end
if isfield(this,'faces')
s.faces = subsref(this, substruct('.', 'faces'));
Expand Down
186 changes: 175 additions & 11 deletions @gifti/save.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,60 @@ function save(this,filename,encoding)
% this - GIfTI object
% filename - name of GIfTI file that will be created
% encoding - optional argument to specify encoding format, among
% ASCII, Base64Binary, GZipBase64Binary, ExternalFileBinary
% ASCII, Base64Binary, GZipBase64Binary, ExternalFileBinary,
% Collada (.dae)
%__________________________________________________________________________
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

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

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

% Open file for writing
% Check filename and file format
%--------------------------------------------------------------------------
ext = '.gii';
if nargin == 1
filename = 'untitled.gii';
else
if nargin == 3 && strcmpi(encoding,'collada')
ext = '.dae';
end
[p,f,e] = fileparts(filename);
if ~ismember(lower(e),{'.gii'})
e = '.gii';
if ~ismember(lower(e),{ext})
e = ext;
end
filename = fullfile(p,[f e]);
end

% Open file for writing
%--------------------------------------------------------------------------
fid = fopen(filename,'wt');
if fid == -1
error('Unable to write file %s: permission denied.',filename);
end

% Write file
%--------------------------------------------------------------------------
switch ext
case '.gii'
if nargin < 3, encoding = 'GZipBase64Binary'; end
fid = save_gii(fid,this,encoding);
case '.dae'
fid = save_dae(fid,this);
otherwise
error('Unknown file format.');
end

% Close file
%--------------------------------------------------------------------------
fclose(fid);

%==========================================================================
% function fid = save_gii(fid,this,encoding)
%==========================================================================
function fid = save_gii(fid,this,encoding)

% Defaults for DataArray's attributes
%--------------------------------------------------------------------------
[unused,unused,mach] = fopen(fid);
Expand All @@ -40,11 +68,7 @@ function save(this,filename,encoding)
else
error('[GIFTI] Unknown byte order "%s".',mach);
end
if nargin > 2
def.Encoding = encoding;
else
def.Encoding = 'GZipBase64Binary';
end
def.Encoding = encoding;
def.Intent = 'NIFTI_INTENT_NONE';
def.DataType = 'NIFTI_TYPE_FLOAT32';
def.ExternalFileName = '';
Expand Down Expand Up @@ -214,4 +238,144 @@ function save(this,filename,encoding)
end

fprintf(fid,'</GIFTI>\n');
fclose(fid);

%==========================================================================
% function fid = save_dae(fid,this)
%==========================================================================
function fid = save_dae(fid,this)

o = inline('blanks(x*3)');

% Split the mesh into connected components
%--------------------------------------------------------------------------
s = struct(this);
try
C = spm_mesh_label(s.faces);
d = [];
for i=1:numel(unique(C))
d(i).faces = s.faces(C==i,:);
u = unique(d(i).faces);
d(i).vertices = s.vertices(u,:);
a = 1:max(d(i).faces(:));
a(u) = 1:size(d(i).vertices,1);
%a = sparse(1,double(u),1:1:size(d(i).vertices,1));
d(i).faces = a(d(i).faces);
end
s = d;
end

% Prolog & root of the Collada XML file
%--------------------------------------------------------------------------
fprintf(fid,'<?xml version="1.0"?>\n');
fprintf(fid,'<COLLADA xmlns="http://www.collada.org/2008/03/COLLADASchema" version="1.5.0">\n');

% Assets
%--------------------------------------------------------------------------
fprintf(fid,'%s<asset>\n',o(1));
fprintf(fid,'%s<contributor>\n',o(2));
fprintf(fid,'%s<author_website>%s</author_website>\n',o(3),...
'http://www.fil.ion.ucl.ac.uk/spm/');
fprintf(fid,'%s<authoring_tool>%s</authoring_tool>\n',o(3),spm('Ver'));
fprintf(fid,'%s</contributor>\n',o(2));
fprintf(fid,'%s<created>%s</created>\n',o(2),datestr(now,'yyyy-mm-ddTHH:MM:SSZ'));
fprintf(fid,'%s<modified>%s</modified>\n',o(2),datestr(now,'yyyy-mm-ddTHH:MM:SSZ'));
fprintf(fid,'%s<unit name="millimeter" meter="0.001"/>\n',o(2));
fprintf(fid,'%s<up_axis>Z_UP</up_axis>\n',o(2));
fprintf(fid,'%s</asset>\n',o(1));

% Image, Materials, Effects
%--------------------------------------------------------------------------
%fprintf(fid,'%s<library_images/>\n',o(1));

fprintf(fid,'%s<library_materials>\n',o(1));
for i=1:numel(s)
fprintf(fid,'%s<material id="material%d" name="material%d">\n',o(2),i,i);
fprintf(fid,'%s<instance_effect url="#material%d-effect"/>\n',o(3),i);
fprintf(fid,'%s</material>\n',o(2));
end
fprintf(fid,'%s</library_materials>\n',o(1));

fprintf(fid,'%s<library_effects>\n',o(1));
for i=1:numel(s)
fprintf(fid,'%s<effect id="material%d-effect" name="material%d-effect">\n',o(2),i,i);
fprintf(fid,'%s<profile_COMMON>\n',o(3));
fprintf(fid,'%s<technique sid="COMMON">\n',o(4));
fprintf(fid,'%s<lambert>\n',o(5));
fprintf(fid,'%s<emission>\n',o(6));
fprintf(fid,'%s<color>%f %f %f %d</color>\n',o(7),[0 0 0 1]);
fprintf(fid,'%s</emission>\n',o(6));
fprintf(fid,'%s<ambient>\n',o(6));
fprintf(fid,'%s<color>%f %f %f %d</color>\n',o(7),[0 0 0 1]);
fprintf(fid,'%s</ambient>\n',o(6));
fprintf(fid,'%s<diffuse>\n',o(6));
fprintf(fid,'%s<color>%f %f %f %d</color>\n',o(7),[0.5 0.5 0.5 1]);
fprintf(fid,'%s</diffuse>\n',o(6));
fprintf(fid,'%s<transparent>\n',o(6));
fprintf(fid,'%s<color>%d %d %d %d</color>\n',o(7),[1 1 1 1]);
fprintf(fid,'%s</transparent>\n',o(6));
fprintf(fid,'%s<transparency>\n',o(6));
fprintf(fid,'%s<float>%f</float>\n',o(7),0);
fprintf(fid,'%s</transparency>\n',o(6));
fprintf(fid,'%s</lambert>\n',o(5));
fprintf(fid,'%s</technique>\n',o(4));
fprintf(fid,'%s</profile_COMMON>\n',o(3));
fprintf(fid,'%s</effect>\n',o(2));
end
fprintf(fid,'%s</library_effects>\n',o(1));

% Geometry
%--------------------------------------------------------------------------
fprintf(fid,'%s<library_geometries>\n',o(1));
for i=1:numel(s)
fprintf(fid,'%s<geometry id="shape%d" name="shape%d">\n',o(2),i,i);
fprintf(fid,'%s<mesh>\n',o(3));
fprintf(fid,'%s<source id="shape%d-positions">\n',o(4),i);
fprintf(fid,'%s<float_array id="shape%d-positions-array" count="%d">',o(5),i,numel(s(i).vertices));
fprintf(fid,'%f ',repmat(s(i).vertices',1,[]));
fprintf(fid,'</float_array>\n');
fprintf(fid,'%s<technique_common>\n',o(5));
fprintf(fid,'%s<accessor count="%d" offset="0" source="#shape%d-positions-array" stride="3">\n',o(6),size(s(i).vertices,1),i);
fprintf(fid,'%s<param name="X" type="float" />\n',o(7));
fprintf(fid,'%s<param name="Y" type="float" />\n',o(7));
fprintf(fid,'%s<param name="Z" type="float" />\n',o(7));
fprintf(fid,'%s</accessor>\n',o(6));
fprintf(fid,'%s</technique_common>\n',o(5));
fprintf(fid,'%s</source>\n',o(4));
fprintf(fid,'%s<vertices id="shape%d-vertices">\n',o(4),i);
fprintf(fid,'%s<input semantic="POSITION" source="#shape%d-positions"/>\n',o(5),i);
fprintf(fid,'%s</vertices>\n',o(4));
fprintf(fid,'%s<triangles material="material%d" count="%d">\n',o(4),i,size(s(i).faces,1));
fprintf(fid,'%s<input semantic="VERTEX" source="#shape%d-vertices" offset="0"/>\n',o(5),i);
fprintf(fid,'%s<p>',o(5));
fprintf(fid,'%d ',repmat(s(i).faces',1,[])-1);
fprintf(fid,'</p>\n');
fprintf(fid,'%s</triangles>\n',o(4));
fprintf(fid,'%s</mesh>\n',o(3));
fprintf(fid,'%s</geometry>\n',o(2));
end
fprintf(fid,'%s</library_geometries>\n',o(1));

% Scene
%--------------------------------------------------------------------------
fprintf(fid,'%s<library_visual_scenes>\n',o(1));
fprintf(fid,'%s<visual_scene id="VisualSceneNode" name="SceneNode">\n',o(2));
for i=1:numel(s)
fprintf(fid,'%s<node id="node%d">\n',o(3),i);
fprintf(fid,'%s<instance_geometry url="#shape%d">\n',o(4),i);
fprintf(fid,'%s<bind_material>\n',o(5));
fprintf(fid,'%s<technique_common>\n',o(6));
fprintf(fid,'%s<instance_material symbol="material%d" target="#material%d"/>\n',o(7),i,i);
fprintf(fid,'%s</technique_common>\n',o(6));
fprintf(fid,'%s</bind_material>\n',o(5));
fprintf(fid,'%s</instance_geometry>\n',o(4));
fprintf(fid,'%s</node>\n',o(3));
end
fprintf(fid,'%s</visual_scene>\n',o(2));
fprintf(fid,'%s</library_visual_scenes>\n',o(1));
fprintf(fid,'%s<scene>\n',o(1));
fprintf(fid,'%s<instance_visual_scene url="#VisualSceneNode" />\n',o(2));
fprintf(fid,'%s</scene>\n',o(1));

% End of XML
%--------------------------------------------------------------------------
fprintf(fid,'</COLLADA>\n');
6 changes: 5 additions & 1 deletion @meeg/check.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% Vladimir Litvak
% $Id: check.m 2720 2009-02-09 19:50:46Z vladimir $
% $Id: check.m 3196 2009-06-11 12:54:47Z vladimir $

if nargin == 1
option = 'basic';
end

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

Expand Down
20 changes: 15 additions & 5 deletions @meeg/clone.m
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
function new = clone(this, fnamedat, dim)
function new = clone(this, fnamedat, dim, reset)
% Creates a copy of the object with a new, empty data file,
% possibly changing dimensions
% FORMAT new = clone(this, fnamedat, dim)
% FORMAT new = clone(this, fnamedat, dim, reset)
% reset - 0 (default) do not reset channel or trial info unless dimensions
% change, 1 - reset channels only, 2 - trials only, 3 both
% Note that when fnamedat comes with a path, the cloned meeg object uses
% it. Otherwise, its path is by definition that of the meeg object to be
% cloned.
% _________________________________________________________________________
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% Stefan Kiebel, Vladimir Litvak
% $Id: clone.m 2476 2008-11-18 12:58:57Z christophe $
% $Id: clone.m 3350 2009-09-03 13:19:20Z vladimir $

if nargin < 4
reset = 0;
end

if nargin < 3
if ~strcmp(transformtype(this), 'TF')
Expand Down Expand Up @@ -39,6 +45,10 @@
d(end, end, end, end) = 0;
nsampl = dim(3);
ntrial = dim(4);

if ~strncmpi(transformtype(new), 'TF',2)
new = transformtype(new, 'TF');
end
else
error('Dimensions different from 3 or 4 are not supported.');
end
Expand All @@ -52,14 +62,14 @@
new.path = pth;

% ensure consistency
if dim(1) ~= nchannels(this)
if (dim(1) ~= nchannels(this)) || ismember(reset, [1 3])
new.channels = [];
for i = 1:dim(1)
new.channels(i).label = ['Ch' num2str(i)];
end
end

if ntrial ~= ntrials(this)
if ntrial ~= ntrials(this) || ismember(reset, [2 3])
new.trials = repmat(struct('label', 'Undefined'), 1, ntrial);
end

Expand Down
4 changes: 2 additions & 2 deletions @meeg/condlist.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

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

res = getset(this, 'trials', 'label');
if ~iscell(res)
Expand All @@ -23,7 +23,7 @@

if numel(res)>1 && isfield(this.other, 'condlist') &&...
iscell(this.other.condlist) && ~isempty(this.other.condlist)
[sel1, sel2] = spm_match_str(this.other.condlist, res);
[sel1, sel2] = match_str(this.other.condlist, res);
res = res([sel2(:)' setdiff(1:numel(res), sel2)]);
end
else
Expand Down
Loading

0 comments on commit 10294b1

Please sign in to comment.