capsul.subprocess module

Inheritance diagram of capsul.subprocess, capsul.subprocess.fsl, capsul.subprocess.spm

The capsul.subprocess module provides interfaces similar to those of the standard subprocess module, specialized to call specific neuroimaging software such as FSL, SPM or FreeSurfer. It provides Popen, call(), check_call() and check_outputs() replacement functions which work in the selected specific environment.

capsul.subprocess.fsl submodule

Specific subprocess-like functions to call FSL taking into account a potential configuration done in StudyConfig. If a StudyConfig is not configured to use FSL, it may be automatically configured. Automatic configuration had been tested in the two following cases:

  • FSL was installed from the FMRIB site and, at least, FSLDIR environment variable is set (fsl.sh can be sourced or not)

  • FSL was installed from Neurodebian packages

For calling FSL command with this module, the first argument of command line must be the FSL executable without any path nor prefix. Prefix areused in Neurodebian install. For instance on Ubuntu 16.04 Neurodebian FSL commands are prefixed with “fsl5.0-“. The appropriate path and eventually prefix are added from the configuration of the StudyConfig instance.

Classes

Popen

Functions

fsl_command_with_environment()

check_fsl_configuration()

check_configuration_values()

auto_configuration()

call()

check_call()

check_output()

class capsul.subprocess.fsl.Popen(study_config, command, **kwargs)[source]

Equivalent to Python subprocess.Popen for FSL commands

Create new Popen instance.

capsul.subprocess.fsl.auto_configuration(study_config)[source]

Try to automatically set the study_config configuration for FSL.

capsul.subprocess.fsl.call(study_config, command, **kwargs)[source]

Equivalent to Python subprocess.call for FSL commands

capsul.subprocess.fsl.check_call(study_config, command, **kwargs)[source]

Equivalent to Python subprocess.check_call for FSL commands

capsul.subprocess.fsl.check_configuration_values(study_config)[source]

Check if the configuration is valid to run FLS and returns an error message if there is an error or None if everything is good.

capsul.subprocess.fsl.check_fsl_configuration(study_config)[source]

Check thas study_config configuration is valid to call FSL commands. If not, try to automatically configure FSL. Finally raises an EnvironmentError if configuration is still wrong.

capsul.subprocess.fsl.check_output(study_config, command, **kwargs)[source]

Equivalent to Python subprocess.check_output for FSL commands

capsul.subprocess.fsl.fsl_command_with_environment(study_config, command)[source]

Given an FSL command where first element is a command name without any path or prefix (e.g. “bet”). Returns the appropriate command to call taking into account the study_config FSL configuration.

capsul.subprocess.spm submodule

Classes

Popen

Functions

find_spm()

check_spm_configuration()

check_configuration_values()

auto_configuration()

spm_command()

call()

check_call()

check_output()

class capsul.subprocess.spm.Popen(study_config, batch_file, **kwargs)[source]

Equivalent to Python soma.subprocess.Popen for SPM batch

Create new Popen instance.

capsul.subprocess.spm.auto_configuration(study_config)[source]

Obsolete.

Try to automatically set the study_config configuration for SPM.

capsul.subprocess.spm.call(study_config, batch_file, **kwargs)[source]

Equivalent to Python soma.subprocess.call for SPM batch

capsul.subprocess.spm.check_call(study_config, batch_file, **kwargs)[source]

Equivalent to Python soma.subprocess.check_call for SPM batch

capsul.subprocess.spm.check_configuration_values(study_config)[source]

Obsolete.

Check if the configuration is valid to run SPM and returns an error message if there is an error or None if everything is good.

capsul.subprocess.spm.check_output(study_config, batch_file, **kwargs)[source]

Equivalent to Python soma.subprocess.check_output for SPM batch

capsul.subprocess.spm.check_spm_configuration(study_config)[source]

Obsolete.

Check thas study_config configuration is valid to call SPM commands. If not, try to automatically configure SPM. Finally raises an EnvironmentError if configuration is still wrong.

capsul.subprocess.spm.find_spm(spm_version='', matlab_exec='matlab', matlab_path=None)[source]

Function to return the root directory of SPM.

Parameters:
  • spm_version (str (default='')) – if given, the version to use when running spm<version> in Matlab.

  • matlab (str (default='matlab')) – if given, is the path to the Matlab executable.

  • matlab_path (str (default None)) – if given, is a Matlab expression fed to addpath.

Returns:

last_line – the SPM root directory

Return type:

str