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.

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)[source]#
get_path_data_affine(bids_info)[source]#
apply_conditions(image_data_orig, image_file)[source]#
get_name()[source]#
get_image_getter(task_name)[source]#
get_image_direct(dwi, bids_info, b0_file, data_imap=None)[source]#
class AFQ.definitions.image.FullImage[source]#

Bases: ImageDefinition

Define an image which covers a full volume.

Examples

brain_image_definition = FullImage()

find_path(bids_layout, from_path, subject, session)[source]#
get_name()[source]#
get_image_getter(task_name)[source]#
get_image_direct(dwi, bids_info, b0_file, data_imap=None)[source]#
class AFQ.definitions.image.RoiImage(use_waypoints=True, use_presegment=False, use_endpoints=False)[source]#

Bases: ImageDefinition

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

Parameters
use_presegmentbool

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

use_endpointsbool

Whether to use the endpoints (“start” and “end”) instead of the include ROIs to generate the image.

Examples

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

find_path(bids_layout, from_path, subject, session)[source]#
get_name()[source]#
get_image_getter(task_name)[source]#
get_image_direct(dwi, bids_info, b0_file, data_imap=None)[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)

find_path(bids_layout, from_path, subject, session)[source]#
get_name()[source]#
get_image_getter(task_name)[source]#
get_image_direct(dwi, bids_info, b0_file, data_imap=None)[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, 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.

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})

find_path(bids_layout, from_path, subject, session)[source]#
get_name()[source]#
get_image_getter(task_name)[source]#
get_image_direct(dwi, bids_info, b0_file, data_imap=None)[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])

find_path(bids_layout, from_path, subject, session)[source]#
get_name()[source]#
get_image_getter(task_name)[source]#
get_image_direct(dwi, bids_info, b0_file, data_imap=None)[source]#