Postprocess module
PyMIALSRTK postprocessing functions.
It encompasses a High Resolution mask refinement and an N4 global bias field correction.
BinarizeImage
Bases: nipype.interfaces.base.core.BaseInterface
Runs the MIAL SRTK mask image module.
Example
>>> from pymialsrtk.interfaces.postprocess import BinarizeImage >>> maskImg = MialsrtkMaskImage() >>> maskImg.inputs.input_image = 'input_image.nii.gz'
- Mandatory Inputs
input_image (a pathlike object or string representing a file) – Input image filename to be binarized.
- Outputs
output_srmask (a pathlike object or string representing a file) – Image mask (binarized input).
ConcatenateImageMetrics
Bases: nipype.interfaces.base.core.BaseInterface
Concatenate metrics CSV files with the metrics computed on each labelmap.
Example
>>> from pymialsrtk.interfaces.postprocess import ConcatenateImageMetrics >>> concat_metrics = ConcatenateImageMetrics() >>> concat_metrics.inputs.input_metrics = ['sub-01_acq-haste_run-1_paramset_1_metrics.csv', 'sub-01_acq-haste_run-1_paramset2_metrics.csv'] concat_metrics.inputs.input_metrics_labels = ['sub-01_acq-haste_run-1_paramset_1_metrics_labels.csv', 'sub-01_acq-haste_run-1_paramset2_metrics_labels.csv'] >>> concat_metrics.run()
- Optional Inputs
input_metrics (a list of items which are a pathlike object or string representing a file)
input_metrics_labels (a list of items which are a pathlike object or string representing a file)
- Outputs
output_csv (a pathlike object or string representing a file)
output_csv_labels (a pathlike object or string representing a file)
FilenamesGeneration
Bases: nipype.interfaces.base.core.BaseInterface
Generates final filenames from outputs of super-resolution reconstruction.
Example
>>> from pymialsrtk.interfaces.postprocess import FilenamesGeneration >>> filenamesGen = FilenamesGeneration() >>> filenamesGen.inputs.sub_ses = 'sub-01' >>> filenamesGen.inputs.stacks_order = [3,1,4] >>> filenamesGen.inputs.sr_id = 3 >>> filenamesGen.inputs.use_manual_masks = False >>> filenamesGen.run()
- Mandatory Inputs
multi_parameters (a boolean) – Whether multiple SR were reconstructed.
run_type (a string) – Type of run (preproc or sr).
sr_id (an integer) – Super-Resolution id.
stacks_order (a list of items which are any value) – List of stack run-id that specify the order of the stacks.
sub_ses (a string) – Subject and session BIDS identifier to construct output filename.
use_manual_masks (a boolean) – Whether masks were computed or manually performed.
- Optional Inputs
TV_params (a list of items which are any value) – List iterables TV parameters processed.
- Outputs
substitutions (a list of items which are any value) – Output correspondance between old and new filenames.
- FilenamesGeneration.m_substitutions = []
ImageMetrics
Bases: nipype.interfaces.base.core.BaseInterface
Compute various image metrics on a SR reconstructed image compared to a ground truth.
Example
>>> from pymialsrtk.interfaces.postprocess import ImageMetrics >>> compute_metrics = ImageMetrics() >>> compute_metrics.inputs.input_image = 'sub-01_acq-haste_rec-SR_id-1_T2w.nii.gz' >>> compute_metrics.inputs.input_ref_image = 'sub-01_acq-haste_desc-GT_T2w.nii.gz' >>> compute_metrics.inputs.input_ref_mask = 'sub-01_acq-haste_desc-GT_T2w_mask.nii.gz' >>> compute_metrics.inputs.input_TV_parameters = {'in_loop': '10', 'in_deltat': '0.01', 'in_lambda': '2.5', 'in_bregman_loop': '3', 'in_iter': '50', 'in_step_scale': '1', 'in_gamma': '1', 'in_inner_thresh': '1e-05', 'in_outer_thresh': '1e-06'} >>> concat_metrics.run()
- Mandatory Inputs
input_TV_parameters (a dictionary with keys which are any value and with values which are any value)
input_image (a pathlike object or string representing a file) – Input image filename.
input_ref_image (a pathlike object or string representing a file) – Input reference image filename.
input_ref_mask (a pathlike object or string representing a file) – Input reference mask filename.
- Optional Inputs
input_ref_labelmap (a pathlike object or string representing a file) – Input reference labelmap filename.
mask_input (a boolean) – Whether the image and reference should be masked when computing the metrics. (Nipype default value:
True
)normalize_input (a boolean) – Whether the image and reference should be individually normalized before passing them into the metrics. (Nipype default value:
True
)- Outputs
output_metrics (a pathlike object or string representing a file) – Output CSV.
output_metrics_labels (a pathlike object or string representing a file) – Output per-label CSV.
MergeMajorityVote
Bases: nipype.interfaces.base.core.BaseInterface
Perform majority voting to merge a list of label-wise labelmaps.
Example
>>> from pymialsrtk.interfaces.postprocess import MergeMajorityVote >>> merge_labels = MergeMajorityVote() >>> merge_labels.inputs.input_images = ['sub-01_acq-haste_run-1_labels_1.nii.gz', 'sub-01_acq-haste_run-1_labels_2.nii.gz', 'sub-01_acq-haste_run-1_labels_3.nii.gz'] >>> merge_labels.run()
- Mandatory Inputs
input_images (a list of items which are a pathlike object or string representing a file) – Inputs label-wise labelmaps to be merged.
- Outputs
output_image (a pathlike object or string representing a file) – Output label map.
MialsrtkN4BiasFieldCorrection
Bases: nipype.interfaces.base.core.BaseInterface
Runs the MIAL SRTK slice by slice N4 bias field correction module.
This tools implements the method proposed by Tustison et al. [1]_ slice by slice.
References
- 1
Tustison et al.; Medical Imaging, IEEE Transactions, 2010. (link to paper)
Example
>>> from pymialsrtk.interfaces.postprocess import MialsrtkSliceBySliceN4BiasFieldCorrection >>> N4biasFieldCorr = MialsrtkSliceBySliceN4BiasFieldCorrection() >>> N4biasFieldCorr.inputs.input_image = 'sub-01_acq-haste_run-1_SR.nii.gz' >>> N4biasFieldCorr.inputs.input_mask = 'sub-01_acq-haste_run-1_mask.nii.gz' >>> N4biasFieldCorr.run()
- Mandatory Inputs
input_image (a pathlike object or string representing a file) – Input image filename to be normalized.
- Optional Inputs
input_mask (a pathlike object or string representing a file) – Input mask filename.
out_fld_postfix (a string) – (Nipype default value:
_gbcorrfield
)out_im_postfix (a string) – (Nipype default value:
_gbcorr
)verbose (a boolean) – Enable verbosity.
- Outputs
output_field (a pathlike object or string representing a file) – Output bias field extracted from input image.
output_image (a pathlike object or string representing a file) – Output corrected image.
MialsrtkRefineHRMaskByIntersection
Bases: nipype.interfaces.base.core.BaseInterface
Runs the MIALSRTK mask refinement module.
It uses the Simultaneous Truth And Performance Level Estimate (STAPLE) by Warfield et al. [1]_.
References
- 1
Warfield et al.; Medical Imaging, IEEE Transactions, 2004. (link to paper)
Example
>>> from pymialsrtk.interfaces.postprocess import MialsrtkRefineHRMaskByIntersection >>> refMask = MialsrtkRefineHRMaskByIntersection() >>> refMask.inputs.input_images = ['sub-01_acq-haste_run-1_T2w.nii.gz','sub-01_acq-haste_run-2_T2w.nii.gz'] >>> refMask.inputs.input_masks = ['sub-01_acq-haste_run-1_mask.nii.gz','sub-01_acq-haste_run-2_mask.nii.gz'] >>> refMask.inputs.input_transforms = ['sub-01_acq-haste_run-1_transform.txt','sub-01_acq-haste_run-2_transform.nii.gz'] >>> refMask.inputs.input_sr = 'sr_image.nii.gz' >>> refMask.run()
- Mandatory Inputs
input_sr (a pathlike object or string representing a file) – SR image filename.
- Optional Inputs
in_use_staple (a boolean) – Use STAPLE for voting (default is True). If False, Majority voting is used instead. (Nipype default value:
True
)input_images (a list of items which are a pathlike object or string representing a file) – Image filenames used in SR reconstruction.
input_masks (a list of items which are a pathlike object or string representing a file) – Mask filenames.
input_rad_dilatation (an integer) – Radius of the structuring element (ball). (Nipype default value:
1
)input_transforms (a list of items which are a pathlike object or string representing a file) – Transformation filenames.
out_lrmask_postfix (a string) – Suffix to be added to the Low resolution input_masks. (Nipype default value:
_LRmask
)out_srmask_postfix (a string) – Suffix to be added to the SR reconstruction filename to construct output SR mask filename. (Nipype default value:
_srMask
)verbose (a boolean) – Enable verbosity.
- Outputs
output_lrmasks (a list of items which are a pathlike object or string representing a file) – Output low-resolution reconstruction refined masks.
output_srmask (a pathlike object or string representing a file) – Output super-resolution reconstruction refined mask.
ReportGeneration
Bases: nipype.interfaces.base.core.BaseInterface
Generate a report summarizing the outputs of mialsrtk.
- This comprises:
Details of which parameters were run.
A visualization of the SR-reconstructed image
A visualization of the computational graph.
Example
>>> from pymialsrtk.interfaces.postprocess import ReportGeneration >>> report_gen = ReportGeneration() >>> report_gen.inputs.subject = "sub-01" >>> report_gen.inputs.session = "ses-01" >>> report_gen.inputs.stacks = [2,3,5,1] >>> report_gen.inputs.stacks_order = [5,2,3,1] >>> report_gen.inputs.sr_id = "1" >>> report_gen.inputs.run_type = "sr" >>> report_gen.inputs.output_dir = "report_dir/ >>> report_gen.inputs.run_start_time = "" >>> report_gen.inputs.run_elapsed_time = "" >>> report_gen.inputs.do_refine_hr_mask = True >>> report_gen.inputs.do_nlm_denoising = True >>> report_gen.inputs.skip_stacks_ordering = False >>> report_gen.inputs.skip_svr = False >>> report_gen.inputs.masks_derivatives_dir = "derivatives/masks" >>> report_gen.inputs.do_reconstruct_labels = False >>> report_gen.inputs.do_anat_orientation = True >>> report_gen.inputs.do_srr_assessment = False >>> report_gen.inputs.openmp_number_of_cores = 3 >>> report_gen.inputs.nipype_number_of_cores = 1 >>> report_gen.inputs.input_sr = "outputs/sub-01_ses-01_res-SR_T2w.nii.gz" >>> report_gen.inputs.input_json_path = "outputs/sub-01_ses-01_res-SR_T2w.json" >>> report_gen.run()
- Mandatory Inputs
do_anat_orientation (a boolean)
do_multi_parameters (a boolean)
do_nlm_denoising (a boolean)
do_reconstruct_labels (a boolean)
do_refine_hr_mask (a boolean)
do_srr_assessment (a boolean)
input_json_path (a pathlike object or string representing a file)
input_sr (a pathlike object or string representing a file)
masks_derivatives_dir (a string)
nipype_number_of_cores (an integer)
openmp_number_of_cores (an integer)
output_dir (a string)
run_elapsed_time (a float)
run_start_time (a float)
run_type (a string) – Type of run (preproc or sr).
session (a string) – Session BIDS identifier to construct output filename.
skip_stacks_ordering (a boolean)
skip_svr (a boolean)
sr_id (an integer) – Super-Resolution id.
stacks (a list of items which are any value) – List of stack run-id that specify the order of the stacks.
stacks_order (a list of items which are any value) – List of stack run-id that specify the order of the stacks.
subject (a string) – Subject BIDS identifier to construct output filename.
- Optional Inputs
substitutions (a list of items which are any value) – Output correspondance between old and new filenames.
- Outputs
report_html (a pathlike object or string representing a file)