Pipelines module

Abstract base class for the anatomical pipeline.

class pymialsrtk.pipelines.anatomical.abstract.AbstractAnatomicalPipeline(p_bids_dir, p_output_dir, p_subject, p_ga=None, p_stacks=None, p_sr_id=1, p_session=None, p_masks_derivatives_dir=None, p_masks_desc=None, p_dict_custom_interfaces=None, p_verbose=None, p_openmp_number_of_cores=None, p_nipype_number_of_cores=None, p_run_type=None)[source]

Bases: object

Class used to represent the workflow of the anatomical pipeline.

Attributes
  • m_bids_dir (string) – BIDS root directory (required)

  • m_output_dir (string) – Output derivatives directory (required)

  • m_subject (string) – Subject ID (in the form sub-XX)

  • m_wf (nipype.pipeline.Workflow) – Nipype workflow of the reconstruction pipeline

  • m_sr_id (string) – ID of the reconstruction useful to distinguish when multiple reconstructions with different order of stacks are run on the same subject

  • m_session (string) – Session ID if applicable (in the form ses-YY)

  • m_stacks (list(int)) – List of stack to be used in the reconstruction. The specified order is kept if skip_stacks_ordering is True.

  • m_masks_derivatives_dir (string) – directory basename in BIDS directory derivatives where to search for masks (optional)

  • m_do_nlm_denoising (bool) – Whether the NLM denoising preprocessing should be performed prior to motion estimation. (default is False)

  • m_skip_stacks_ordering (bool (optional)) – Whether the automatic stacks ordering should be skipped. (default is False)

Examples

>>> from pymialsrtk.pipelines.anatomical.srr import AnatomicalPipeline
>>> # Create a new instance
>>> pipeline = AnatomicalPipeline(bids_dir='/path/to/bids_dir',
                                  output_dir='/path/to/output_dir',
                                  subject='sub-01',
                                  p_stacks=[1,3,2,0],
                                  sr_id=1,
                                  session=None,
                                  paramTV={deltat_TV = "0.001",
                                           lambda_TV = "0.75",
                                           num_primal_dual_loops = "20"},
                                  masks_derivatives_dir="/custom/mask_dir",
                                  masks_desc=None,
                                  p_dict_custom_interfaces=None)
>>> # Create the super resolution Nipype workflow
>>> pipeline.create_workflow()
>>> # Execute the workflow
>>> res = pipeline.run(number_of_cores=1) 
abstract create_workflow()[source]

Create the Niype workflow of the super-resolution pipeline.

It is composed of a succession of Nodes and their corresponding parameters, where the output of node i goes to the input of node i+1.

The more specific definition given in each node implementing the method.

run(memory=None, logger=None)[source]

Execute the workflow of the super-resolution reconstruction pipeline.

Nipype execution engine will take care of the management and execution of all processing steps involved in the super-resolution reconstruction pipeline. Note that the complete execution graph is saved as a PNG image to support transparency on the whole processing.

Parameters

memory (int) – Maximal memory used by the workflow

Module for the preprocessing pipeline.

class pymialsrtk.pipelines.anatomical.preprocessing.PreprocessingPipeline(p_bids_dir, p_output_dir, p_subject, p_ga=None, p_stacks=None, p_sr_id=1, p_session=None, p_masks_derivatives_dir=None, p_masks_desc=None, p_dict_custom_interfaces=None, p_verbose=None, p_openmp_number_of_cores=None, p_nipype_number_of_cores=None)[source]

Bases: pymialsrtk.pipelines.anatomical.abstract.AbstractAnatomicalPipeline

Class used to represent the workflow of the Preprocessing pipeline.

Attributes
  • m_bids_dir (string) – BIDS root directory (required)

  • m_output_dir (string) – Output derivatives directory (required)

  • m_subject (string) – Subject ID (in the form sub-XX)

  • m_wf (nipype.pipeline.Workflow) – Nipype workflow of the preprocessing pipeline

  • m_sr_id (string) – ID of the preprocessing useful to distinguish when multiple preprocessing with different order of stacks are run on the same subject

  • m_session (string) – Session ID if applicable (in the form ses-YY)

  • m_stacks (list(int)) – List of stack to be used in the preprocessing. The specified order is kept if skip_stacks_ordering is True.

  • m_masks_derivatives_dir (string) – directory basename in BIDS directory derivatives where to search for masks (optional)

  • m_do_nlm_denoising (bool) – Whether the NLM denoising preprocessing should be performed prior to motion estimation. (default is False)

  • m_skip_stacks_ordering (bool (optional)) – Whether the automatic stacks ordering should be skipped. (default is False)

Examples

>>> from pymialsrtk.pipelines.anatomical.srr import PreprocessingPipeline
>>> # Create a new instance
>>> pipeline = PreprocessingPipeline(bids_dir='/path/to/bids_dir',
                                  output_dir='/path/to/output_dir',
                                  subject='sub-01',
                                  p_stacks=[1,3,2,0],
                                  sr_id=1,
                                  session=None,
                                  paramTV={deltatTV = "0.001",
                                           lambdaTV = "0.75",
                                           num_primal_dual_loops = "20"},
                                  masks_derivatives_dir="/custom/mask_dir",
                                  masks_desc=None,
                                  p_dict_custom_interfaces=None)
>>> # Create the super resolution Nipype workflow
>>> pipeline.create_workflow()
>>> # Execute the workflow
>>> res = pipeline.run(number_of_cores=1) 
check_parameters_integrity(p_dict_custom_interfaces)[source]

Check parameters integrity.

This checks whether the custom interfaces dictionary contains only keys that are used in preprocessing, and raises an exception if it doesn’t.

Parameters

p_dict_custom_interfaces (dict) – dictionary of custom inferfaces for a given subject that is to be processed.

create_workflow()[source]

Create the Niype workflow of the super-resolution pipeline.

It is composed of a succession of Nodes and their corresponding parameters, where the output of node i goes to the input of node i+1.

Module for the super-resolution reconstruction pipeline.

class pymialsrtk.pipelines.anatomical.srr.SRReconPipeline(p_bids_dir, p_output_dir, p_subject, p_ga=None, p_stacks=None, p_sr_id=1, p_session=None, p_paramTV=None, p_masks_derivatives_dir=None, p_labels_derivatives_dir=None, p_masks_desc=None, p_dict_custom_interfaces=None, p_verbose=None, p_openmp_number_of_cores=None, p_nipype_number_of_cores=None, p_all_outputs=None)[source]

Bases: pymialsrtk.pipelines.anatomical.abstract.AbstractAnatomicalPipeline

Class used to represent the workflow of the Super-Resolution reconstruction pipeline.

Attributes
  • m_bids_dir (string) – BIDS root directory (required)

  • m_output_dir (string) – Output derivatives directory (required)

  • m_subject (string) – Subject ID (in the form sub-XX)

  • m_wf (nipype.pipeline.Workflow) – Nipype workflow of the reconstruction pipeline

  • m_paramTV (dict) – Dictionary of parameters for the super-resolution reconstruction. Contains: - deltatTV : string

    Super-resolution optimization time-step

    • lambdaTVfloat

      Regularization weight (default is 0.75)

    • num_iterationsstring

      Number of iterations in the primal/dual loops used in the optimization of the total-variation super-resolution algorithm.

    • num_primal_dual_loopsstring

      Number of primal/dual (inner) loops used in the optimization of the total-variation super-resolution algorithm.

    • num_bregman_loopsstring

      Number of Bregman (outer) loops used in the optimization of the total-variation super-resolution algorithm.

    • step_scalestring

      Step scale parameter used in the optimization of the total- variation super-resolution algorithm.

    • gammastring

      Gamma parameter used in the optimization of the total-variation super-resolution algorithm.

  • m_sr_id (string) – ID of the reconstruction useful to distinguish when multiple reconstructions with different order of stacks are run on the same subject

  • m_keep_all_outputs (bool) – Whether intermediate outputs must be issued. (default: False)

  • m_session (string) – Session ID if applicable (in the form ses-YY)

  • m_stacks (list(int)) – List of stack to be used in the reconstruction. The specified order is kept if skip_stacks_ordering is True.

  • m_masks_derivatives_dir (string) – directory basename in BIDS directory derivatives where to search for masks (optional)

  • m_skip_svr (bool) – Whether the Slice-to-Volume Registration should be skipped in the image reconstruction. (default is False)

  • m_do_refine_hr_mask (bool) – Whether a refinement of the HR mask should be performed. (default is False)

  • m_do_nlm_denoising (bool) – Whether the NLM denoising preprocessing should be performed prior to motion estimation. (default is False)

  • m_skip_stacks_ordering (bool (optional)) – Whether the automatic stacks ordering should be skipped. (default is False)

Examples

>>> from pymialsrtk.pipelines.anatomical.srr import SRReconPipeline
>>> # Create a new instance
>>> pipeline = SRReconPipeline(bids_dir='/path/to/bids_dir',
                                  output_dir='/path/to/output_dir',
                                  subject='sub-01',
                                  p_stacks=[1,3,2,0],
                                  sr_id=1,
                                  session=None,
                                  paramTV={deltatTV = "0.001",
                                           lambdaTV = "0.75",
                                           num_primal_dual_loops = "20"},
                                  masks_derivatives_dir="/custom/mask_dir",
                                  masks_desc=None,
                                  p_dict_custom_interfaces=None)
>>> # Create the super resolution Nipype workflow
>>> pipeline.create_workflow()
>>> # Execute the workflow
>>> res = pipeline.run(number_of_cores=1) 
create_workflow()[source]

Create the Niype workflow of the super-resolution pipeline.

It is composed of a succession of Nodes and their corresponding parameters, where the output of node i goes to the input of node i+1.

run(memory=None, logger=None)[source]

Execute the workflow of the super-resolution reconstruction pipeline.

Nipype execution engine will take care of the management and execution of all processing steps involved in the super-resolution reconstruction pipeline. Note that the complete execution graph is saved as a PNG image to support transparency on the whole processing.

Parameters

memory (int) – Maximal memory used by the workflow