AFQ.recognition.other_bundles#

Module Contents#

Functions#

clean_by_other_density_map(this_bundle_sls, ...)

Cleans a set of streamlines by removing those with significant overlap with

clean_relative_to_other_core(core, this_fgarray, ...)

Removes streamlines from a set that lie on the opposite side of a specified

Attributes#

AFQ.recognition.other_bundles.logger[source]#
AFQ.recognition.other_bundles.clean_by_other_density_map(this_bundle_sls, other_bundle_sls, node_thresh, img)[source]#

Cleans a set of streamlines by removing those with significant overlap with another set of streamlines.

Parameters
this_bundle_slsarray-like

A list or array of streamlines to be cleaned.

other_bundle_slsarray-like

A reference list or array of streamlines to determine overlapping regions.

node_threshint

The maximum number of nodes allowed to overlap between this_bundle_sls and other_bundle_sls. Streamlines with overlaps beyond this threshold are removed.

imgnibabel.Nifti1Image or ndarray

A reference 3D image that defines the spatial dimensions for the density map.

Returns
cleaned_idxndarray of bool

An array of boolean values indicating which streamlines from this_bundle_sls pass the overlap threshold (True for streamlines to keep, False for streamlines to discard).

Notes

This function computes a density map from other_bundle_sls to represent the spatial occupancy of the streamlines. It then calculates the probability of each streamline in this_bundle_sls overlapping with this map. Streamlines that overlap in more than node_thresh nodes are flagged for removal.

Examples

>>> clean_idx = clean_by_other_density_map(bundle1, bundle2, 5, img)
>>> cleaned_bundle = [s for i, s in enumerate(bundle1) if clean_idx[i]]
AFQ.recognition.other_bundles.clean_relative_to_other_core(core, this_fgarray, other_fgarray, affine)[source]#

Removes streamlines from a set that lie on the opposite side of a specified core axis compared to another set of streamlines.

Parameters
core{‘anterior’, ‘posterior’, ‘superior’, ‘inferior’, ‘right’, ‘left’}

The anatomical axis used to define the core direction. This determines the side of the core from which streamlines in this_fgarray are retained.

this_fgarrayndarray

An array of streamlines to be cleaned.

other_fgarrayndarray

An array of reference streamlines to define the core.

affinendarray

The affine transformation matrix.

Returns
cleaned_idx_corendarray of bool

An array of boolean values indicating which streamlines in this_fgarray lie on the correct side of the core (True for streamlines to keep, False for streamlines to discard).

Notes

This function first calculates the median streamline of other_fgarray, which acts as the core line. It then determines whether each streamline in this_fgarray is on the specified side of this core, based on the specified anatomical axis (core). Streamlines on the opposite side are flagged for removal.

Examples

>>> cleaned_core_idx = clean_relative_to_other_core('anterior',
...                                                 streamlines1,
...                                                 streamlines2,
...                                                 np.eye(4))
>>> cleaned_streamlines = [s for i, s in enumerate(streamlines1)
...                        if cleaned_core_idx[i]]