Skip to content

Commit

Permalink
updated external mask handling in SPM
Browse files Browse the repository at this point in the history
git-svn-id: https://nipy.svn.sourceforge.net/svnroot/nipy/nipype/trunk@518 ead46cd0-7350-4e37-8683-fc4c6f79bf00
  • Loading branch information
satra committed Oct 2, 2009
1 parent 59b3e2f commit fe9d0e0
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions nipype/interfaces/spm.py
Expand Up @@ -215,7 +215,7 @@ def _generate_job(self, prefix='', contents=None):
jobstring += "%s = %s;\n" % (prefix,str(contents))
return jobstring

def _make_matlab_command(self, jobtype, jobname, contents, cwd=None,mod_defaults=None):
def _make_matlab_command(self, jobtype, jobname, contents, cwd=None, postscript=None):
""" generates a mfile to build job structure
Arguments
---------
Expand All @@ -231,8 +231,6 @@ def _make_matlab_command(self, jobtype, jobname, contents, cwd=None,mod_defaults
mscript += "fprintf('SPM version: %s\n',spm('ver'));\n"
mscript += "fprintf('SPM path: %s\n',which('spm'));\n"
mscript += "spm_defaults;\n\n"
if mod_defaults is not None:
mscript += mod_defaults
if self.mfile:
if jobname in ['smooth','preproc','fmri_spec','fmri_est'] :
mscript += self._generate_job('jobs{1}.%s{1}.%s(1)' %
Expand All @@ -246,7 +244,9 @@ def _make_matlab_command(self, jobtype, jobname, contents, cwd=None,mod_defaults
savemat(os.path.join(cwd,'pyjobs_%s.mat'%jobname), jobdef)
mscript += "load pyjobs_%s;\n\n" % jobname
#mscript += "if strcmp(spm('ver'),'SPM8'), jobs=spm_jobman('spm5tospm8',jobs); end\n"
mscript += 'spm_jobman(\'run\',jobs);'
mscript += 'spm_jobman(\'run\',jobs);\n'
if postscript is not None:
mscript += postscript
cmdline = self._gen_matlab_command(mscript, cwd=cwd,
script_name='pyscript_%s' % jobname,
mfile=self.mfile)
Expand Down Expand Up @@ -1522,14 +1522,21 @@ def _compile_command(self):
else generates a job structure and saves in .mat
"""
if self.inputs.mask_image is not None:
mod_defaults = "global defaults; defaults.mask.thresh = -inf\n"
# SPM doesn't handle explicit masking properly, especially
# when you want to use the entire mask image
postscript = "load SPM;\n"
postscript += "SPM.xM.VM = spm_vol('%s');\n"%self.inputs.mask_image
postscript += "SPM.xM.I = 0;\n"
postscript += "SPM.xM.T = [];\n"
postscript += "SPM.xM.TH = ones(size(SPM.xM.TH))*(-Inf);\n"
postscript += "SPM.xM.xs = struct('Masking', 'explicit masking only');\n"
postscript += "save SPM SPM;\n"
else:
mod_defaults = None

postscript = None
self._cmdline, mscript =self._make_matlab_command('stats',
'fmri_spec',
[self._parseinputs()],
mod_defaults=mod_defaults)
postscript=postscript)

def outputs_help(self):
"""
Expand Down

0 comments on commit fe9d0e0

Please sign in to comment.