Commit fde9a5e7 authored by Mauricio Diaz's avatar Mauricio Diaz

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

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