AFQ.api.bundle_dict#

Classes#

BundleDict

Create a bundle dictionary, needed for the segmentation.

Functions#

default_bd()

baby_bd()

callosal_bd()

reco_bd(n_bundles)

n_bundles: int

cerebellar_bd()

Module Contents#

AFQ.api.bundle_dict.default_bd()[source]#
AFQ.api.bundle_dict.baby_bd()[source]#
AFQ.api.bundle_dict.callosal_bd()[source]#
AFQ.api.bundle_dict.reco_bd(n_bundles)[source]#
n_bundles: int

Selects between 16 or 80 bundle atlas

AFQ.api.bundle_dict.cerebellar_bd()[source]#
class AFQ.api.bundle_dict.BundleDict(bundle_info, resample_to=None, resample_subject_to=False, keep_in_memory=False, citations=None, criteria_for_all=None)[source]#

Bases: collections.abc.MutableMapping

Create a bundle dictionary, needed for the segmentation.

Parameters:
bundle_infodict,

A dictionary defining custom bundles. See Defining Custom Bundle Dictionaries in the usage section of pyAFQ’s documentation for details.

resample_toNifti1Image or bool, optional

If there are bundles in bundle_info with the ‘space’ attribute set to ‘template’, or with no ‘space’ attribute, their images (all ROIs and probability maps) will be resampled to the affine and shape of this image. If None, the MNI template will be used. If False, no resampling will be done. Default: None

resample_subject_toNifti1Image or bool, optional

If there are bundles in bundle_info with the ‘space’ attribute set to ‘subject’, their images (all ROIs and probability maps) will be resampled to the affine and shape of this image. If True, resamples to DWI. Be careful if you use this, that this is the correct choice. If False, no resampling will be done. Default: False

keep_in_memorybool, optional

Whether, once loaded, all ROIs and probability maps will stay loaded in memory within this object. By default, ROIs are loaded into memory on demand and no references to ROIs are kept, other than their paths. The default 18 bundles use ~6GB when all loaded. Default: False

citations: set, optional

A set of citations (in BibTeX format) relevant to the bundle definitions provided. Default: None

criteria_for_all: dict, optional

A dictionary of criteria that should be applied to all bundles. For example, you might want to set cleaning parameters for all bundles. Applied immediately after instantiation and does not affect newly added bundles. Default: None

Examples

# import OR ROIs and create a custom bundle dict # from them import AFQ.data.fetch as afd or_rois = afd.read_or_templates()

bundles = BundleDict({
“L_OR”: {
“include”: [

or_rois[“left_OR_1”], # these can be paths to Nifti files or_rois[“left_OR_2”]], # or they can Nifti images

“exclude”: [

or_rois[“left_OP_MNI”], or_rois[“left_TP_MNI”], or_rois[“left_pos_thal_MNI”]],

“start”: or_rois[‘left_thal_MNI’], “end”: or_rois[‘left_V1_MNI’], “cross_midline”: False,

}, “R_OR”: {

“include”: [

or_rois[“right_OR_1”], or_rois[“right_OR_2”]],

“exclude”: [

or_rois[“right_OP_MNI”], or_rois[“right_TP_MNI”], or_rois[“right_pos_thal_MNI”]],

“start”: or_rois[‘right_thal_MNI’], “end”: or_rois[‘right_V1_MNI’], “cross_midline”: False

}

})

resample_to = None[source]#
resample_subject_to = False[source]#
keep_in_memory = False[source]#
citations = None[source]#
_dict[source]#
bundle_names = [][source]#
logger[source]#
__print__()[source]#
_use_bids_info(roi_or_sl, bids_layout, bids_path, subject, session)[source]#
_cond_load(roi_or_sl, resample_to)[source]#

Load ROI or streamline if not already loaded

get_b_info(b_name)[source]#
relax_cleaning(delta_distance=1, delta_length=1)[source]#

This can be useful for PTT

__getitem__(key)[source]#
__setitem__(key, item)[source]#
__len__()[source]#
__delitem__(key)[source]#
__iter__()[source]#
copy()[source]#

Generates a copy of this BundleDict where the internal dictionary is a copy of this BundleDict’s internal dictionary. Useful if you want to add or remove bundles from a copy of a BundleDict.

Returns:
bundle_dictBundleDict

Euclidean norms of vectors.

apply_to_rois(b_name, *args, **kwargs)[source]#

See: AFQ.api.bundle_dict.apply_to_roi_dict

Parameters:
b_namename

bundle name of bundle whose ROIs will be transformed.

_cond_load_bundle(b_name, dry_run=False)[source]#

Given a bundle name, resample all ROIs and prob maps into either template or subject space for that bundle, depending on its “space” attribute.

Parameters:
b_namestr

Name of the bundle to be resampled.

is_bundle_in_template(bundle_name)[source]#
_roi_transform_helper(roi_or_sl, mapping, new_img)[source]#
transform_rois(bundle_name, mapping, new_img, base_fname=None, to_space='subject', apply_to_recobundles=False)[source]#

Get the bundle definition with transformed ROIs for a given bundle into a given subject space using a given mapping. Will only run on bundles which are in template space, otherwise will just return the bundle definition without transformation.

Parameters:
bundle_namestr

Name of the bundle to be transformed.

mappingDiffeomorphicMap object

A mapping between DWI space and a template.

new_imgNifti1Image

Image of space transformed into.

base_fnamestr, optional

Base file path to construct file path from. Additional BIDS descriptors will be added to this file path. If None, no file paths returned.

to_spacestr, optional

Name for space for exported ROIs. Only used if base_fname is not None. Default: “subject”

apply_to_recobundlesbool, optional

Whether to apply the transformation to recobundles TRKs as well. Default: False

Returns:
If base_fname is None, a dictionary where keys are
the roi type and values are the transformed ROIs.
Otherwise, a list of file names and a list of transformed ROIs
are returned.
__add__(other)[source]#