Skip to content

Commit 533e1b3

Browse files
committed
Merge pull request #886 from satra/enh/spm12
fix: spm12b compatibility
2 parents df7d9a6 + d52c782 commit 533e1b3

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Next Release
2323
* ENH: New ANTs interface: LaplacianThickness
2424
* FIX: MRTrix tracking algorithms were ignoring mask parameters.
2525
* FIX: FNIRT registration pathway and associated OpenFMRI example script
26+
* FIX: spm12b compatibility for Model estimate
2627

2728
Release 0.9.2 (January 31, 2014)
2829
============

examples/fmri_spm.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
1616
Import necessary modules from nipype."""
1717

18+
import os # system functions
19+
1820
from nipype import config
1921
config.enable_provenance()
2022

@@ -30,7 +32,7 @@
3032
import nipype.pipeline.engine as pe # pypeline engine
3133
import nipype.algorithms.rapidart as ra # artifact detection
3234
import nipype.algorithms.modelgen as model # model specification
33-
import os # system functions
35+
import nipype.interfaces.matlab as mlab
3436

3537
"""
3638
@@ -50,6 +52,9 @@
5052
# import nipype.interfaces.matlab as mlab # how to run matlab
5153
# mlab.MatlabCommand.set_default_matlab_cmd("matlab -nodesktop -nosplash")
5254

55+
# In case a different path is required
56+
# mlab.MatlabCommand.set_default_paths('/software/matlab/spm12b/spm12b_r5918')
57+
5358
"""The nipype tutorial contains data for two subjects. Subject data
5459
is in two subdirectories, ``s1`` and ``s2``. Each subject directory
5560
contains four functional volumes: f3.nii, f5.nii, f7.nii, f10.nii. And

nipype/interfaces/spm/model.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,27 @@ def _parse_inputs(self):
213213
def _list_outputs(self):
214214
outputs = self._outputs().get()
215215
pth, _ = os.path.split(self.inputs.spm_mat_file)
216-
mask = os.path.join(pth, 'mask.img')
216+
spm12 = '12' in self.version.split('.')[0]
217+
if spm12:
218+
mask = os.path.join(pth, 'mask.nii')
219+
else:
220+
mask = os.path.join(pth, 'mask.img')
217221
outputs['mask_image'] = mask
218222
spm = sio.loadmat(self.inputs.spm_mat_file, struct_as_record=False)
219223
betas = []
220224
for vbeta in spm['SPM'][0, 0].Vbeta[0]:
221225
betas.append(str(os.path.join(pth, vbeta.fname[0])))
222226
if betas:
223227
outputs['beta_images'] = betas
224-
resms = os.path.join(pth, 'ResMS.img')
228+
if spm12:
229+
resms = os.path.join(pth, 'ResMS.nii')
230+
else:
231+
resms = os.path.join(pth, 'ResMS.img')
225232
outputs['residual_image'] = resms
226-
rpv = os.path.join(pth, 'RPV.img')
233+
if spm12:
234+
rpv = os.path.join(pth, 'RPV.nii')
235+
else:
236+
rpv = os.path.join(pth, 'RPV.img')
227237
outputs['RPVimage'] = rpv
228238
spm = os.path.join(pth, 'SPM.mat')
229239
outputs['spm_mat_file'] = spm
@@ -382,10 +392,17 @@ def _list_outputs(self):
382392
if con_images:
383393
outputs['con_images'] = con_images
384394
outputs['spmT_images'] = spmT_images
385-
ess = glob(os.path.join(pth, 'ess*.img'))
395+
spm12 = '12' in self.version.split('.')[0]
396+
if spm12:
397+
ess = glob(os.path.join(pth, 'ess*.nii'))
398+
else:
399+
ess = glob(os.path.join(pth, 'ess*.img'))
386400
if len(ess) > 0:
387401
outputs['ess_images'] = sorted(ess)
388-
spmf = glob(os.path.join(pth, 'spmF*.img'))
402+
if spm12:
403+
spmf = glob(os.path.join(pth, 'spmF*.nii'))
404+
else:
405+
spmf = glob(os.path.join(pth, 'spmF*.img'))
389406
if len(spmf) > 0:
390407
outputs['spmF_images'] = sorted(spmf)
391408
outputs['spm_mat_file'] = self.inputs.spm_mat_file

0 commit comments

Comments
 (0)