AFQ.bundles

Module Contents

Classes

Bundles

class AFQ.bundles.Bundles(reference='same', space=Space.RASMM, origin=Origin.NIFTI, bundles_dict=None, using_idx=False)[source]
add_bundle(self, bundle_name, streamlines, idx=None)[source]

Add a bundle to bundles.

Parameters
bundle_namestring

Name of bundle.

streamlinesnibabel.Streamlines or StatefulTractogram

The streamlines constituting a bundle.

idxarray of ints, optional

Indices for streamlines in original tractography. Default: None.

clean_bundles(self, **kwargs)[source]

Clean each segmented bundle based on the Mahalnobis distance of each streamline

Parameters
clean_roundsint, optional.

Number of rounds of cleaning based on the Mahalanobis distance from the mean of extracted bundles. Default: 5

clean_thresholdfloat, optional.

Threshold of cleaning based on the Mahalanobis distance (the units are standard deviations). Default: 3.

min_slint, optional.

Number of streamlines in a bundle under which we will not bother with cleaning outliers. Default: 20.

statcallable, optional.

The statistic of each node relative to which the Mahalanobis is calculated. Default: np.mean (but can also use median, etc.)

_apply_affine_sft(self, sft, affine, reference, origin)[source]
apply_affine(self, affine, reference, origin=Origin.NIFTI)[source]

Apply a linear transformation, given by affine, to all streamlines.

Parameters
affinearray (4, 4)

Apply affine matrix to all streamlines

referenceNifti or Trk filename, Nifti1Image or TrkFile,

Nifti1Header, trk.header (dict) or another Stateful Tractogram Reference that provides the new spatial attribute.

originEnum (dipy.io.stateful_tractogram.Origin), optional

New origin of streamlines. Default: Origin.NIFTI

to_space(self, space)[source]

Transform streamlines to space.

Parameters
spaceSpace

Space to transform the streamlines to.

save_bundles(self, file_path='./', file_suffix='.trk', space=None, bbox_valid_check=False)[source]

Save tractograms in bundles.

Parameters
file_pathstring, optional.

Path to save trk files to. Default: ‘./’

file_suffixstring, optional.

File name will be the bundle name + file_suffix. Default: ‘.trk’

spacestring

Space to save the streamlines in. If not none, the streamlines will be transformed to this space, saved, then transformed back. Default: None.

bbox_valid_checkboolean, optional.

Whether to verify that the bounding box is valid in voxel space. Default: False

load_bundles(self, bundle_names, file_path='./', file_suffix='.trk', affine=np.eye(4), bbox_valid_check=False)[source]

load tractograms from file.

Parameters
bundle_nameslist of strings

Names of bundles to load.

file_pathstring, optional.

Path to load trk files from. Default: ‘./’

file_suffixstring, optional.

File name will be the bundle name + file_suffix. Default: ‘.trk’

affinearray_like (4, 4), optional.

The mapping from the file’s reference to this object’s reference. Default: np.eye(4)

bbox_valid_checkboolean, optional.

Whether to verify that the bounding box is valid in voxel space. Default: False

tract_profiles(self, data, subject_label, affine=np.eye(4), method='afq', metric='FA', n_points=100, weight=True)[source]

Calculate a summarized profile of data for each bundle along its length.

Follows the approach outlined in [Yeatman2012].

Parameters
data3D volume

The statistic to sample with the streamlines.

subject_labelstring

String which identifies these bundles in the pandas dataframe.

affinearray_like (4, 4), optional.

The mapping from voxel coordinates to ‘data’ coordinates. Default: np.eye(4)

methodstring

Method used to segment streamlines. Default: ‘afq’

metricstring

Metric of statistic in data. Default: ‘FA’

n_pointsint

Number of points to resample to. Default: 100

weightboolean

Whether to calculate gaussian weights before profiling. Default: True