tractolearn.transformation package#
Submodules#
tractolearn.transformation.peaks_utils module#
- tractolearn.transformation.peaks_utils.get_peak_count(peak_dirs)#
Get the peak count per spatial location. All locations are expected to have the same peak count. Peaks are assumed to have 3 spatial coordinates (x, y, z). :param peak_dirs: The peak directions. Q must be a multiple of 3. :type peak_dirs: ndarray (X, Y, Z, Q)
- tractolearn.transformation.peaks_utils.reshape_peaks_for_computing(peak_dirs, peak_count, spatial_dims)#
Reshape the peak dirs array so that the volume extension indices remain unchanged in the first three dimensions; the peak count indices are made the last but one dimension, and the peak orientation values are made the last dimension, typically (X, Y, Z, P, 3), where P is the number of peaks per voxel. See also dipy.direction.peaks.reshape_peaks_for_visualization :param peak_dirs: Peak directions. Q must be a multiple of 3. :type peak_dirs: ndarray (X, Y, Z, Q) (4D) :param peak_count: Peak count. :type peak_count: int :param spatial_dims: Spatial dimensions of peaks. Typically 3 (x, y, z). :type spatial_dims: int
- Returns:
Reshaped peak directions.
- Return type:
ndarray
tractolearn.transformation.streamline_transformation module#
- tractolearn.transformation.streamline_transformation.flip_random_streamlines(streamlines, ratio=0.5)#
Flips streamlines randomly by reversing the array ordering.
- Parameters:
streamlines (nib.streamlines.ArraySequence) – Streamlines to be flipped.
ratio (float, optional) – Ratio of the streamlines to be flipped. Must be in the range [0..1].
- Returns:
flipped_streamlines (nib.streamlines.ArraySequence) – Flipped streamlines.
streamline_flip_indices (ndarray) – Flipped streamline indices.
- tractolearn.transformation.streamline_transformation.flip_streamlines(streamlines)#
Flips streamlines by reversing the array ordering. Note that both the head/tails and the streamline sorting are reversed. To reverse only the heads/tails use reverse_head_tails; to reverse only the streamline sorting use, reverse_streamline_sorting.
- Parameters:
streamlines (nib.streamlines.ArraySequence) – Streamlines to be flipped.
- Returns:
flipped_streamlines – Flipped streamlines.
- Return type:
nib.streamlines.ArraySequence
- tractolearn.transformation.streamline_transformation.resample_streamlines(streamlines, num_points, arc_length=True)#
Resamples streamlines to a number of points. If arc length parameterization is used, resampled streamlines will have equal length segments.
- Parameters:
streamlines (nib.streamlines.ArraySequence) – Streamlines to be resampled.
num_points (int) – Number of points for the resampled bundles.
arc_length (bool, optional) – If True, use arc length parameterization resampling.
- Returns:
resampled_streamlines – Resampled streamlines.
- Return type:
nib.streamlines.ArraySequence
- tractolearn.transformation.streamline_transformation.sft_voxel_transform(sft)#
tractolearn.transformation.volume_utils module#
- tractolearn.transformation.volume_utils.compute_isocenter(img)#
Computes the iso-center of a volumetric image in RAS space (mm).
- Parameters:
img (nibabel.nifti1.Nifti1Image) – NIfTI-1 Image.
- Returns:
isocenter – Iso-center of the input image.
- Return type:
ndarray
- tractolearn.transformation.volume_utils.compute_volume(img)#
Computes the volume of an input image in mm^3.
- Parameters:
img (nibabel.nifti1.Nifti1Image) – NIfTI-1 Image.
- Returns:
Volume of the input image.
- Return type:
float
- tractolearn.transformation.volume_utils.interpolate_volume_at_coordinates(volume: ndarray, coords: ndarray, mode: str = 'nearest', order: int = 3, cval=0.0) ndarray #
Evaluates a 3D or 4D volume data at the given coordinates by interpolation.
- Parameters:
volume (3D array or 4D array) – Data volume.
coords (ndarray of shape (N, 3)) – 3D coordinates where to evaluate the volume data.
mode (str, optional) – Points outside the boundaries of the input are filled according to the given mode (‘constant’, ‘nearest’, ‘reflect’ or ‘wrap’). (‘constant’ uses 0.0 as a points outside the boundary)
order (int, optional) – The order of the spline interpolation.
cval (float, optional) – Value used to fill past-boundary coordinates.
- Returns:
output – Values from volume.
- Return type:
2D array