cmtklib.connectome module

Module that defines CMTK functions and Nipype interfaces for connectome mapping.

CMTK_cmat

Link to code

Bases: nipype.interfaces.base.core.BaseInterface

Creates the structural connectivity matrices for a given parcellation scheme.

Examples

>>> from cmtklib.connectome import CMTK_cmat
>>> cmat = CMTK_cmat()
>>> cmat.inputs.base_dir = '/my_directory'
>>> cmat.inputs.track_file = '/path/to/sub-01_tractogram.trk'
>>> cmat.inputs.roi_volumes = ['/path/to/sub-01_space-DWI_atlas-L2018_desc-scale1_dseg.nii.gz',
>>>                            '/path/to/sub-01_space-DWI_atlas-L2018_desc-scale2_dseg.nii.gz',
>>>                            '/path/to/sub-01_space-DWI_atlas-L2018_desc-scale3_dseg.nii.gz',
>>>                            '/path/to/sub-01_space-DWI_atlas-L2018_desc-scale4_dseg.nii.gz',
>>>                            '/path/to/sub-01_space-DWI_atlas-L2018_desc-scale5_dseg.nii.gz']
>>> cmat.inputs.roi_graphmls = ['/path/to/sub-01_atlas-L2018_desc-scale1_dseg.graphml',
>>>                             '/path/to/sub-01_atlas-L2018_desc-scale2_dseg.graphml',
>>>                             '/path/to/sub-01_atlas-L2018_desc-scale3_dseg.graphml',
>>>                             '/path/to/sub-01_atlas-L2018_desc-scale4_dseg.graphml',
>>>                             '/path/to/sub-01_atlas-L2018_desc-scale5_dseg.graphml']
>>> cmat.inputs.parcellation scheme = 'Lausanne2018'
>>> cmat.inputs.output_types = ['gPickle','mat','graphml']
>>> cmat.run()  
track_filea list of items which are a pathlike object or string representing an existing file

Tractography result.

additional_mapsa list of items which are a pathlike object or string representing a file

Additional calculated maps (ADC, gFA, …).

atlas_infoa dictionary with keys which are any value and with values which are any value

Custom atlas information.

compute_curvaturea boolean

Compute curvature. (Nipype default value: True)

output_typesa list of items which are a string

Output types of the connectivity matrices.

parcellation_scheme‘Lausanne2018’ or ‘NativeFreesurfer’ or ‘Custom’

Parcellation scheme. (Nipype default value: Lausanne2018)

roi_graphmlsa list of items which are a pathlike object or string representing an existing file

GraphML description of ROI volumes (Lausanne2018).

roi_volumesa list of items which are a pathlike object or string representing an existing file

ROI volumes registered to diffusion space.

voxel_connectivitya list of items which are a pathlike object or string representing an existing file

ProbtrackX connectivity matrices (# seed voxels x # target ROIs).

connectivity_matricesa list of items which are a pathlike object or string representing a file

Connectivity matrices.

endpoints_filea pathlike object or string representing a file

Numpy files storing the list of fiber endpoint.

endpoints_mm_filea pathlike object or string representing a file

Numpy files storing the list of fiber endpoint in mm.

filtered_fiberslabel_filesa list of items which are a pathlike object or string representing a file

List of fiber start end ROI parcellation label after filtering.

final_fiberlabels_filesa list of items which are a pathlike object or string representing a file

List of fiber start end ROI parcellation label.

final_fiberslength_filesa list of items which are a pathlike object or string representing a file

List of fiber length.

streamline_final_filea pathlike object or string representing a file

Final tractogram of fibers considered in the creation of connectivity matrices.

CMTK_rsfmri_cmat

Link to code

Bases: nipype.interfaces.base.core.BaseInterface

Creates the functional connectivity matrices for a given parcellation scheme.

It applies scrubbing (if enabled), computes the average GM ROI time-series and computes

the Pearson’s correlation coefficient between each GM ROI time-series poir.

Examples

>>> from cmtklib.connectome import CMTK_rsfmri_cmat
>>> cmat = CMTK_rsfmri_cmat()
>>> cmat.inputs.base_dir = '/my_directory'
>>> cmat.inputs.func_file = '/path/to/sub-01_task-rest_desc-preproc_bold.nii.gz'
>>> cmat.inputs.roi_volumes = ['/path/to/sub-01_space-meanBOLD_atlas-L2018_desc-scale1_dseg.nii.gz',
>>>                            '/path/to/sub-01_space-meanBOLD_atlas-L2018_desc-scale2_dseg.nii.gz',
>>>                            '/path/to/sub-01_space-meanBOLD_atlas-L2018_desc-scale3_dseg.nii.gz',
>>>                            '/path/to/sub-01_space-meanBOLD_atlas-L2018_desc-scale4_dseg.nii.gz',
>>>                            '/path/to/sub-01_space-meanBOLD_atlas-L2018_desc-scale5_dseg.nii.gz']
>>> cmat.inputs.roi_graphmls = ['/path/to/sub-01_atlas-L2018_desc-scale1_dseg.graphml',
>>>                             '/path/to/sub-01_atlas-L2018_desc-scale2_dseg.graphml',
>>>                             '/path/to/sub-01_atlas-L2018_desc-scale3_dseg.graphml',
>>>                             '/path/to/sub-01_atlas-L2018_desc-scale4_dseg.graphml',
>>>                             '/path/to/sub-01_atlas-L2018_desc-scale5_dseg.graphml']
>>> cmat.inputs.parcellation scheme = 'Lausanne2018'
>>> cmat.inputs.apply_scrubbing = False
>>> cmat.inputs.output_types = ['gPickle','mat','graphml']
>>> cmat.run() 
func_filea pathlike object or string representing an existing file

FMRI volume.

DVARSa pathlike object or string representing an existing file

DVARS file if scrubbing is performed.

DVARS_tha float

DVARS threshold.

FDa pathlike object or string representing an existing file

FD file if scrubbing is performed.

FD_tha float

FD threshold.

apply_scrubbinga boolean

Apply scrubbing.

atlas_infoa dictionary with keys which are any value and with values which are any value

Custom atlas information.

output_typesa list of items which are a string

Output types of the connectivity matrices.

parcellation_scheme‘Lausanne2018’ or ‘NativeFreesurfer’ or ‘Custom’

Parcellation scheme. (Nipype default value: Lausanne2018)

roi_graphmlsa list of items which are a pathlike object or string representing an existing file

GraphML description file for ROI volumes (used only if parcellation_scheme == Lausanne2018).

roi_volumesa list of items which are a pathlike object or string representing an existing file

ROI volumes registered to functional space.

avg_timeseriesa list of items which are a pathlike object or string representing an existing file

ROI average timeseries.

connectivity_matricesa list of items which are a pathlike object or string representing an existing file

Functional connectivity matrices.

scrubbed_idxa pathlike object or string representing an existing file

Scrubbed indices.

cmtklib.connectome.cmat(intrk, roi_volumes=None, roi_graphmls=None, parcellation_scheme=None, compute_curvature=True, additional_maps=None, output_types=None, atlas_info=None)[source]

Create the connection matrix for each resolution using fibers and ROIs.

Parameters
  • intrk (TRK file) – Reconstructed tractogram

  • roi_volumes (list) – List of parcellation files for a given parcellation scheme

  • roi_graphmls (list) – List of graphmls files that describes parcellation nodes

  • parcellation_scheme (['NativeFreesurfer', 'Lausanne2018', 'Custom']) –

  • compute_curvature (Boolean) –

  • additional_maps (dict) – A dictionary of key/value for each additional map where the value is the path to the map

  • output_types (['gPickle','mat','graphml']) –

  • atlas_info (dict) – Dictionary storing information such as path to files related to a parcellation atlas / scheme.

cmtklib.connectome.compute_curvature_array(fib)[source]

Computes the curvature array.

cmtklib.connectome.create_endpoints_array(fib, voxelSize, print_info)[source]

Create the endpoints arrays for each fiber.

Parameters
  • fib (the fibers data) –

  • voxelSize (3-tuple) – It contains the voxel size of the ROI image

  • print_info (bool) – If True, print extra information

Returns

  • (endpoints (matrix of size [#fibers, 2, 3] containing for each fiber the) – index of its first and last point in the voxelSize volume

  • endpointsmm) (endpoints in milimeter coordinates)

cmtklib.connectome.group_analysis_sconn(output_dir, subjects_to_be_analyzed)[source]

Perform group level analysis of structural connectivity matrices.

cmtklib.connectome.save_fibers(oldhdr, oldfib, fname, indices)[source]

Stores a new trackvis file fname using only given indices.

Parameters
  • oldhdr (the tractogram header) – Tractogram header to use as reference

  • oldfib (the fibers data) – Input fibers

  • fname (string) – Output tractogram filename

  • indices (list) – Indices of fibers included