Skip to content

Commit 257a234

Browse files
committed
fix: spm12b compatibility
1 parent 8a5a190 commit 257a234

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

CHANGES

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

2324
Release 0.9.2 (January 31, 2014)
2425
============

examples/fmri_spm.py

Lines changed: 7 additions & 4 deletions
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,8 +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
34-
35+
import nipype.interfaces.matlab as mlab
3536
"""
3637
3738
Preliminaries
@@ -50,6 +51,8 @@
5051
# import nipype.interfaces.matlab as mlab # how to run matlab
5152
# mlab.MatlabCommand.set_default_matlab_cmd("matlab -nodesktop -nosplash")
5253

54+
mlab.MatlabCommand.set_default_paths('/software/matlab/spm12b/spm12b_r5918')
55+
5356
"""The nipype tutorial contains data for two subjects. Subject data
5457
is in two subdirectories, ``s1`` and ``s2``. Each subject directory
5558
contains four functional volumes: f3.nii, f5.nii, f7.nii, f10.nii. And
@@ -70,7 +73,7 @@
7073
# Specify the location of the data.
7174
data_dir = os.path.abspath('data')
7275
# Specify the subject directories
73-
subject_list = ['s1', 's3']
76+
subject_list = ['s1'] #, 's3']
7477
# Map field names to individual subject runs.
7578
info = dict(func=[['subject_id', ['f3','f5','f7','f10']]],
7679
struct=[['subject_id','struct']])
@@ -392,4 +395,4 @@ def getstripdir(subject_id):
392395

393396
if __name__ == '__main__':
394397
l1pipeline.run('MultiProc')
395-
l2pipeline.run('MultiProc')
398+
#l2pipeline.run('MultiProc')

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)