neuralib.atlas.view

neuralib.atlas.view.load_slice_view(view, plane_type, *, resolution=10, check_latest=True)[source]

Load the mouse brain slice view

Parameters:
  • view (Literal['annotation', 'reference']) – VIEW_TYPE.

  • plane_type (Literal['coronal', 'sagittal', 'transverse']) – PLANE_TYPE. {‘coronal’, ‘sagittal’, ‘transverse’}

  • resolution (int) – Volume resolution in um. default is 10 um

  • check_latest (bool) – If True, check the latest version of brain

Returns:

AbstractSliceView

Return type:

AbstractSliceView

class neuralib.atlas.view.AbstractSliceView[source]

SliceView ABC for different plane type

Dimension parameters:

AP = anterior-posterior

DV = dorsal-ventral

ML = medial-lateral

W = view width

H = view height

REFERENCE_FROM: ClassVar[str] = ''

reference from which axis

static __new__(cls, view_type, plane, resolution, reference)[source]
Parameters:
  • view_type (Literal['annotation', 'reference'])

  • plane (Literal['coronal', 'sagittal', 'transverse'])

  • resolution (int)

  • reference (ndarray)

__init__(view_type, plane, resolution, reference)[source]
Parameters:
  • view_type (Literal['annotation', 'reference']) – DATA_SOURCE_TYPE. {‘ccf_annotation’, ‘ccf_template’, ‘allensdk_annotation’}

  • plane (Literal['coronal', 'sagittal', 'transverse']) – PLANE_TYPE`. {‘coronal’, ‘sagittal’, ‘transverse’}

  • resolution (int) – um/pixel

  • reference (ndarray) – Array[uint16, [AP, DV, ML]]

view_type: Final[Literal['annotation', 'reference']]

VIEW_TYPE. {‘annotation’, ‘reference’}

plane_type: Final[Literal['coronal', 'sagittal', 'transverse']]

PLANE_TYPE`. {‘coronal’, ‘sagittal’, ‘transverse’}

resolution: Final[int]

um/pixel

reference: Final[ndarray]

Array[float, [AP, DV, ML]]

grid_y: Final[ndarray]

Array[int, [W, H]]

grid_x: Final[ndarray]

Array[int, [W, H]]

property bregma: ndarray
property n_ap: int

number of slices along AP axis

property n_dv: int

number of slices along DV axis

property n_ml: int

number of slices along ML axis

abstract property n_planes: int

number of planes in a specific plane view

abstract property width: int

width (pixel) in a specific plane view

abstract property height: int

height (pixel) in a specific plane view

property width_mm: float

width (um) in a specific plane view

property height_mm: float

height (um) in a specific plane view

abstract property reference_point: int

reference point in a specific plane view. aka, bregma plane index

abstract property project_index: tuple[int, int, int]

plane(p), x, y of index order in (AP, DV, ML)

Returns:

(p, x, y)

abstract property max_projection_axis: tuple[int, int, int]
plot_max_projection(ax, *, annotation_regions=None, annotation_cmap='hsv')[source]

Plot max projection for the given plane_type

Parameters:
  • ax (Axes) – Axes

  • annotation_regions (str | list[str] | None) – annotation_regions

  • annotation_cmap (str) – camp for the annotation regions, defaults to ‘hsv’

plane_at(slice_index)[source]
Parameters:

slice_index (int)

Return type:

SlicePlane

offset(h, v)[source]
Parameters:
  • h (int) – horizontal plane diff to the center. right side positive.

  • v (int) – vertical plane diff to the center. bottom side positive.

Returns:

(H, W) array

Return type:

ndarray

plane(offset)[source]

Get image plane.

Parameters:

offset (int | tuple[int, int, int] | ndarray) – Array[int, height, width] or tuple (plane, dh, dv)

Returns:

Return type:

ndarray

coor_on(plane, o)[source]

map slice point (x, y) at plane plane back to volume point (ap, dv, ml)

Parameters:
  • plane (ndarray) – plane number of array

  • o (tuple[ndarray, ndarray]) – tuple of (x, y)

Returns:

(ap, dv, ml)

Return type:

tuple[ndarray, …]

class neuralib.atlas.view.SlicePlane[source]

2D Wrapper for a specific plane

slice_index: int

anchor index

ax: int

anchor x

ay: int

anchor y

__init__(slice_index, ax, ay, dw, dh, slice_view, unit='a.u.')

Method generated by attrs for class SlicePlane.

Parameters:
  • slice_index (int)

  • ax (int)

  • ay (int)

  • dw (int)

  • dh (int)

  • slice_view (AbstractSliceView)

  • unit (str)

Return type:

None

dw: int

dw in um

dh: int

dh in um

slice_view: AbstractSliceView

AbstractSliceView

unit: str
property image: ndarray
property plane_offset: ndarray
property reference_value: float

relative to reference point

with_offset(dw, dh, debug=False)[source]
Parameters:
  • dw (int)

  • dh (int)

  • debug (bool)

Return type:

Self

with_angle_offset(deg_x=0, deg_y=0)[source]

with degree offset

Parameters:
  • deg_x (float) – degree in x axis (width)

  • deg_y (float) – degree in y axis (height)

Returns:

Return type:

Self

plot(ax=None, to_um=True, annotation_region=None, boundaries=False, with_title=False, affine_transform=False, customized_trans=False, extent=None, annotation_cmap='berlin', rescale=True, **kwargs)[source]
Parameters:
  • ax (Axes | None) – The Axes object on which to plot. If None, a new figure and axes are created.

  • to_um (bool) – A boolean flag indicating whether the coordinates should be converted to micrometers. Defaults to True. Only applicable if extent is None.

  • annotation_region (str | list[str] | None) – The annotation region on which to plot. Defaults to None.

  • boundaries (bool) – A boolean indicating whether to include annotations in the plot.

  • with_title (bool) – A boolean indicating whether to include a title in the plot.

  • affine_transform (bool) – A boolean indicating whether to apply an affine transformation to the plot.

  • customized_trans (bool) – A boolean indicating whether to use a customized affine transformation.

  • extent (tuple[float, float, float, float] | None) – A tuple defining the image boundaries (left, right, bottom, top). If None, boundaries are computed internally.

  • annotation_cmap (str) – Cmap for the annotation regions if specified

  • rescale (bool) – Rescale the image when view_type is annotation.

  • kwargs – Additional keyword arguments passed to ax.imshow().

Return type:

None