Skip to content

brainhops.datamodel.enums

Enumerations shared across the data model.

The enumerations cover interpolation orders, boundary conditions, anatomical orientations and the known terms of metadata fields.

Attributes

SimplifyPolicyName module-attribute

SimplifyPolicyName: TypeAlias = Literal[
    "none", "analytic", "numeric"
]

Simplification policy names.

SimplifyPolicyLike module-attribute

SimplifyPolicyLike: TypeAlias = (
    SimplifyPolicy | SimplifyPolicyName
)

Values that can be interpreted as simplification policies.

BoundaryName module-attribute

BoundaryName: TypeAlias = Literal[
    "nearest",
    "edge",
    "border",
    "replicate",
    "reflect",
    "symmetric",
    "dct2",
    "grid-mirror",
    "mirror",
    "dct1",
    "grid-wrap",
    "wrap",
    "circular",
    "circulant",
    "dft",
    "constant",
    "zero",
    "zeros",
    "grid-constant",
    "antimirror",
    "dst1",
    "antireflect",
    "dst2",
]

Acceptable names of boundary conditions, with their aliases.

BoundaryLike module-attribute

Values that can be interpreted as boundary conditions. Constant values imply a constant boundary condition.

StoreName module-attribute

StoreName: TypeAlias = Literal['coefficients', 'values']

Acceptable names of what a transformation field stores.

StoreLike module-attribute

StoreLike: TypeAlias = StoreEnum | StoreName

Values that can be interpreted as what a transformation field stores.

InterpolationName module-attribute

InterpolationName: TypeAlias = Literal[
    "zeroth",
    "nearest",
    "first",
    "linear",
    "second",
    "quadratic",
    "third",
    "cubic",
    "fourth",
    "fifth",
    "sixth",
    "seventh",
    "barycentric",
    "fourier",
]

Interpolation order names.

InterpolationValue module-attribute

InterpolationValue: TypeAlias = Literal[
    -2, -1, 0, 1, 2, 3, 4, 5, 6, 7
]

Interpolation order values.

InterpolationLike module-attribute

Values that can be interpreted as interpolation orders.

AxisTypeName module-attribute

AxisTypeName: TypeAlias = Literal[
    "space",
    "time",
    "channel",
    "displacement",
    "coordinate",
    "point",
    "vector",
    "tensor",
]

Axis type names.

AxisTypeLike module-attribute

AxisTypeLike: TypeAlias = AxisType | AxisTypeName

Values that can be interpreted as axis types.

ValenceName module-attribute

ValenceName: TypeAlias = Literal['vector', 'covector']

Valence names.

ValenceLike module-attribute

ValenceLike: TypeAlias = Valence | ValenceName

Values that can be interpreted as valences.

TensorLayoutName module-attribute

TensorLayoutName: TypeAlias = Literal[
    "C",
    "F",
    "symmetric",
    "symmetric-lower",
    "symmetric-diagonal-first",
    "diagonal",
]

Tensor layout names.

TensorLayoutLike module-attribute

TensorLayoutLike: TypeAlias = (
    TensorLayout | TensorLayoutName
)

Values that can be interpreted as tensor layouts.

ReframeMethodName module-attribute

ReframeMethodName: TypeAlias = Literal[
    "jacobian", "rotation"
]

Reframe method names.

ReframeMethodLike module-attribute

ReframeMethodLike: TypeAlias = (
    ReframeMethod | ReframeMethodName
)

Values that can be interpreted as reframe methods.

OrientationTypeName module-attribute

OrientationTypeName: TypeAlias = Literal['anatomical']

Orientation type names.

OrientationTypeLike module-attribute

OrientationTypeLike: TypeAlias = (
    OrientationType | OrientationTypeName
)

Values that can be interpreted as orientation types.

AnatomicalOrientationName module-attribute

AnatomicalOrientationName: TypeAlias = Literal[
    "left-to-right",
    "right-to-left",
    "proximal-to-distal",
    "distal-to-proximal",
    "anterior-to-posterior",
    "posterior-to-anterior",
    "inferior-to-superior",
    "superior-to-inferior",
    "dorsal-to-palmar",
    "palmar-to-dorsal",
    "dorsal-to-plantar",
    "plantar-to-dorsal",
    "rostral-to-caudal",
    "caudal-to-rostral",
    "cranial-to-caudal",
    "caudal-to-cranial",
    "dorsal-to-ventral",
    "ventral-to-dorsal",
    "superficial-to-deep",
    "deep-to-superficial",
    "apical-to-basal",
    "basal-to-apical",
    "apex-to-base",
    "base-to-apex",
]

Anatomical orientation names.

AnatomicalOrientationLike module-attribute

Values that can be interpreted as anatomical orientations.

SpaceName module-attribute

SpaceName: TypeAlias = Literal[
    "scanner",
    "aligned",
    "talairach",
    "mni",
    "template",
    "ICBM452AirSpace",
    "ICBM452Warp5Space",
    "IXI549Space",
    "MNI152Lin",
    "MNI152NLin2009aAsym",
    "MNI152NLin2009aSym",
    "MNI152NLin2009bAsym",
    "MNI152NLin2009bSym",
    "MNI152NLin2009cAsym",
    "MNI152NLin2009cSym",
    "MNI152NLin6Asym",
    "MNI152NLin6Sym",
    "MNI305",
    "MNIColin27",
    "MNIInfant",
    "MNIPediatricAsym",
    "NMT31Sym",
    "OASIS30AntsOASISAnts",
    "OASIS30Atropos",
    "Talairach",
    "UNCInfant",
    "fsaverage",
    "fsaverage3",
    "fsaverage4",
    "fsaverage5",
    "fsaverage6",
    "fsaveragesym",
    "fsLR",
    "fsnative",
    "orig",
    "anat",
    "T1w",
    "T2w",
    "individual",
    "study",
]

Known world space names.

SpaceLike module-attribute

SpaceLike: TypeAlias = SpaceEnum | SpaceName

Values that can be interpreted as world spaces.

IntentName module-attribute

IntentName: TypeAlias = Literal[
    "correlation",
    "t test",
    "f test",
    "z score",
    "chi2",
    "beta",
    "binomial",
    "gamma",
    "poisson",
    "normal",
    "non central f test",
    "non central chi2",
    "logistic",
    "laplace",
    "uniform",
    "non central t test",
    "weibull",
    "chi",
    "inverse gaussian",
    "extreme value 1",
    "p value",
    "log p value",
    "log10 p value",
    "estimate",
    "label",
    "neuroname",
    "general matrix",
    "symmetric matrix",
    "displacement vector",
    "vector",
    "pointset",
    "triangle",
    "quaternion",
    "dimensionless",
    "time series",
    "node index",
    "rgb vector",
    "rgba vector",
    "shape",
    "fnirt disp field",
    "fnirt cubic spline coef",
    "fnirt dct coef",
    "fnirt quad spline coef",
    "topup field",
]

Known intent names.

IntentLike module-attribute

Values that can be interpreted as intents.

ManufacturerName module-attribute

ManufacturerName: TypeAlias = Literal[
    "Siemens",
    "GE",
    "Philips",
    "Canon",
    "Toshiba",
    "Hitachi",
    "Bruker",
    "UIH",
    "MRSolutions",
]

Known manufacturer names.

ManufacturerLike module-attribute

ManufacturerLike: TypeAlias = (
    Manufacturer | ManufacturerName
)

Values that can be interpreted as manufacturers.

IlluminationName module-attribute

IlluminationName: TypeAlias = Literal[
    "Transmitted",
    "Epifluorescence",
    "Oblique",
    "NonLinear",
    "Other",
]

Known illumination type names.

IlluminationLike module-attribute

IlluminationLike: TypeAlias = (
    IlluminationType | IlluminationName
)

Values that can be interpreted as illumination types.

ContrastMethodName module-attribute

ContrastMethodName: TypeAlias = Literal[
    "Brightfield",
    "Phase",
    "DIC",
    "HoffmanModulation",
    "ObliqueIllumination",
    "PolarizedLight",
    "Darkfield",
    "Fluorescence",
    "Other",
]

Known contrast method names.

ContrastMethodLike module-attribute

ContrastMethodLike: TypeAlias = (
    ContrastMethod | ContrastMethodName
)

Values that can be interpreted as contrast methods.

Classes

SimplifyPolicy

Bases: StrEnum

How far a transformation may be inspected when it is simplified.

  • none: only the declared type is used, and nothing is inspected or rewritten.
  • analytic: the structure is inspected (missing parameters, array shapes, axis lists, the contents of wrappers), but no value is read and no lazy inverse is materialized. Matrix transformations are assumed invertible when square, surjective when wide and injective when tall.
  • numeric: values are read as well, so that zero entries, diagonality, orthogonality and rank can be tested. The rank replaces the assumption based on the shape, so a singular square matrix is not invertible. A lazy inverse is never materialized, because resolving it is the job of the composition mode.

When numeric is given alone, as "numeric" or True, values are read only for matrix transformations, which are the members of the Affine family. Every other transformation, such as a field, is simplified analytically. The mapping {None: "numeric"} extends the reading of values to every transformation.

The members and their values are listed in the following table.

Name Value Description
none "none" Only the declared type is used; nothing is inspected or rewritten.
analytic "analytic" The structure is inspected, but no value is read.
numeric "numeric" Values are read as well, for matrix transformations when alone.

BoundaryCondition

Bases: StrEnum

Boundary conditions for interpolation and resampling.

A boundary condition says how an array continues beyond its edges, which matters wherever an interpolation reads samples outside the array. With splines of degree 2 or more, the condition applies to the spline coefficients, which the prefilter computes so that the spline passes through the values. The following table lists every member with its value, its aliases and the extension that it gives to the values a b c d.

Name Value Aliases Description
nearest "nearest" edge, border, replicate (a a a a | a b c d | d d d d)
reflect "reflect" symmetric, dct2, grid-mirror (d c b a | a b c d | d c b a)
mirror "mirror" dct1 (d c b | a b c d | c b a)
gridwrap "grid-wrap" wrap, circular, circulant, dft (a b c d | a b c d | a b c d)
constant "constant" zero, zeros, grid-constant (0 0 0 0 | a b c d | 0 0 0 0)
antimirror "antimirror" dst1 (-c -b -a 0 | a b c d | 0 -d -c -b)
antireflect "antireflect" dst2 (-d -c -b -a | a b c d | -d -c -b -a)

The names come from SciPy (grid-constant, nearest, mirror, reflect, grid-mirror and grid-wrap), from torch-interpol (zero, replicate, dct1, dct2, dst1, dst2 and dft), and from NumPy, MATLAB and PyTorch (edge, symmetric, circular and border). A name that means different conditions in different libraries keeps the meaning of SciPy, except wrap. The wrap mode of SciPy extends the array periodically with a shift of one sample, which brainhops does not implement, so wrap is the periodic condition, as in NumPy and torch-interpol. The constant mode of SciPy returns the fill value as soon as a coordinate lies beyond the centre of an edge sample, whereas constant here is the grid-constant mode of SciPy, which interpolates the fill value with the samples near the edges.

An alias that contains a hyphen is a member name without its hyphen, such as BoundaryCondition.gridconstant. The text of any alias converts to its member, for example BoundaryCondition("grid-mirror") gives BoundaryCondition.reflect.

StoreEnum

Bases: StrEnum

What the data of a transformation field holds.

The member is given by the store flag of [TransformationField][brainhops.datamodel.transformations.TransformationField].

The following table lists each member with its aliases, its value and what data holds when the member is used.

Name Aliases Value Description
coefficients coeffs "coefficients" data holds spline coefficients, and field decodes them to values.
values "values" data holds the field's values, and field is data itself.

InterpolationOrder

Bases: IntEnum

Interpolation order for interpolation and resampling.

Name Aliases Value Description
zeroth nearest 0 Nearest neighbor interpolation.
first linear 1 Linear interpolation.
second quadratic 2 Quadratic interpolation.
third cubic 3 Cubic interpolation.
fourth 4 Fourth-order interpolation.
fifth 5 Fifth-order interpolation.
sixth 6 Sixth-order interpolation.
seventh 7 Seventh-order interpolation.
barycentric -1 Barycentric interpolation.
fourier -2 Fourier interpolation.

AxisType

Bases: StrEnum

Types of the axes of coordinate systems and transformations.

The last five types describe axes whose entries are the components of a geometric object, such as a vector or a tensor, rather than independent values. displacement behaves as vector and coordinate behaves as point, and both are kept for the transformation fields of OME-NGFF. A covector, such as the gradient of an image, is a vector whose valence is "covector".

Name Value Description
space "space" Spatial axis.
time "time" Temporal axis.
channel "channel" Channel axis.
displacement "displacement" Components of displacements.
coordinate "coordinate" Coordinates of points of a field.
point "point" Coordinates of points.
vector "vector" Components of vectors.
tensor "tensor" Components of tensors.

Valence

Bases: StrEnum

How one index of a vector or a tensor changes with the frame.

When the frame changes by a linear map J, an index of valence vector is multiplied by J and an index of valence covector by J⁻ᵀ. The gradient of an image is a vector of valence covector.

Name Value Description
vector "vector" The index is multiplied by J.
covector "covector" The index is multiplied by J⁻ᵀ.

TensorLayout

Bases: StrEnum

Named layouts of the components of a tensor along an axis.

The order is given for a tensor of rank 2 in a frame of three axes, where ij stands for the component (i, j) (see [TensorAxis][brainhops.datamodel.axes.TensorAxis]).

Name Value Order for k = 2, n = 3 Used by
C "C" 00 01 02 10 11 12 20 21 22
F "F" 00 10 20 01 11 21 02 12 22
symmetric "symmetric" 00 01 02 11 12 22 FSL, ITK, NRRD, Camino
symmetric_lower "symmetric-lower" 00 10 11 20 21 22 DIPY
symmetric_diagonal_first "symmetric-diagonal-first" 00 11 22 01 02 12 MRtrix
diagonal "diagonal" 00 11 22

ReframeMethod

Bases: StrEnum

What is applied to the values of vectors and tensors in a new frame.

J is the Jacobian of the change of frame (see reframe), and J = R P is its polar decomposition, in which R is a rotation and P is symmetric positive definite. Applying J changes the frame exactly, and applying R keeps the length of vectors and the eigenvalues of tensors.

Name Value Description
jacobian "jacobian" Apply J.
rotation "rotation" Apply R.

OrientationType

Bases: StrEnum

Types of orientation, of which only anatomical exists for now.

Name Value Description
anatomical "anatomical" Anatomical orientation.

AnatomicalOrientationValue

Bases: StrEnum

Anatomical orientations of the axes of coordinate systems.

Name Value Description
left_to_right "left-to-right"
right_to_left "right-to-left"
proximal_to_distal "proximal-to-distal"
distal_to_proximal "distal-to-proximal"
anterior_to_posterior "anterior-to-posterior" front-to-back
posterior_to_anterior "posterior-to-anterior" back-to-front
inferior_to_superior "inferior-to-superior" feet-to-head
superior_to_inferior "superior-to-inferior" head-to-feet
dorsal_to_palmar "dorsal-to-palmar" back of hand to palm
palmar_to_dorsal "palmar-to-dorsal" palm to back of hand
dorsal_to_plantar "dorsal-to-plantar" top of foot to sole
plantar_to_dorsal "plantar-to-dorsal" sole to top of foot
rostral_to_caudal "rostral-to-caudal" nose/beak-to-tail, especially for nervous system
caudal_to_rostral "caudal-to-rostral" tail-to-nose/beak, especially for nervous system
cranial_to_caudal "cranial-to-caudal" head-to-tail
caudal_to_cranial "caudal-to-cranial" tail-to-head
dorsal_to_ventral "dorsal-to-ventral" back/top-to-belly/bottom
ventral_to_dorsal "ventral-to-dorsal" belly/bottom-to-back/top
superficial_to_deep "superficial-to-deep" outer surface to inner depth, e.g. skin, gut, cortex
deep_to_superficial "deep-to-superficial" inner depth to outer surface
apical_to_basal "apical-to-basal" apical to basal surface, e.g. epithelial layers, polarized cells
basal_to_apical "basal-to-apical" basal to apical surface
apex_to_base "apex-to-base" tip to broad base, e.g. heart, lungs
base_to_apex "base-to-apex" broad base to tip

SpaceEnum

Bases: StrEnum

Known labels of a world space.

The labels are used by the metadata fields space, input_space and output_space. An unlisted label is kept as a plain string.

The first five members are the names that NIfTI gives to the values of sform_code and qform_code. They are followed by the BIDS standard templates, which BIDS uses for SpatialReference and for the space- entity of file names, and by the non-standard spaces that BIDS defines without a template. Every member is listed in the following table.

Member

Value

Meaning

scanner

"scanner"

NIfTI xform code 1: scanner-based anatomical coordinates

aligned

"aligned"

NIfTI xform code 2: aligned to another file

talairach

"talairach"

NIfTI xform code 3: Talairach-Tournoux atlas

mni

"mni"

NIfTI xform code 4: MNI 152

template

"template"

NIfTI xform code 5: another template

ICBM452AirSpace

"ICBM452AirSpace"

BIDS standard template (volume)

ICBM452Warp5Space

"ICBM452Warp5Space"

BIDS standard template (volume)

IXI549Space

"IXI549Space"

BIDS standard template (volume)

MNI152Lin

"MNI152Lin"

BIDS standard template (volume)

MNI152NLin2009aAsym

"MNI152NLin2009aAsym"

BIDS standard template (volume)

MNI152NLin2009aSym

"MNI152NLin2009aSym"

BIDS standard template (volume)

MNI152NLin2009bAsym

"MNI152NLin2009bAsym"

BIDS standard template (volume)

MNI152NLin2009bSym

"MNI152NLin2009bSym"

BIDS standard template (volume)

MNI152NLin2009cAsym

"MNI152NLin2009cAsym"

BIDS standard template (volume)

MNI152NLin2009cSym

"MNI152NLin2009cSym"

BIDS standard template (volume)

MNI152NLin6Asym

"MNI152NLin6Asym"

BIDS standard template (volume)

MNI152NLin6Sym

"MNI152NLin6Sym"

BIDS standard template (volume)

MNI305

"MNI305"

BIDS standard template (volume)

MNIColin27

"MNIColin27"

BIDS standard template (volume)

MNIInfant

"MNIInfant"

BIDS standard template (volume)

MNIPediatricAsym

"MNIPediatricAsym"

BIDS standard template (volume)

NMT31Sym

"NMT31Sym"

BIDS standard template (volume)

OASIS30AntsOASISAnts

"OASIS30AntsOASISAnts"

BIDS standard template (volume)

OASIS30Atropos

"OASIS30Atropos"

BIDS standard template (volume)

Talairach

"Talairach"

BIDS standard template (volume)

UNCInfant

"UNCInfant"

BIDS standard template (volume)

fsaverage

"fsaverage"

BIDS standard template (surface)

fsaverage3

"fsaverage3"

BIDS standard template (surface)

fsaverage4

"fsaverage4"

BIDS standard template (surface)

fsaverage5

"fsaverage5"

BIDS standard template (surface)

fsaverage6

"fsaverage6"

BIDS standard template (surface)

fsaveragesym

"fsaveragesym"

BIDS standard template (surface)

fsLR

"fsLR"

BIDS standard template (surface)

fsnative

"fsnative"

BIDS standard template (surface)

orig

"orig"

BIDS non-standard space

anat

"anat"

BIDS non-standard space

T1w

"T1w"

BIDS non-standard space

T2w

"T2w"

BIDS non-standard space

individual

"individual"

BIDS non-standard space

study

"study"

BIDS non-standard space

IntentEnum

Bases: StrEnum

Known values of the intent metadata field.

The intent states what the values of an image represent. The members are the NIfTI intent names as nibabel spells them, and each value is the member name with its underscores replaced by spaces. An unlisted intent is kept as a plain string.

NIfTI codes 2 to 24 name statistical distributions, codes 1001 to 2005 name other kinds of values, and the codes from 2006 onwards are specific to FSL. The following table lists every member with its value and its NIfTI code.

Member

Value

NIfTI code

correlation

"correlation"

2

t_test

"t test"

3

f_test

"f test"

4

z_score

"z score"

5

chi2

"chi2"

6

beta

"beta"

7

binomial

"binomial"

8

gamma

"gamma"

9

poisson

"poisson"

10

normal

"normal"

11

non_central_f_test

"non central f test"

12

non_central_chi2

"non central chi2"

13

logistic

"logistic"

14

laplace

"laplace"

15

uniform

"uniform"

16

non_central_t_test

"non central t test"

17

weibull

"weibull"

18

chi

"chi"

19

inverse_gaussian

"inverse gaussian"

20

extreme_value_1

"extreme value 1"

21

p_value

"p value"

22

log_p_value

"log p value"

23

log10_p_value

"log10 p value"

24

estimate

"estimate"

1001

label

"label"

1002

neuroname

"neuroname"

1003

general_matrix

"general matrix"

1004

symmetric_matrix

"symmetric matrix"

1005

displacement_vector

"displacement vector"

1006

vector

"vector"

1007

pointset

"pointset"

1008

triangle

"triangle"

1009

quaternion

"quaternion"

1010

dimensionless

"dimensionless"

1011

time_series

"time series"

2001

node_index

"node index"

2002

rgb_vector

"rgb vector"

2003

rgba_vector

"rgba vector"

2004

shape

"shape"

2005

fnirt_disp_field

"fnirt disp field"

2006

fnirt_cubic_spline_coef

"fnirt cubic spline coef"

2007

fnirt_dct_coef

"fnirt dct coef"

2008

fnirt_quad_spline_coef

"fnirt quad spline coef"

2009

topup_field

"topup field"

2018

Manufacturer

Bases: StrEnum

Known values of the manufacturer metadata field.

The names follow the BIDS Manufacturer field, spelled as converters such as dcm2niix normalise the DICOM Manufacturer tag. Other manufacturers are kept as plain strings.

The members and their values are listed in the following table.

Member

Value

Siemens

"Siemens"

GE

"GE"

Philips

"Philips"

Canon

"Canon"

Toshiba

"Toshiba"

Hitachi

"Hitachi"

Bruker

"Bruker"

UIH

"UIH"

MRSolutions

"MRSolutions"

IlluminationType

Bases: StrEnum

Known values of the illumination_type metadata field.

The members are those of the OME Channel.IlluminationType enumeration. Other values are kept as plain strings.

The members and their values are listed in the following table.

Member

Value

Transmitted

"Transmitted"

Epifluorescence

"Epifluorescence"

Oblique

"Oblique"

NonLinear

"NonLinear"

Other

"Other"

ContrastMethod

Bases: StrEnum

Known values of the contrast_method metadata field.

The members are those of the OME Channel.ContrastMethod enumeration. Other values are kept as plain strings.

The members and their values are listed in the following table.

Member

Value

Brightfield

"Brightfield"

Phase

"Phase"

DIC

"DIC"

HoffmanModulation

"HoffmanModulation"

ObliqueIllumination

"ObliqueIllumination"

PolarizedLight

"PolarizedLight"

Darkfield

"Darkfield"

Fluorescence

"Fluorescence"

Other

"Other"