diff --git a/clinica/pipelines/fmri_preprocessing/fmri_preprocessing_pipeline.py b/clinica/pipelines/fmri_preprocessing/fmri_preprocessing_pipeline.py index 89a122c..3f0d653 100644 --- a/clinica/pipelines/fmri_preprocessing/fmri_preprocessing_pipeline.py +++ b/clinica/pipelines/fmri_preprocessing/fmri_preprocessing_pipeline.py @@ -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', diff --git a/clinica/pipelines/fmri_preprocessing/fmri_preprocessing_utils.py b/clinica/pipelines/fmri_preprocessing/fmri_preprocessing_utils.py index 5a87635..65600e3 100644 --- a/clinica/pipelines/fmri_preprocessing/fmri_preprocessing_utils.py +++ b/clinica/pipelines/fmri_preprocessing/fmri_preprocessing_utils.py @@ -1,7 +1,7 @@ """ -""" +""" 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), diff --git a/clinica/pipelines/pet_volume/pet_volume_pipeline.py b/clinica/pipelines/pet_volume/pet_volume_pipeline.py index cb1a970..88ce0f3 100644 --- a/clinica/pipelines/pet_volume/pet_volume_pipeline.py +++ b/clinica/pipelines/pet_volume/pet_volume_pipeline.py @@ -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'], diff --git a/clinica/pipelines/t1_volume_create_dartel/t1_volume_create_dartel_pipeline.py b/clinica/pipelines/t1_volume_create_dartel/t1_volume_create_dartel_pipeline.py index 3593a3c..46aee0f 100644 --- a/clinica/pipelines/t1_volume_create_dartel/t1_volume_create_dartel_pipeline.py +++ b/clinica/pipelines/t1_volume_create_dartel/t1_volume_create_dartel_pipeline.py @@ -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'], diff --git a/clinica/pipelines/t1_volume_dartel2mni/t1_volume_dartel2mni_pipeline.py b/clinica/pipelines/t1_volume_dartel2mni/t1_volume_dartel2mni_pipeline.py index 166191f..1641fd6 100644 --- a/clinica/pipelines/t1_volume_dartel2mni/t1_volume_dartel2mni_pipeline.py +++ b/clinica/pipelines/t1_volume_dartel2mni/t1_volume_dartel2mni_pipeline.py @@ -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'], diff --git a/clinica/pipelines/t1_volume_existing_template/t1_volume_existing_template_utils.py b/clinica/pipelines/t1_volume_existing_template/t1_volume_existing_template_utils.py index 7b02c67..8b184ce 100644 --- a/clinica/pipelines/t1_volume_existing_template/t1_volume_existing_template_utils.py +++ b/clinica/pipelines/t1_volume_existing_template/t1_volume_existing_template_utils.py @@ -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", diff --git a/clinica/pipelines/t1_volume_new_template/t1_volume_new_template_pipeline.py b/clinica/pipelines/t1_volume_new_template/t1_volume_new_template_pipeline.py index 6f8d556..48c29c1 100644 --- a/clinica/pipelines/t1_volume_new_template/t1_volume_new_template_pipeline.py +++ b/clinica/pipelines/t1_volume_new_template/t1_volume_new_template_pipeline.py @@ -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'], diff --git a/clinica/pipelines/t1_volume_tissue_segmentation/t1_volume_tissue_segmentation_pipeline.py b/clinica/pipelines/t1_volume_tissue_segmentation/t1_volume_tissue_segmentation_pipeline.py index ac1c7fa..3e8b14c 100644 --- a/clinica/pipelines/t1_volume_tissue_segmentation/t1_volume_tissue_segmentation_pipeline.py +++ b/clinica/pipelines/t1_volume_tissue_segmentation/t1_volume_tissue_segmentation_pipeline.py @@ -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'],