Commit fde9a5e7 by Mauricio Diaz

Merge branch 'noMatlabDep'. Adds options to run pipelines using SPM

standalone.
parents 579ba2d4 2d1fee5c
Pipeline #1482 passed with stages
in 1 minute 47 seconds
......@@ -275,7 +275,7 @@ class fMRIPreprocessing(cpe.Pipeline):
import nipype.interfaces.spm as spm
import nipype.pipeline.engine as npe
from clinica.utils.io import zip_nii, unzip_nii
# Zipping
# =======
unzip_node = npe.MapNode(name='Unzipping',
......
"""
"""
"""
from __future__ import print_function, division, unicode_literals, absolute_import
from nipype.utils.filemanip import (fname_presuffix, filename_to_list, list_to_filename)
......@@ -11,6 +11,15 @@ import nipype.pipeline.engine as npe
import nipype.interfaces.spm as spm
import nipype.interfaces.fsl as fsl
import os
if 'SPMSTANDALONE_HOME' in os.environ:
if 'MCR_HOME' in os.environ:
matlab_cmd = os.path.join(os.environ['SPMSTANDALONE_HOME'],
'/run_spm12.sh') \
+ ' ' + os.environ['MCR_HOME'] \
+ ' script'
spm.SPMCommand.set_mlab_paths(matlab_cmd=matlab_cmd, use_mcr=True)
class RealignUnwarpInputSpec(SPMCommandInputSpec):
scans = traits.Either(traits.List(File(exists=True)), File(exists=True),
......
......@@ -357,6 +357,18 @@ class PETVolume(cpe.Pipeline):
from clinica.utils.io import unzip_nii
import clinica.pipelines.pet_volume.pet_volume_utils as utils
import os
if 'SPMSTANDALONE_HOME' in os.environ:
if 'MCR_HOME' in os.environ:
matlab_cmd = os.path.join(os.environ['SPMSTANDALONE_HOME'],
'/run_spm12.sh') \
+ ' ' + os.environ['MCR_HOME'] \
+ ' script'
spm.SPMCommand.set_mlab_paths(matlab_cmd=matlab_cmd, use_mcr=True)
# Unzipping
# =========
unzip_pet_image = npe.Node(nutil.Function(input_names=['in_file'],
......
......@@ -193,17 +193,38 @@ class T1VolumeCreateDartel(cpe.Pipeline):
mlab.MatlabCommand.set_default_matlab_cmd(mlab_home)
mlab.MatlabCommand.set_default_paths(spm_home)
version = spm.Info.version()
if 'SPMSTANDALONE_HOME' in os.environ:
if 'MCR_HOME' in os.environ:
matlab_cmd = os.path.join(os.environ['SPMSTANDALONE_HOME'],
'run_spm12.sh') \
+ ' ' + os.environ['MCR_HOME'] \
+ ' script'
spm.SPMCommand.set_mlab_paths(matlab_cmd=matlab_cmd, use_mcr=True)
version = spm.SPMCommand().version
else:
version = spm.Info.version()
if version:
if version['name'] == 'SPM8':
print 'You are using SPM version 8. The recommended version to use with Clinica is SPM 12. ' \
'Please upgrade your SPM toolbox.'
elif version['name'] != 'SPM12':
raise RuntimeError('SPM version 8 or 12 could not be found. Please upgrade your SPM toolbox.')
if isinstance(version, dict):
spm_path = version['path']
if version['name'] == 'SPM8':
print 'You are using SPM version 8. The recommended version to use with Clinica is SPM 12. ' \
'Please upgrade your SPM toolbox.'
tissue_map = os.path.join(spm_path, 'toolbox/Seg/TPM.nii')
elif version['name'] == 'SPM12':
tissue_map = os.path.join(spm_path, 'tpm/TPM.nii')
else:
raise RuntimeError('SPM version 8 or 12 could not be found. Please upgrade your SPM toolbox.')
if isinstance(version, unicode):
if version == '12.7169':
tissue_map = os.path.join(unicode(spm_home), 'spm12_mcr/spm/spm12/tpm/TPM.nii')
else:
raise RuntimeError('SPM standalone version not supported. Please upgrade SPM standalone.')
else:
raise RuntimeError('SPM could not be found. Please verify your SPM_HOME environment variable.')
# Unzipping
# =========
unzip_node = npe.MapNode(nutil.Function(input_names=['in_file'],
......
......@@ -241,17 +241,38 @@ class T1VolumeDartel2MNI(cpe.Pipeline):
mlab.MatlabCommand.set_default_matlab_cmd(mlab_home)
mlab.MatlabCommand.set_default_paths(spm_home)
version = spm.Info.version()
if 'SPMSTANDALONE_HOME' in os.environ:
if 'MCR_HOME' in os.environ:
matlab_cmd = os.path.join(os.environ['SPMSTANDALONE_HOME'],
'run_spm12.sh') \
+ ' ' + os.environ['MCR_HOME'] \
+ ' script'
spm.SPMCommand.set_mlab_paths(matlab_cmd=matlab_cmd, use_mcr=True)
version = spm.SPMCommand().version
else:
version = spm.Info.version()
if version:
if version['name'] == 'SPM8':
print 'You are using SPM version 8. The recommended version to use with Clinica is SPM 12. ' \
'Please upgrade your SPM toolbox.'
elif version['name'] != 'SPM12':
raise RuntimeError('SPM version 8 or 12 could not be found. Please upgrade your SPM toolbox.')
if isinstance(version, dict):
spm_path = version['path']
if version['name'] == 'SPM8':
print 'You are using SPM version 8. The recommended version to use with Clinica is SPM 12. ' \
'Please upgrade your SPM toolbox.'
tissue_map = os.path.join(spm_path, 'toolbox/Seg/TPM.nii')
elif version['name'] == 'SPM12':
tissue_map = os.path.join(spm_path, 'tpm/TPM.nii')
else:
raise RuntimeError('SPM version 8 or 12 could not be found. Please upgrade your SPM toolbox.')
if isinstance(version, unicode):
if version == '12.7169':
tissue_map = os.path.join(unicode(spm_home), 'spm12_mcr/spm/spm12/tpm/TPM.nii')
else:
raise RuntimeError('SPM standalone version not supported. Please upgrade SPM standalone.')
else:
raise RuntimeError('SPM could not be found. Please verify your SPM_HOME environment variable.')
# Unzipping
# =========
unzip_tissues_node = npe.MapNode(nutil.Function(input_names=['in_file'],
......
......@@ -21,6 +21,14 @@ __email__ = "jorge.samper-gonzalez@inria.fr"
__status__ = "Development"
if 'SPMSTANDALONE_HOME' in os.environ:
if 'MCR_HOME' in os.environ:
matlab_cmd = os.environ['SPMSTANDALONE_HOME'] \
+ '/run_spm12.sh ' \
+ os.environ['MCR_HOME'] \
+ ' script'
SPMCommand.set_mlab_paths(matlab_cmd=matlab_cmd, use_mcr=True)
class DARTELExistingTemplateInputSpec(SPMCommandInputSpec):
image_files = traits.List(traits.List(File(exists=True)),
desc="A list of files to be segmented",
......
......@@ -321,22 +321,37 @@ class T1VolumeNewTemplate(cpe.Pipeline):
mlab.MatlabCommand.set_default_matlab_cmd(mlab_home)
mlab.MatlabCommand.set_default_paths(spm_home)
version = spm.Info.version()
#TODO: remove check for SPM
if 'SPMSTANDALONE_HOME' in os.environ:
if 'MCR_HOME' in os.environ:
matlab_cmd = os.path.join(os.environ['SPMSTANDALONE_HOME'],
'run_spm12.sh') \
+ ' ' + os.environ['MCR_HOME'] \
+ ' script'
spm.SPMCommand.set_mlab_paths(matlab_cmd=matlab_cmd, use_mcr=True)
version = spm.SPMCommand().version
else:
version = spm.Info.version()
if version:
spm_path = version['path']
if version['name'] == 'SPM8':
print 'You are using SPM version 8. The recommended version to use with Clinica is SPM 12. ' \
'Please upgrade your SPM toolbox.'
tissue_map = op.join(spm_path, 'toolbox/Seg/TPM.nii')
elif version['name'] == 'SPM12':
tissue_map = op.join(spm_path, 'tpm/TPM.nii')
else:
raise RuntimeError('SPM version 8 or 12 could not be found. Please upgrade your SPM toolbox.')
if isinstance(version, dict):
spm_path = version['path']
if version['name'] == 'SPM8':
print 'You are using SPM version 8. The recommended version to use with Clinica is SPM 12. ' \
'Please upgrade your SPM toolbox.'
tissue_map = os.path.join(spm_path, 'toolbox/Seg/TPM.nii')
elif version['name'] == 'SPM12':
tissue_map = os.path.join(spm_path, 'tpm/TPM.nii')
else:
raise RuntimeError('SPM version 8 or 12 could not be found. Please upgrade your SPM toolbox.')
if isinstance(version, unicode):
if version == '12.7169':
tissue_map = os.path.join(unicode(spm_home), 'spm12_mcr/spm/spm12/tpm/TPM.nii')
else:
raise RuntimeError('SPM standalone version not supported. Please upgrade SPM standalone.')
else:
raise RuntimeError('SPM could not be found. Please verify your SPM_HOME environment variable.')
# Unzipping
# ===============================
unzip_node = npe.MapNode(nutil.Function(input_names=['in_file'],
......
......@@ -201,21 +201,36 @@ class T1VolumeTissueSegmentation(cpe.Pipeline):
mlab.MatlabCommand.set_default_matlab_cmd(mlab_home)
mlab.MatlabCommand.set_default_paths(spm_home)
version = spm.Info.version()
if 'SPMSTANDALONE_HOME' in os.environ:
if 'MCR_HOME' in os.environ:
matlab_cmd = os.path.join(os.environ['SPMSTANDALONE_HOME'],
'run_spm12.sh') \
+ ' ' + os.environ['MCR_HOME'] \
+ ' script'
spm.SPMCommand.set_mlab_paths(matlab_cmd=matlab_cmd, use_mcr=True)
version = spm.SPMCommand().version
else:
version = spm.Info.version()
if version:
spm_path = version['path']
if version['name'] == 'SPM8':
print 'You are using SPM version 8. The recommended version to use with Clinica is SPM 12. ' \
'Please upgrade your SPM toolbox.'
tissue_map = op.join(spm_path, 'toolbox/Seg/TPM.nii')
elif version['name'] == 'SPM12':
tissue_map = op.join(spm_path, 'tpm/TPM.nii')
else:
raise RuntimeError('SPM version 8 or 12 could not be found. Please upgrade your SPM toolbox.')
if isinstance(version, dict):
spm_path = version['path']
if version['name'] == 'SPM8':
print 'You are using SPM version 8. The recommended version to use with Clinica is SPM 12. ' \
'Please upgrade your SPM toolbox.'
tissue_map = os.path.join(spm_path, 'toolbox/Seg/TPM.nii')
elif version['name'] == 'SPM12':
tissue_map = os.path.join(spm_path, 'tpm/TPM.nii')
else:
raise RuntimeError('SPM version 8 or 12 could not be found. Please upgrade your SPM toolbox.')
if isinstance(version, unicode):
if version == '12.7169':
tissue_map = os.path.join(unicode(spm_home), 'spm12_mcr/spm/spm12/tpm/TPM.nii')
else:
raise RuntimeError('SPM standalone version not supported. Please upgrade SPM standalone.')
else:
raise RuntimeError('SPM could not be found. Please verify your SPM_HOME environment variable.')
# Unzipping
# ===============================
unzip_node = npe.MapNode(nutil.Function(input_names=['in_file'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment