Skip to content

Commit d9a52d0

Browse files
committed
Merge pull request #945 from chrisfilo/fix/spm12
Fix/spm12
2 parents 4d855cb + 7bf9d11 commit d9a52d0

File tree

4 files changed

+27
-13
lines changed

4 files changed

+27
-13
lines changed

examples/fmri_spm.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import os # system functions
1919

2020
from nipype import config
21-
config.enable_provenance()
21+
#config.enable_provenance()
2222

2323
from nipype.interfaces import spm, fsl
2424

@@ -349,7 +349,8 @@ def getstripdir(subject_id):
349349
# collect all the con images for each contrast.
350350
contrast_ids = range(1,len(contrasts)+1)
351351
l2source = pe.Node(nio.DataGrabber(infields=['fwhm', 'con']), name="l2source")
352-
l2source.inputs.template=os.path.abspath('spm_tutorial/l1output/*/con*/*/_fwhm_%d/con_%04d.img')
352+
# we use .*i* to capture both .img (SPM8) and .nii (SPM12)
353+
l2source.inputs.template=os.path.abspath('spm_tutorial/l1output/*/con*/*/_fwhm_%d/con_%04d.*i*')
353354
# iterate over all contrast images
354355
l2source.iterables = [('fwhm',fwhmlist),
355356
('con',contrast_ids)]

examples/fmri_spm_dartel.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@ def getstripdir(subject_id):
481481
# collect all the con images for each contrast.
482482
contrast_ids = range(1,len(contrasts)+1)
483483
l2source = pe.Node(nio.DataGrabber(infields=['fwhm', 'con']), name="l2source")
484-
l2source.inputs.template=os.path.abspath('spm_dartel_tutorial/l1output/*/con*/*/_fwhm_%d/con_%04d.img')
484+
# we use .*i* to capture both .img (SPM8) and .nii (SPM12)
485+
l2source.inputs.template=os.path.abspath('spm_dartel_tutorial/l1output/*/con*/*/_fwhm_%d/con_%04d.*i*')
485486
# iterate over all contrast images
486487
l2source.iterables = [('fwhm',fwhmlist),
487488
('con',contrast_ids)]

examples/fmri_spm_nested.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def getstripdir(subject_id):
419419
"""
420420

421421
if __name__ == '__main__':
422-
level1.run()
422+
level1.run('MultiProc')
423423
level1.write_graph()
424424

425425
"""
@@ -435,7 +435,8 @@ def getstripdir(subject_id):
435435
# collect all the con images for each contrast.
436436
contrast_ids = range(1,len(contrasts)+1)
437437
l2source = pe.Node(nio.DataGrabber(infields=['fwhm', 'con']), name="l2source")
438-
l2source.inputs.template=os.path.abspath('spm_tutorial2/l1output/*/con*/*/_fwhm_%d/con_%04d.img')
438+
# we use .*i* to capture both .img (SPM8) and .nii (SPM12)
439+
l2source.inputs.template=os.path.abspath('spm_tutorial2/l1output/*/con*/*/_fwhm_%d/con_%04d.*i*')
439440
# iterate over all contrast images
440441
l2source.iterables = [('fwhm',fwhmlist),
441442
('con',contrast_ids)]
@@ -477,5 +478,5 @@ def getstripdir(subject_id):
477478
"""
478479

479480
if __name__ == '__main__':
480-
l2pipeline.run()
481+
l2pipeline.run('MultiProc')
481482

nipype/workflows/fmri/spm/preprocess.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,21 +254,32 @@ def create_DARTEL_template(name='dartel_template'):
254254
iterfield=['channel_files'],
255255
name='segment')
256256
workflow.connect(inputnode, 'structural_files', segment, 'channel_files')
257-
if not no_matlab:
258-
version = spm.Info.version()
259-
if version and version['name'] == 'SPM8':
260-
spm_path = version['path']
257+
258+
version = spm.Info.version()
259+
if version:
260+
spm_path = version['path']
261+
if version['name'] == 'SPM8':
261262
tissue1 = ((os.path.join(spm_path,'toolbox/Seg/TPM.nii'), 1), 2, (True,True), (False, False))
262263
tissue2 = ((os.path.join(spm_path,'toolbox/Seg/TPM.nii'), 2), 2, (True,True), (False, False))
263264
tissue3 = ((os.path.join(spm_path,'toolbox/Seg/TPM.nii'), 3), 2, (True,False), (False, False))
264265
tissue4 = ((os.path.join(spm_path,'toolbox/Seg/TPM.nii'), 4), 3, (False,False), (False, False))
265266
tissue5 = ((os.path.join(spm_path,'toolbox/Seg/TPM.nii'), 5), 4, (False,False), (False, False))
266267
tissue6 = ((os.path.join(spm_path,'toolbox/Seg/TPM.nii'), 6), 2, (False,False), (False, False))
267-
segment.inputs.tissues = [tissue1, tissue2, tissue3, tissue4, tissue5, tissue6]
268+
elif version['name'] == 'SPM12':
269+
spm_path = version['path']
270+
tissue1 = ((os.path.join(spm_path,'tpm/TPM.nii'), 1), 1, (True,True), (False, False))
271+
tissue2 = ((os.path.join(spm_path,'tpm/TPM.nii'), 2), 1, (True,True), (False, False))
272+
tissue3 = ((os.path.join(spm_path,'tpm/TPM.nii'), 3), 2, (True,False), (False, False))
273+
tissue4 = ((os.path.join(spm_path,'tpm/TPM.nii'), 4), 3, (False,False), (False, False))
274+
tissue5 = ((os.path.join(spm_path,'tpm/TPM.nii'), 5), 4, (False,False), (False, False))
275+
tissue6 = ((os.path.join(spm_path,'tpm/TPM.nii'), 6), 2, (False,False), (False, False))
268276
else:
269-
logger.critical('SPM8 not found: DARTEL not available')
277+
logger.critical('Unsupported version of SPM')
278+
279+
segment.inputs.tissues = [tissue1, tissue2, tissue3, tissue4, tissue5, tissue6]
270280
else:
271-
logger.critical('MATLAB not found: DARTEL not setting tissue templates')
281+
logger.critical('SPM not found')
282+
272283
dartel = pe.Node(spm.DARTEL(), name='dartel')
273284

274285
"""Get the gray and white segmentation classes generated by NewSegment

0 commit comments

Comments
 (0)