nipype.interfaces.cmtk.cmtk module¶
CreateMatrix¶
Bases: BaseInterface
Performs connectivity mapping and outputs the result as a NetworkX graph and a Matlab matrix
Example
>>> import nipype.interfaces.cmtk as cmtk >>> conmap = cmtk.CreateMatrix() >>> conmap.roi_file = 'fsLUT_aparc+aseg.nii' >>> conmap.tract_file = 'fibers.trk' >>> conmap.run()
- Mandatory Inputs
resolution_network_file (a pathlike object or string representing an existing file) – Parcellation files from Connectome Mapping Toolkit.
roi_file (a pathlike object or string representing an existing file) – Freesurfer aparc+aseg file.
tract_file (a pathlike object or string representing an existing file) – Trackvis tract file.
- Optional Inputs
count_region_intersections (a boolean) – Counts all of the fiber-region traversals in the connectivity matrix (requires significantly more computational time). (Nipype default value:
False
)out_endpoint_array_name (a pathlike object or string representing a file) – Name for the generated endpoint arrays.
out_fiber_length_std_matrix_mat_file (a pathlike object or string representing a file) – Matlab matrix describing the deviation in fiber lengths connecting each node.
out_intersection_matrix_mat_file (a pathlike object or string representing a file) – Matlab connectivity matrix if all region/fiber intersections are counted.
out_matrix_file (a pathlike object or string representing a file) – NetworkX graph describing the connectivity.
out_matrix_mat_file (a pathlike object or string representing a file) – Matlab matrix describing the connectivity. (Nipype default value:
cmatrix.mat
)out_mean_fiber_length_matrix_mat_file (a pathlike object or string representing a file) – Matlab matrix describing the mean fiber lengths between each node.
out_median_fiber_length_matrix_mat_file (a pathlike object or string representing a file) – Matlab matrix describing the mean fiber lengths between each node.
- Outputs
endpoint_file (a pathlike object or string representing an existing file) – Saved Numpy array with the endpoints of each fiber.
endpoint_file_mm (a pathlike object or string representing an existing file) – Saved Numpy array with the endpoints of each fiber (in millimeters).
fiber_label_file (a pathlike object or string representing an existing file) – Saved Numpy array with the labels for each fiber.
fiber_labels_noorphans (a pathlike object or string representing an existing file) – Saved Numpy array with the labels for each non-orphan fiber.
fiber_length_file (a pathlike object or string representing an existing file) – Saved Numpy array with the lengths of each fiber.
fiber_length_std_matrix_mat_file (a pathlike object or string representing an existing file) – Matlab matrix describing the deviation in fiber lengths connecting each node.
filtered_tractographies (a list of items which are a pathlike object or string representing an existing file)
filtered_tractography (a pathlike object or string representing an existing file) – TrackVis file containing only those fibers originate in one and terminate in another region.
filtered_tractography_by_intersections (a pathlike object or string representing an existing file) – TrackVis file containing all fibers which connect two regions.
intersection_matrix_file (a pathlike object or string representing an existing file) – NetworkX graph describing the connectivity.
intersection_matrix_mat_file (a pathlike object or string representing an existing file) – Matlab matrix describing the mean fiber lengths between each node.
matlab_matrix_files (a list of items which are a pathlike object or string representing an existing file)
matrix_file (a pathlike object or string representing an existing file) – NetworkX graph describing the connectivity.
matrix_files (a list of items which are a pathlike object or string representing an existing file)
matrix_mat_file (a pathlike object or string representing an existing file) – Matlab matrix describing the connectivity.
mean_fiber_length_matrix_mat_file (a pathlike object or string representing an existing file) – Matlab matrix describing the mean fiber lengths between each node.
median_fiber_length_matrix_mat_file (a pathlike object or string representing an existing file) – Matlab matrix describing the median fiber lengths between each node.
stats_file (a pathlike object or string representing an existing file) – Saved Matlab .mat file with the number of fibers saved at each stage.
CreateNodes¶
Bases: BaseInterface
Generates a NetworkX graph containing nodes at the centroid of each region in the input ROI file. Node data is added from the resolution network file.
Example
>>> import nipype.interfaces.cmtk as cmtk >>> mknode = cmtk.CreateNodes() >>> mknode.inputs.roi_file = 'ROI_scale500.nii.gz' >>> mknode.run()
- Mandatory Inputs
resolution_network_file (a pathlike object or string representing an existing file) – Parcellation file from Connectome Mapping Toolkit.
roi_file (a pathlike object or string representing an existing file) – Region of interest file.
- Optional Inputs
out_filename (a pathlike object or string representing a file) – Output gpickled network with the nodes defined. (Nipype default value:
nodenetwork.pck
)- Outputs
node_network (a pathlike object or string representing a file) – Output gpickled network with the nodes defined.
ROIGen¶
Bases: BaseInterface
Generates a ROI file for connectivity mapping and a dictionary file containing relevant node information
Example
>>> import nipype.interfaces.cmtk as cmtk >>> rg = cmtk.ROIGen() >>> rg.inputs.aparc_aseg_file = 'aparc+aseg.nii' >>> rg.inputs.use_freesurfer_LUT = True >>> rg.inputs.freesurfer_dir = '/usr/local/freesurfer' >>> rg.run()The label dictionary is written to disk using Pickle. Resulting data can be loaded using:
>>> file = open("FreeSurferColorLUT_adapted_aparc+aseg_out.pck", "r") >>> file = open("fsLUT_aparc+aseg.pck", "r") >>> labelDict = pickle.load(file) >>> labelDict
- Mandatory Inputs
aparc_aseg_file (a pathlike object or string representing an existing file) – Freesurfer aparc+aseg file.
- Optional Inputs
LUT_file (a pathlike object or string representing an existing file) – Custom lookup table (cf. FreeSurferColorLUT.txt). Mutually exclusive with inputs:
use_freesurfer_LUT
.freesurfer_dir (a pathlike object or string representing a directory) – Freesurfer main directory. Requires inputs:
use_freesurfer_LUT
.out_dict_file (a pathlike object or string representing a file) – Label dictionary saved in Pickle format.
out_roi_file (a pathlike object or string representing a file) – Region of Interest file for connectivity mapping.
use_freesurfer_LUT (a boolean) – Boolean value; Set to True to use default Freesurfer LUT, False for custom LUT. Mutually exclusive with inputs:
LUT_file
.- Outputs
dict_file (a pathlike object or string representing a file) – Label dictionary saved in Pickle format.
roi_file (a pathlike object or string representing a file) – Region of Interest file for connectivity mapping.
- nipype.interfaces.cmtk.cmtk.cmat(track_file, roi_file, resolution_network_file, matrix_name, matrix_mat_name, endpoint_name, intersections=False)¶
Create the connection matrix for each resolution using fibers and ROIs.
- nipype.interfaces.cmtk.cmtk.create_allpoints_cmat(streamlines, roiData, voxelSize, n_rois)¶
Create the intersection arrays for each fiber
- nipype.interfaces.cmtk.cmtk.create_endpoints_array(fib, voxelSize)¶
Create the endpoints arrays for each fiber.
- Parameters
fib (array-like) – the fibers data
voxelSize (tuple) – 3-tuple containing the voxel size of the ROI image
- Returns
endpoints (ndarray of size [#fibers, 2, 3]) – containing for each fiber the index of its first and last point in the voxelSize volume
endpointsmm (ndarray of size [#fibers, 2, 3]) – endpoints in millimeter coordinates
- nipype.interfaces.cmtk.cmtk.create_nodes(roi_file, resolution_network_file, out_filename)¶
- nipype.interfaces.cmtk.cmtk.get_connectivity_matrix(n_rois, list_of_roi_crossed_lists)¶
- nipype.interfaces.cmtk.cmtk.get_rois_crossed(pointsmm, roiData, voxelSize)¶
- nipype.interfaces.cmtk.cmtk.length(xyz, along=False)¶
Euclidean length of track line
- Parameters
xyz (array-like shape (N,3)) – array representing x,y,z of N points in a track
along (bool, optional) – If True, return array giving cumulative length along track, otherwise (default) return scalar giving total length.
- Returns
L – scalar in case of along == False, giving total length, array if along == True, giving cumulative lengths.
- Return type
scalar or array shape (N-1,)
Examples
>>> xyz = np.array([[1,1,1],[2,3,4],[0,0,0]]) >>> expected_lens = np.sqrt([1+2**2+3**2, 2**2+3**2+4**2]) >>> length(xyz) == expected_lens.sum() True >>> len_along = length(xyz, along=True) >>> np.allclose(len_along, expected_lens.cumsum()) True >>> length([]) 0 >>> length([[1, 2, 3]]) 0 >>> length([], along=True) array([0])
- nipype.interfaces.cmtk.cmtk.save_fibers(oldhdr, oldfib, fname, indices)¶
Stores a new trackvis file fname using only given indices