cmp.stages.segmentation.segmentation module

Definition of config and stage classes for segmentation.

class cmp.stages.segmentation.segmentation.SegmentationConfig[source]

Bases: traits.has_traits.HasTraits

Class used to store configuration parameters of a SegmentationStage object.

seg_tool

Choice of segmentation tool that can be “Freesurfer”

Type

traits.Enum([“Freesurfer”])

make_isotropic

Resample to isotropic resolution (Default: False)

Type

traits.Bool

isotropic_vox_size

Isotropic resolution to be resampled (Default: 1.2, desc=’’)

Type

traits.Float

isotropic_interpolation

Interpolation type used for resampling that can be: ‘cubic’, ‘weighted’, ‘nearest’, ‘sinc’, or ‘interpolate’, (Default: ‘cubic’)

Type

traits.Enum

brain_mask_extraction_tool

Choice of brain extraction tool: “Freesurfer”, “BET”, or “ANTs” (Default: Freesurfer)

Type

traits.Enum

ants_templatefile

Anatomical template used by ANTS brain extraction

Type

traits.File

ants_probmaskfile

Brain probability mask used by ANTS brain extraction

Type

traits.File

ants_regmaskfile

Mask (defined in the template space) used during registration in ANTs brain extraction. To limit the metric computation to a specific region.

Type

traits.File

use_fsl_brain_mask

Use FSL BET for brain extraction (Default: False)

Type

traits.Bool

brain_mask_path

Custom brain mask path

Type

traits.File

use_existing_freesurfer_data

(Default: False)

Type

traits.Bool

freesurfer_subjects_dir

Freesurfer subjects directory path usually /output_dir/freesurfer

Type

traits.Str

freesurfer_subject_id_trait

Freesurfer subject (being processed) directory path usually /output_dir/freesurfer/sub-XX(_ses-YY)

Type

traits.List

freesurfer_subject_id

Freesurfer subject (being processed) ID in the form sub-XX(_ses-YY)

Type

traits.Str

freesurfer_args

Extra Freesurfer recon-all arguments

Type

traits.Str

white_matter_mask

Custom white-matter mask

Type

traits.File

number_of_threads

Number of threads leveraged by OpenMP and used in the stage by Freesurfer and ANTs (Default: 1)

Type

traits.Int

class cmp.stages.segmentation.segmentation.SegmentationStage(bids_dir, output_dir)[source]

Bases: cmp.stages.common.Stage

Class that represents the segmentation stage of a AnatomicalPipeline.

create_workflow()[source]

Create the workflow of the SegmentationStage

create_workflow(flow, inputnode, outputnode)[source]

Create the stage worflow.

Parameters
  • flow (nipype.pipeline.engine.Workflow) – The nipype.pipeline.engine.Workflow instance of the anatomical pipeline

  • inputnode (nipype.interfaces.utility.IdentityInterface) – Identity interface describing the inputs of the stage

  • outputnode (nipype.interfaces.utility.IdentityInterface) – Identity interface describing the outputs of the stage

define_inspect_outputs()[source]

Update the `inspect_outputs’ class attribute.

It contains a dictionary of stage outputs with corresponding commands for visual inspection.

has_run()[source]

Function that returns True if the stage has been run successfully.

Returns

Return type

True if the stage has been run successfully

cmp.stages.segmentation.segmentation.extract_base_directory(file)[source]

Extract Recon-all base directory from a file.

Parameters

file (File) – File generated by Recon-all

Returns

out_path – Recon-all base directory

Return type

string