AFQ.definitions.image#

Module Contents#

Classes#

ImageFile

Define an image based on a file.

FullImage

Define an image which covers a full volume.

RoiImage

Define an image which is all include ROIs or'd together.

GQImage

Threshold the anisotropic diffusion component of the

B0Image

Define an image using b0 and dipy's median_otsu.

LabelledImageFile

Define an image based on labels in a file.

ThresholdedImageFile

Define an image based on thresholding a file.

ScalarImage

Define an image based on a scalar.

ThresholdedScalarImage

Define an image based on thresholding a scalar image.

TemplateImage

Define a scalar based on a template.

class AFQ.definitions.image.ImageFile(path=None, suffix=None, filters={})[source]#

Bases: ImageDefinition

Define an image based on a file. Does not apply any labels or thresholds; Generates image with floating point data. Useful for seed and stop images, where threshold can be applied after interpolation (see example).

Parameters
pathstr, optional

path to file to get image from. Use this or suffix. Default: None

suffixstr, optional

suffix to pass to bids_layout.get() to identify the file. Default: None

filtersstr, optional

Additional filters to pass to bids_layout.get() to identify the file. Default: {}

Examples

seed_image = ImageFile(

suffix=”WM”, filters={“scope”:”dmriprep”})

api.GroupAFQ(tracking_params={“seed_image”: seed_image,

“seed_threshold”: 0.1})

find_path(bids_layout, from_path, subject, session, required=True)[source]#
get_path_data_affine(dwi_path)[source]#
apply_conditions(image_data_orig, image_file)[source]#
get_name()[source]#
get_image_getter(task_name)[source]#
class AFQ.definitions.image.FullImage[source]#

Bases: ImageDefinition

Define an image which covers a full volume.

Examples

brain_image_definition = FullImage()

get_name()[source]#
get_image_getter(task_name)[source]#
class AFQ.definitions.image.RoiImage(use_waypoints=True, use_presegment=False, use_endpoints=False, tissue_property=None, tissue_property_n_voxel=None, tissue_property_threshold=None)[source]#

Bases: ImageDefinition

Define an image which is all include ROIs or’d together.

Parameters
use_waypointsbool

Whether to use the include ROIs to generate the image.

use_presegmentbool

Whether to use presegment bundle dict from segmentation params to get ROIs.

use_endpointsbool

Whether to use the endpoints (“start” and “end”) to generate the image.

tissue_propertystr or None

Tissue property from scalars to multiply the ROI image with. Can be useful to limit seed mask to the core white matter. Note: this must be a built-in tissue property. Default: None

tissue_property_n_voxelint or None

Threshold tissue_property to a boolean mask with tissue_property_n_voxel number of voxels set to True. Default: None

tissue_property_thresholdint or None

Threshold to threshold tissue_property if a boolean mask is desired. This threshold is interpreted as a percentile. Overrides tissue_property_n_voxel. Default: None

Examples
——–
seed_image = RoiImage()
api.GroupAFQ(tracking_params={“seed_image”: seed_image})
get_name()[source]#
get_image_getter(task_name)[source]#
class AFQ.definitions.image.GQImage[source]#

Bases: ImageDefinition

Threshold the anisotropic diffusion component of the Generalized Q-Sampling Model to generate a brain mask which will include the eyes, optic nerve, and cerebrum but will exclude most or all of the skull.

Examples

api.GroupAFQ(brain_mask_definition=GQImage())

get_name()[source]#
get_image_getter(task_name)[source]#
class AFQ.definitions.image.B0Image(median_otsu_kwargs={})[source]#

Bases: ImageDefinition

Define an image using b0 and dipy’s median_otsu.

Parameters
median_otsu_kwargs: dict, optional

Optional arguments to pass into dipy’s median_otsu. Default: {}

Examples

brain_image_definition = B0Image() api.GroupAFQ(brain_image_definition=brain_image_definition)

get_name()[source]#
get_image_getter(task_name)[source]#
class AFQ.definitions.image.LabelledImageFile(path=None, suffix=None, filters={}, inclusive_labels=None, exclusive_labels=None, combine='or')[source]#

Bases: ImageFile, CombineImageMixin

Define an image based on labels in a file.

Parameters
pathstr, optional

path to file to get image from. Use this or suffix. Default: None

suffixstr, optional

suffix to pass to bids_layout.get() to identify the file. Default: None

filtersstr, optional

Additional filters to pass to bids_layout.get() to identify the file. Default: {}

inclusive_labelslist of ints, optional

The labels from the file to include from the boolean image. If None, no inclusive labels are applied.

exclusive_labelslist of ints, optional

The labels from the file to exclude from the boolean image. If None, no exclusive labels are applied. Default: None.

combinestr, optional

How to combine the boolean images generated by inclusive_labels and exclusive_labels. If “and”, they will be and’d together. If “or”, they will be or’d. Note: in this class, you will most likely want to either set inclusive_labels or exclusive_labels, not both, so combine will not matter. Default: “or”

Examples

brain_image_definition = LabelledImageFile(

suffix=”aseg”, filters={“scope”: “dmriprep”}, exclusive_labels=[0])

api.GroupAFQ(brain_image_definition=brain_image_definition)

apply_conditions(image_data_orig, image_file)[source]#
class AFQ.definitions.image.ThresholdedImageFile(path=None, suffix=None, filters={}, lower_bound=None, upper_bound=None, as_percentage=False, combine='and')[source]#

Bases: ImageFile, CombineImageMixin

Define an image based on thresholding a file. Note that this should not be used to directly make a seed image or a stop image. In those cases, consider thresholding after interpolation, as in the example for ImageFile.

Parameters
pathstr, optional

path to file to get image from. Use this or suffix. Default: None

suffixstr, optional

suffix to pass to bids_layout.get() to identify the file. Default: None

filtersstr, optional

Additional filters to pass to bids_layout.get() to identify the file. Default: {}

lower_boundfloat, optional

Lower bound to generate boolean image from data in the file. If None, no lower bound is applied. Default: None.

upper_boundfloat, optional

Upper bound to generate boolean image from data in the file. If None, no upper bound is applied. Default: None.

as_percentagebool, optional

Interpret lower_bound and upper_bound as percentages of the total non-nan voxels in the image to include (between 0 and 100), instead of as a threshold on the values themselves. Default: False

combinestr, optional

How to combine the boolean images generated by lower_bound and upper_bound. If “and”, they will be and’d together. If “or”, they will be or’d. Default: “and”

Examples

brain_image_definition = ThresholdedImageFile(

suffix=”BM”, filters={“scope”:”dmriprep”}, lower_bound=0.1)

api.GroupAFQ(brain_image_definition=brain_image_definition)

apply_conditions(image_data_orig, image_file)[source]#
class AFQ.definitions.image.ScalarImage(scalar)[source]#

Bases: ImageDefinition

Define an image based on a scalar. Does not apply any labels or thresholds; Generates image with floating point data. Useful for seed and stop images, where threshold can be applied after interpolation (see example).

Parameters
scalarstr

Scalar to threshold. Can be one of “dti_fa”, “dti_md”, “dki_fa”, “dki_md”.

Examples

seed_image = ScalarImage(

“dti_fa”)

api.GroupAFQ(tracking_params={

“seed_image”: seed_image, “seed_threshold”: 0.2})

get_name()[source]#
get_image_getter(task_name)[source]#
class AFQ.definitions.image.ThresholdedScalarImage(scalar, lower_bound=None, upper_bound=None, combine='and')[source]#

Bases: ThresholdedImageFile, ScalarImage

Define an image based on thresholding a scalar image. Note that this should not be used to directly make a seed image or a stop image. In those cases, consider thresholding after interpolation, as in the example for ScalarImage.

Parameters
scalarstr

Scalar to threshold. Can be one of “dti_fa”, “dti_md”, “dki_fa”, “dki_md”.

lower_boundfloat, optional

Lower bound to generate boolean image from data in the file. If None, no lower bound is applied. Default: None.

upper_boundfloat, optional

Upper bound to generate boolean image from data in the file. If None, no upper bound is applied. Default: None.

combinestr, optional

How to combine the boolean images generated by lower_bound and upper_bound. If “and”, they will be and’d together. If “or”, they will be or’d. Default: “and”

Examples

seed_image = ThresholdedScalarImage(

“dti_fa”, lower_bound=0.2)

api.GroupAFQ(tracking_params={“seed_image”: seed_image})

class AFQ.definitions.image.TemplateImage(path)[source]#

Bases: ImageDefinition

Define a scalar based on a template. This template will be transformed into subject space before use.

Parameters
pathstr

path to the template.

Examples

my_scalar = TemplateImage(

“path/to/my_scalar_in_MNI.nii.gz”)

api.GroupAFQ(scalars=[“dti_fa”, “dti_md”, my_scalar])

get_name()[source]#
get_image_getter(task_name)[source]#