Segmentation Workflow

CPAC.seg_preproc.create_seg_preproc(use_ants, wf_name='seg_preproc')[source]

Segment the subject’s snatomical brain into cerebral spinal fluids, white matter and gray matter. Threshold and binarize them.

wf_name : string
name of the workflow

seg_preproc : workflow

Workflow Object for Segmentation Workflow

Source

Workflow Inputs:

csf_threshold.csf_threshold : list (float)
    Threshold of Cerebral Spinal Fluid probabilities 

wm_threshold.wm_threshold : list (float) 
    Threshold of White Matter probabilities

gm_threshold.gm_threshold : list (float) 
    Threshold of Gray Matter probabilities

inputspec.brain : string (existing nifti file)
    Anatomical image(without skull)

inputspec.standard2highres_mat : string (existing affine transformation .mat file)
    File for transformation from mni space to anatomical space

inputspec.PRIOR_CSF : string (existing nifti file)
    FSL Standard CSF Tissue prior image , binarized with threshold of 0.4 

inputspec.PRIOR_GRAY : string (existing nifti file)
    FSL Standard GRAY Matter Tissue prior image , binarized with threshold of 0.66

inputspec.PRIOR_WHITE : string (existing nifti file)
    FSL Standard White Matter Tissue prior image , binarized with threshold of 0.2

Workflow Outputs:

outputspec.csf_mni2t1 : string (nifti file)
    outputs CSF prior template(in MNI space) registered to anatomical space

outputspec.csf_combo : string (nifti file)
    outputs Image containing overlap between csf probability map and 
    csf tissue prior in t1 native space

outputspec.csf_bin : string (nifti file)
    outputs image after Thresholding and binarizing csf_combo

outputspec.csf_mask : string (nifti file)
    outputs image after masking csf_combo with csf prior in t1 space

outputspec.gm_mni2t1 : string (nifti file)
    outputs gray matter prior template registered to anatomical space

outputspec.gm_combo : string (nifti file)
    outputs image containing overlap between gray matter probability map 
    and gm tissue prior in t1 native space

outputspec.gm_bin : string (nifti file)
    outputs image after thresholding and binarizing gm_combo

outputspec.gm_mask : string (nifti file)
    outputs image after masking gm_combo with gm prior in t1 space

outputspec.wm_mni2t1 : string (nifti file)
    outputs White Matter prior template(in MNI space) registered to anatomical space

outputspec.wm_combo : string (nifti file)
    outputs image containing overlap between white matter(wm) probability map 
    and wm tissue prior in t1 native space
    
outputspec.wm_bin : string (nifti file)
    outputs image after Thresholding and binarizing wm_combo

outputspec.wm_mask : string (nifti file)
    outputs image after masking wm_combo with white matter(wm) prior in t1 space

outputspec.probability_maps : string (nifti file)
    outputs individual probability maps (output from brain segmentation using FAST)

outputspec.mixeltype : string (nifti file)
    outputs mixeltype volume file _mixeltype (output from brain segmentation using FAST)

outputspec.partial_volume_map : string (nifti file)
    outputs partial volume file _pveseg (output from brain segmentation using FAST)

outputspec.partial_volume_files : string (nifti file)
    outputs partial volume estimate files _pve_ (output from brain segmentation using FAST)

Order of commands:

  • Segment the Anatomical brain. For details see fast:

    fast
    -t 1
    -g
    -p
    -o segment
    mprage_brain.nii.gz
    
  • Register CSF template in MNI space to t1 space. For details see flirt:

    flirt
    -in PRIOR_CSF
    -ref mprage_brain.nii.gz
    -applyxfm
    -init standard2highres_inv.mat
    -out csf_mni2t1
    
  • Find overlap between csf probability map and csf_mni2t1. For details see `fslmaths <http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/Fslutils>_:

    fslmaths
    segment_prob_0.nii.gz
    -mas csf_mni2t1.nii.gz
    csf_combo.nii.gz
    
  • Threshold and binarize CSF probability map

    fslmaths
    csf_combo.nii.gz
    -thr 0.4
    -bin csf_bin.nii.gz
    
  • Generate CSF csf_mask, by applying csf prior in t1 space to thresholded binarized csf probability map

    fslmaths
    csf_bin.nii.gz
    -mas csf_mni2t1
    csf_mask
    
  • Register WM template in MNI space to t1 space

    flirt
    -in PRIOR_WM
    -ref mprage_brain.nii.gz
    -applyxfm
    -init standard2highres.mat
    -out wm_mni2t1
    
  • Find overlap between wm probability mask and wm_mni2t1

    fslmaths
    segment_prob_2.nii.gz
    -mas wm_mni2t1.nii.gz
    wm_combo.nii.gz
    
  • Threshold and binarize WM probability map

    fslmaths
    wm_combo.nii.gz
    -thr 0.4
    -bin wm_bin.nii.gz
    
  • Generate WM csf_mask, by applying wm_prior in t1 space to thresholded binarized wm probability map

    fslmaths
    wm_bin.nii.gz
    -mas wm_mni2t1
    wm_mask
    
  • Register GM template in MNI space to t1 space

    flirt
    -in PRIOR_GM
    -ref mprage_brain.nii.gz
    -applyxfm
    -init standard2highres.mat
    -out gm_mni2t1
    
  • Find overlap between gm probability map and gm_mni2t1

    fslmaths
    segment_prob_1.nii.gz
    -mas gm_mni2t1.nii.gz
    gm_combo.nii.gz
    
  • Threshold and binarize GM probability map

    fslmaths
    gm_combo.nii.gz
    -thr 0.4
    -bin gm_bin.nii.gz
    
  • Generate GM csf_mask, by applying gm prior in t1 space to thresholded binarized gm probability map

    fslmaths
    gm_bin.nii.gz
    -mas gm_mni2t1
    gm_mask
    
>>> import CPAC.seg_preproc as seg_wflow
>>> seg = seg_wflow.create_seg_preproc()
>>> seg.inputs.inputspec.standard2highres_mat = '/home/data/Projects/C-PAC/working_directory/s1001/reg_preproc/standard2highres.mat'
>>> seg.inputs.inputspec.PRIOR_CSF = '/home/data/Projects/C-PAC/tissuepriors/2mm/avg152T1_csf_bin.nii.gz'
>>> seg.inputs.inputspec.PRIOR_WHITE = '/home/data/Projects/C-PAC/tissuepriors/2mm/avg152T1_white_bin.nii.gz'
>>> seg.inputs.inputspec.PRIOR_GRAY = '/home/data/Projects/C-PAC/tissuepriors/2mm/avg152T1_gray_bin.nii.gz'
>>> seg.inputs.inputspec.brain = '/home/data/Projects/C-PAC/working_directory/s1001/anat_preproc/mprage_brain.nii.gz'
>>> seg.inputs.csf_threshold.csf_threshold = 0.4
>>> seg.inputs.wm_threshold.wm_threshold = 0.66
>>> seg.inputs.gm_threshold.gm_threshold = 0.2
>>> seg_preproc.run() 

High Level Graph:

workflows/../images/seg_preproc.dot.png

Detailed Graph:

workflows/../images/seg_preproc_detailed.dot.png
CPAC.seg_preproc.process_segment_map(wf_name, use_ants)[source]

This is a sub workflow used inside segmentation workflow to process probability maps obtained in segmententation. Steps include overlapping of the prior tissue with probability maps, thresholding and binarizing it and creating a mask thst is used in further analysis.

wf_name : string
Workflow Name
preproc : workflow
Workflow Object for process_segment_map Workflow

Source

Workflow Inputs:

inputspec.brain : string (existing nifti file)
    Anatomical image(without skull)

inputspec.standard2highres_mat : string (existing affine transformation .mat file)
    path to transformation matrix from mni space to anatomical space

inputspec.tissue_prior : string (existing nifti file)
    path to FSL Standard Tissue prior image 
    
inputspec.threshold : string (float)
    threshold of Segmentation Probaility Maps
    
inputspec.probability_map : string (nifti file)
    tissue Probability map obtained from fsl FAST

Workflow Outputs:

outputspec.segment_mni2t1 : string (nifti file)
    path to output CSF prior template(in MNI space) registered to anatomical space

outputspec.segment_combo : string (nifti file)
    path to output image containing overlap between csf probability map and segment_mni2t1

outputspec.segment_bin : string (nifti file)
    path to output image after Thresholding and binarizing segment_combo

outputspec.segment_mask : string (nifti file)
    path to output image after masking segment_combo with its tissue prior in t1 space

Order of commands:

  • Register tissue prior in MNI space to t1 space.
  • Find overlap between segment probability map and tissue prior in t1 native space.
  • Threshold and binarize segment probability map
  • Generate segment mask, by applying tissue prior in t1 space to thresholded binarized segment probability map

High Level Graph:

workflows/../images/process_segment_map.dot.png

Detailed Graph:

workflows/../images/process_segment_map_detailed.dot.png
CPAC.seg_preproc.pick_wm_0(probability_maps)[source]

Returns the csf probability map from the list of segmented probability maps

probability_maps : list (string)
List of Probability Maps
file : string
Path to segment_prob_0.nii.gz is returned
CPAC.seg_preproc.pick_wm_1(probability_maps)[source]

Returns the gray matter probability map from the list of segmented probability maps

probability_maps : list (string)
List of Probability Maps
file : string
Path to segment_prob_1.nii.gz is returned
CPAC.seg_preproc.pick_wm_2(probability_maps)[source]

Returns the white matter probability map from the list of segmented probability maps

probability_maps : list (string)
List of Probability Maps
file : string
Path to segment_prob_2.nii.gz is returned