AFQ.definitions.mask

Module Contents

Classes

MaskFile

Define a mask based on a file.

FullMask

Define a mask which covers a full volume.

RoiMask

Define a mask which is all ROIs or'd together.

B0Mask

Define a mask using b0 and dipy's median_otsu.

LabelledMaskFile

Define a mask based on labels in a file.

ThresholdedMaskFile

Define a mask based on thresholding a file.

ScalarMask

Define a mask based on a scalar.

ThresholdedScalarMask

Define a mask based on thresholding a scalar mask.

class AFQ.definitions.mask.MaskFile(suffix, filters={})[source]

Bases: AFQ.definitions.utils.Definition

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

Parameters
suffixstr

suffix to pass to bids_layout.get() to identify the file.

filtersstr

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

Examples

seed_mask = MaskFile(

“WM_mask”, {“scope”:”dmriprep”})

api.AFQ(tracking_params={“seed_mask”: seed_mask,

“seed_threshold”: 0.1})

find_path(self, bids_layout, from_path, subject, session)[source]
get_path_data_affine(self, subses_dict)[source]
apply_conditions(self, mask_data_orig, mask_file)[source]
get_mask_getter(self, in_data=False)[source]
class AFQ.definitions.mask.FullMask[source]

Bases: AFQ.definitions.utils.Definition

Define a mask which covers a full volume.

Examples

brain_mask = FullMask()

find_path(self, bids_layout, from_path, subject, session)[source]
get_mask_getter(self, in_data=False)[source]
class AFQ.definitions.mask.RoiMask(use_presegment=False)[source]

Bases: AFQ.definitions.utils.Definition

Define a mask which is all ROIs or’d together.

Examples

seed_mask = RoiMask() api.AFQ(tracking_params={“seed_mask”: seed_mask})

find_path(self, bids_layout, from_path, subject, session)[source]
get_mask_getter(self, in_data=False)[source]
class AFQ.definitions.mask.B0Mask(median_otsu_kwargs={})[source]

Bases: AFQ.definitions.utils.Definition

Define a mask 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_mask = B0Mask() api.AFQ(brain_mask=brain_mask)

find_path(self, bids_layout, from_path, subject, session)[source]
get_mask_getter(self, in_data=False)[source]
class AFQ.definitions.mask.LabelledMaskFile(suffix, filters={}, inclusive_labels=None, exclusive_labels=None, combine='or')[source]

Bases: MaskFile, CombineMaskMixin

Define a mask based on labels in a file.

Parameters
suffixstr

suffix to pass to bids_layout.get() to identify the file.

filtersstr

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 mask. If None, no inclusive labels are applied.

exclusive_labelslits of ints, optional

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

combinestr, optional

How to combine the boolean masks 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_mask = LabelledMaskFile(

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

api.AFQ(brain_mask=brain_mask)

apply_conditions(self, mask_data_orig, mask_file)[source]
class AFQ.definitions.mask.ThresholdedMaskFile(suffix, filters={}, lower_bound=None, upper_bound=None, combine='and')[source]

Bases: MaskFile, CombineMaskMixin

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

Parameters
suffixstr

suffix to pass to bids_layout.get() to identify the file.

filtersstr

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

lower_boundfloat, optional

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

upper_boundfloat, optional

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

combinestr, optional

How to combine the boolean masks 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_mask = ThresholdedMaskFile(

“brain_mask”, {“scope”:”dmriprep”}, lower_bound=0.1)

api.AFQ(brain_mask=brain_mask)

apply_conditions(self, mask_data_orig, mask_file)[source]
class AFQ.definitions.mask.ScalarMask(scalar)[source]

Bases: AFQ.definitions.utils.Definition

Define a mask based on a scalar. Does not apply any labels or thresholds; Generates mask with floating point data. Useful for seed and stop masks, 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_mask = ScalarMask(

“dti_fa”, scope=”dmriprep”)

api.AFQ(tracking_params={

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

find_path(self, bids_layout, from_path, subject, session)[source]
get_mask_getter(self, in_data=False)[source]
class AFQ.definitions.mask.ThresholdedScalarMask(scalar, lower_bound=None, upper_bound=None, combine='and')[source]

Bases: ThresholdedMaskFile, ScalarMask

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

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 mask from data in the file. If None, no lower bound is applied. Default: None.

upper_boundfloat, optional

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

combinestr, optional

How to combine the boolean masks 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_mask = ThresholdedScalarMask(

“dti_fa”, lower_bound=0.2)

api.AFQ(tracking_params={“seed_mask”: seed_mask})