Home > marsbar > @mardo_99 > save_spm.m

save_spm

PURPOSE ^

method to save design as SPM format design structure

SYNOPSIS ^

function tf = save_spm(D, fname);

DESCRIPTION ^

 method to save design as SPM format design structure
 FORMAT tf = save_spm(D, fname);
 
 Inputs
 D      - design object
 fname  - filename
 
 Outputs
 tf     - flag ==1 if successful
 
 $Id$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function tf = save_spm(D, fname);
0002 % method to save design as SPM format design structure
0003 % FORMAT tf = save_spm(D, fname);
0004 %
0005 % Inputs
0006 % D      - design object
0007 % fname  - filename
0008 %
0009 % Outputs
0010 % tf     - flag ==1 if successful
0011 %
0012 % $Id$
0013   
0014 if nargin < 2
0015   if is_spm_estimated(D)
0016     fname = 'SPM.mat';
0017   elseif has_images(D)
0018     fname = 'SPMcfg.mat';
0019   elseif is_fmri(D)
0020     fname = 'SPM_fMRIDesMtx.mat';
0021   else
0022     error('Cannot work out design type for default filename');
0023   end
0024 end
0025 
0026 % Convert vols to native format
0027 D = convert_vols(D, native_vol_ver(D));
0028 
0029 SPM = des_struct(D);
0030 if ~mars_utils('isabspath', fname)
0031   Swd = mars_struct('getifthere', SPM, 'swd');
0032   if isempty(Swd)
0033     error('No path passed, and none in design');
0034   end
0035   fname = fullfile(Swd, fname);
0036 else
0037   SPM.swd = fileparts(fname);
0038 end
0039 
0040 try 
0041   if verbose(D)
0042     fprintf('Saving design to file %s\n', fname);
0043   end
0044   savestruct(SPM, fname);
0045   tf = 1;
0046 catch
0047   warning(lasterr);
0048   tf = 0;
0049 end

Generated on Wed 11-May-2022 16:26:09 by m2html © 2003-2019