cmtklib.diffusion module
Module that defines CMTK utility functions for the diffusion pipeline.
ExtractPVEsFrom5TT
Bases: nipype.interfaces.base.core.BaseInterface
Create Partial Volume Estimation maps for CSF, GM, WM tissues from
mrtrix3
5TT image.Examples
>>> from cmtklib.diffusion import ExtractPVEsFrom5TT >>> pves = ExtractPVEsFrom5TT() >>> pves.inputs.in_5tt = 'sub-01_desc-5tt_dseg.nii.gz' >>> pves.inputs.ref_image = 'sub-01_T1w.nii.gz' >>> pves.inputs.pve_csf_file = '/path/to/output_csf_pve.nii.gz' >>> pves.inputs.pve_gm_file = '/path/to/output_gm_pve.nii.gz' >>> pves.inputs.pve_wm_file = '/path/to/output_wm_pve.nii.gz' >>> pves.run()
- in_5tta pathlike object or string representing an existing file
Input 5TT (4D) image.
- pve_csf_filea pathlike object or string representing a file
CSF Partial Volume Estimation volume estimated from.
- pve_gm_filea pathlike object or string representing a file
GM Partial Volume Estimation volume estimated from.
- pve_wm_filea pathlike object or string representing a file
WM Partial Volume Estimation volume estimated from.
- ref_imagea pathlike object or string representing an existing file
Reference 3D image to be used to save 3D PVE volumes.
- partial_volume_filesa list of items which are a pathlike object or string representing a file
CSF/GM/WM Partial Volume Estimation images estimated from.
FlipBvec
Bases: nipype.interfaces.base.core.BaseInterface
Return a diffusion bvec file with flipped axis as specified by
flipping_axis
input.Examples
>>> from cmtklib.diffusion import FlipBvec >>> flip_bvec = FlipBvec() >>> flip_bvec.inputs.bvecs = 'sub-01_dwi.bvecs' >>> flip_bvec.inputs.flipping_axis = ['x'] >>> flip_bvec.inputs.delimiter = ' ' >>> flip_bvec.inputs.header_lines = 0 >>> flip_bvec.inputs.orientation = 'h' >>> flip_bvec.run()
- bvecsa pathlike object or string representing an existing file
Input diffusion gradient bvec file.
- delimitera string
Delimiter used in the table.
- flipping_axisa list of items which are any value
List of axis to be flipped.
- header_linesan integer
Line number of table header.
- orientation‘v’ or ‘h’
Orientation of the table.
- bvecs_flippeda pathlike object or string representing an existing file
Output bvec file with flipped axis.
FlipTable
Bases: nipype.interfaces.base.core.BaseInterface
Flip axis and rewrite a gradient table.
Examples
>>> from cmtklib.diffusion import FlipTable >>> flip_table = FlipTable() >>> flip_table.inputs.table = 'sub-01_mod-dwi_gradient.txt' >>> flip_table.inputs.flipping_axis = ['x'] >>> flip_table.inputs.orientation = 'v' >>> flip_table.inputs.delimiter = ',' >>> flip_table.run()
- delimitera string
Delimiter used in the table.
- flipping_axisa list of items which are any value
List of axis to be flipped.
- header_linesan integer
Line number of table header.
- orientation‘v’ or ‘h’
Orientation of the table.
- tablea pathlike object or string representing an existing file
Input diffusion gradient table.
- tablea pathlike object or string representing an existing file
Output table with flipped axis.
Make_Mrtrix_Seeds
Bases: nipype.interfaces.base.core.BaseInterface
Creates seeding ROIs by intersecting dilated ROIs with WM mask for
mrtrix
.Examples
>>> from cmtklib.diffusion import Make_Mrtrix_Seeds >>> make_mrtrix_seeds = Make_Mrtrix_Seeds() >>> make_mrtrix_seeds.inputs.ROI_files = ['sub-01_space-DWI_atlas-L2018_desc-scale1_dseg.nii.gz', >>> 'sub-01_space-DWI_atlas-L2018_desc-scale2_dseg.nii.gz', >>> 'sub-01_space-DWI_atlas-L2018_desc-scale3_dseg.nii.gz', >>> 'sub-01_space-DWI_atlas-L2018_desc-scale4_dseg.nii.gz', >>> 'sub-01_space-DWI_atlas-L2018_desc-scale5_dseg.nii.gz'] >>> make_mrtrix_seeds.inputs.WM_file = 'sub-01_space-DWI_label-WM_dseg.nii.gz' >>> make_mrtrix_seeds.run()
- WM_filea pathlike object or string representing a file
WM mask file registered to diffusion space.
- ROI_filesa list of items which are a pathlike object or string representing an existing file
ROI files registered to diffusion space.
- seed_filesa list of items which are a pathlike object or string representing an existing file
Seed files for probabilistic tractography.
- Make_Mrtrix_Seeds.ROI_idx = []
- Make_Mrtrix_Seeds.base_name = ''
Make_Seeds
Bases: nipype.interfaces.base.core.BaseInterface
Creates seeding ROIs by intersecting dilated ROIs with WM mask for
Dipy
.Examples
>>> from cmtklib.diffusion import Make_Seeds >>> make_dipy_seeds = Make_Seeds() >>> make_dipy_seeds.inputs.ROI_files = ['sub-01_space-DWI_atlas-L2018_desc-scale1_dseg.nii.gz', >>> 'sub-01_space-DWI_atlas-L2018_desc-scale2_dseg.nii.gz', >>> 'sub-01_space-DWI_atlas-L2018_desc-scale3_dseg.nii.gz', >>> 'sub-01_space-DWI_atlas-L2018_desc-scale4_dseg.nii.gz', >>> 'sub-01_space-DWI_atlas-L2018_desc-scale5_dseg.nii.gz'] >>> make_dipy_seeds.inputs.WM_file = 'sub-01_space-DWI_label-WM_dseg.nii.gz' >>> make_dipy_seeds.run()
- WM_filea pathlike object or string representing a file
WM mask file registered to diffusion space.
- ROI_filesa list of items which are a pathlike object or string representing an existing file
ROI files registered to diffusion space.
- seed_filesa list of items which are a pathlike object or string representing an existing file
Seed files for probabilistic tractography.
- Make_Seeds.ROI_idx = []
- Make_Seeds.base_name = ''
SplitDiffusion
Bases: nipype.interfaces.base.core.BaseInterface
Extract volumes from diffusion MRI data given a start and end index.
Examples
>>> from cmtklib.diffusion import SplitDiffusion >>> split_dwi = SplitDiffusion() >>> split_dwi.inputs.in_file = 'sub-01_dwi.nii.gz' >>> split_dwi.inputs.start = 5 >>> split_dwi.inputs.in_file = 30 >>> split_dwi.run()
- endan integer
Volume index to end the split.
- in_filea pathlike object or string representing an existing file
Input diffusion MRI file.
- startan integer
Volume index to start the split.
- dataa pathlike object or string representing an existing file
Extracted volumes.
- padding1a pathlike object or string representing a file
Extracted volumes with padding 1.
- padding2a pathlike object or string representing a file
Extracted volumes with padding 2.
Tck2Trk
Bases: nipype.interfaces.base.core.BaseInterface
Convert a tractogram in
mrtrix
TCK format totrackvis
TRK format.Examples
>>> from cmtklib.diffusion import Tck2Trk >>> tck_to_trk = Tck2Trk() >>> tck_to_trk.inputs.in_tracks = 'sub-01_tractogram.tck' >>> tck_to_trk.inputs.in_image = 'sub-01_desc-preproc_dwi.nii.gz' >>> tck_to_trk.inputs.out_tracks = 'sub-01_tractogram.trk' >>> tck_to_trk.run()
- in_imagea pathlike object or string representing an existing file
Input image used to extract the header.
- in_tracksa pathlike object or string representing an existing file
Input track file in MRtrix .tck format.
- out_tracksa pathlike object or string representing a file
Output track file in Trackvis .trk format.
- out_tracksa pathlike object or string representing an existing file
Output track file in Trackvis .trk format.
UpdateGMWMInterfaceSeeding
Bases: nipype.interfaces.base.core.BaseInterface
Add extra Lausanne2018 structures to the Gray-matter/White-matter interface for tractography seeding.
Examples
>>> from cmtklib.diffusion import UpdateGMWMInterfaceSeeding >>> update_gmwmi = UpdateGMWMInterfaceSeeding() >>> update_gmwmi.inputs.in_gmwmi_file = 'sub-01_label-gmwmi_desc-orig_dseg.nii.gz' >>> update_gmwmi.inputs.out_gmwmi_file = 'sub-01_label-gmwmi_desc-modif_dseg.nii.gz' >>> update_gmwmi.inputs.in_roi_volumes = ['sub-01_space-DWI_atlas-L2018_desc-scale1_dseg.nii.gz', >>> 'sub-01_space-DWI_atlas-L2018_desc-scale2_dseg.nii.gz', >>> 'sub-01_space-DWI_atlas-L2018_desc-scale3_dseg.nii.gz', >>> 'sub-01_space-DWI_atlas-L2018_desc-scale4_dseg.nii.gz', >>> 'sub-01_space-DWI_atlas-L2018_desc-scale5_dseg.nii.gz'] >>> update_gmwmi.run()
- in_gmwmi_filea pathlike object or string representing an existing file
Input GMWM interface image used for streamline seeding.
- in_roi_volumesa list of items which are a pathlike object or string representing an existing file
Input parcellation images.
- out_gmwmi_filea pathlike object or string representing a file
Output GM WM interface used for streamline seeding.
- out_gmwmi_filea pathlike object or string representing an existing file
Output GM WM interface used for streamline seeding.
- cmtklib.diffusion.compute_length_array(trkfile=None, streams=None, savefname='lengths.npy')[source]
Computes the length of the fibers in a tractogram and returns an array of length.
- Parameters
trkfile (TRK file) – Path to the tractogram in TRK format
streams (the fibers data) – The fibers from which we want to compute the length
savefname (string) – Output filename to write the length array
- Returns
leng – Array of fiber lengths
- Return type
numpy.array