Home > rest_20090422 > rest_spm5_files > @read_nifti > private > write_extras.m

write_extras

PURPOSE ^

Write extra bits of information

SYNOPSIS ^

function extras = write_extras(fname,extras)

DESCRIPTION ^

 Write extra bits of information
_______________________________________________________________________
 Copyright (C) 2005 Wellcome Department of Imaging Neuroscience

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

DOWNLOAD ^

write_extras.m

SOURCE CODE ^

0001 function extras = write_extras(fname,extras)
0002 % Write extra bits of information
0003 %_______________________________________________________________________
0004 % Copyright (C) 2005 Wellcome Department of Imaging Neuroscience
0005 
0006 %
0007 % $Id: write_extras.m 253 2005-10-13 15:31:34Z guillaume $
0008 
0009 
0010 [pth,nam,ext] = fileparts(fname);
0011 switch ext
0012 case {'.hdr','.img','.nii'}
0013     mname = fullfile(pth,[nam '.mat']);
0014 case {'.HDR','.IMG','.NII'}
0015     mname = fullfile(pth,[nam '.MAT']);
0016 otherwise
0017     mname = fullfile(pth,[nam '.mat']);
0018 end
0019 if isstruct(extras) && ~isempty(fieldnames(extras)),
0020     savefields(mname,extras);
0021 end;
0022 
0023 function savefields(fnam,p)
0024 if length(p)>1, error('Can''t save fields.'); end;
0025 fn = fieldnames(p);
0026 for i_=1:length(fn),
0027     eval([fn{i_} '= p.' fn{i_} ';']);
0028 end;
0029 if numel(fn)>0,
0030     icatb_save(fnam,fn{:});
0031 end;
0032 return;
0033

Generated on Wed 29-Apr-2009 01:06:38 by m2html © 2005