cmp.pipelines.diffusion.diffusion module

Diffusion pipeline Class definition.

class cmp.pipelines.diffusion.diffusion.DiffusionPipeline(project_info)[source]

Bases: cmp.pipelines.common.Pipeline

Class that extends a Pipeline and represents the processing pipeline for diffusion MRI.

It is composed of the preprocessing stage that preprocesses dMRI, the registration stage that co-registers T1w to the diffusion B0 and projects the parcellations to the native diffusion space, the diffusion stage that estimates tensors or fiber orientation distributions functions from the diffusion signal and reconstructs fiber using tractography, and finally the connectome stage that combines the output tractogram with the parcellations to create the structural connectivity matrices.

check_config()[source]

Check if the list output formats in the configuration of the connectome stage is not empty.

Returns

message – String that is empty if success, otherwise it contains the error message

Return type

string

check_input(layout, gui=True)[source]

Check if input of the diffusion pipeline are available.

Parameters
  • layout (bids.BIDSLayout) – Instance of BIDSLayout

  • gui (traits.Bool) – Boolean used to display different messages but not really meaningful anymore since the GUI components have been migrated to cmp.bidsappmanager

Returns

valid_inputs – True if inputs are available

Return type

traits.Bool

create_datagrabber_node(base_directory, bids_atlas_label)[source]

Create the appropriate Nipype DataGrabber node depending on the parcellation_scheme

Parameters
  • base_directory (Directory) – Main CMP output directory of a subject e.g. /output_dir/cmp/sub-XX/(ses-YY)

  • bids_atlas_label (string) – Parcellation atlas label

Returns

datasource – Output Nipype Node with DataGrabber interface

Return type

Output Nipype DataGrabber Node

create_datasinker_node(base_directory, bids_atlas_label, recon_model, tracking_model)[source]

Create the appropriate Nipype DataSink node depending on the parcellation_scheme

Parameters
  • base_directory (Directory) – Main CMP output directory of a subject e.g. /output_dir/cmp/sub-XX/(ses-YY)

  • bids_atlas_label (string) – Parcellation atlas label

  • recon_model (string) – Diffusion signal model (DTI or CSD)

  • tracking_model (string) – Tractography algorithm (DET or PROB)

Returns

sinker – Output Nipype Node with DataSink interface

Return type

Output Nipype DataSink Node

create_field_template_dict(bids_atlas_label)[source]

Create the dictionary of input field template given to Nipype DataGrabber`

Parameters

bids_atlas_label (string) – Parcellation atlas label

Returns

field_template – Output dictionary of template input formats given to Nipype DataGrabber

Return type

dict

create_pipeline_flow(cmp_deriv_subject_directory, nipype_deriv_subject_directory)[source]

Create the pipeline workflow.

Parameters
  • cmp_deriv_subject_directory (Directory) – Main CMP output directory of a subject e.g. /output_dir/cmp/sub-XX/(ses-YY)

  • nipype_deriv_subject_directory (Directory) – Intermediate Nipype output directory of a subject e.g. /output_dir/nipype/sub-XX/(ses-YY)

Returns

diffusion_flow – An instance of nipype.pipeline.engine.Workflow

Return type

nipype.pipeline.engine.Workflow

define_custom_mapping(custom_last_stage)[source]

Define the pipeline to be executed until a specific stages.

Not used yet by CMP3.

Parameters

custom_last_stage (string) – Last stage to execute. Valid values are: “Preprocessing”, “Registration”, “Diffusion” and “Connectome”.

get_file(layout, subject, suffix, extension, session=None)[source]

Query files with PyBIDS and take the first file in the returned list or get a specific dmri file if BIDS acq- keyword is used in filename.

Parameters
  • layout (Instance(BIDSLayout)) – Instance of pybids BIDSLayout

  • subject (str) – BIDS subject/participant label i.e. XX in sub-XX

  • suffix (str) – BIDS file suffix i.e. “T1w”, “dwi”, …

  • extension (str) – File extension i.e. “.nii.gz”, “.json”, “.bval”, …

  • session (str) – BIDS session label i.e. YY in ses-YY if the dataset has multiple sessions

Returns

out_file – The output filepath or None if no file was found

Return type

str

global_conf = <cmp.pipelines.diffusion.diffusion.GlobalConfig object>
init_subject_derivatives_dirs()[source]

Return the paths to Nipype and CMP derivatives folders of a given subject / session.

Notes

self.subject is updated to “sub-<participant_label>_ses-<session_label>” when subject has multiple sessions.

input_folders = ['anat', 'dwi']
now = '20220615_1018'
ordered_stage_list = ['Preprocessing', 'Registration', 'Diffusion', 'Connectome']
process()[source]

Executes the diffusion pipeline workflow and returns True if successful.

update_outputs_recon(new)[source]

Update list of of outputs of the diffusion stage when recon_processing_tool is updated.

Parameters

new (string) – New value.

update_outputs_tracking(new)[source]

Update list of of outputs of the diffusion stage when tracking_processing_tool is updated.

Parameters

new (string) – New value.

update_preprocessing_act(new)[source]

Update self.stages["Preprocessing"].config.act_tracking when use_act is updated.

Parameters

new (string) – New value.

update_preprocessing_gmwmi(new)[source]

Update self.stages["Preprocessing"].config.gmwmi_seeding when seed_from_gmwmi is updated.

Parameters

new (string) – New value.

update_tracking_tool(new)[source]

Update self.stages["Preprocessing"].config.tracking_tool when tracking_processing_tool is updated.

Parameters

new (string) – New value.

update_vizualization_layout(new)[source]

Update list of of outputs of the connectome stage when circular_layout is updated.

Parameters

new (string) – New value.

update_vizualization_logscale(new)[source]

Update list of of outputs of the connectome stage when log_visualization is updated.

Parameters

new (bool) – New value.

class cmp.pipelines.diffusion.diffusion.GlobalConfig[source]

Bases: traits.has_traits.HasTraits

Global pipeline configurations.

process_type

Processing pipeline type

Type

‘fMRI’

subjects

List of subjects ID (in the form sub-XX)

Type

traits.List

subject

Subject to be processed (in the form sub-XX)

Type

traits.Str

subject_session

Subject session to be processed (in the form ses-YY)

Type

traits.Str

modalities

List of available diffusion modalities red from the acq-<modality> filename keyword

Type

traits.List

dmri_bids_acq

Diffusion modality to be processed

Type

traits.Str