Resources API
get_default_landmarks(shape=None)
Get default landmark coordinates.
Parameters:
-
shape(tuple[int, int], default:None) –Shape of the scaled template the landmarks should be given in, as (height, width). Defaults to the shipped atlas shape.
Returns:
-
dict(dict) –Default landmark coordinates, as {name: (x, y)}.
Source code in src/mesoscopy/resources/__init__.py
get_atlas(shape=None)
Get the left and right hemisphere atlas label maps.
Parameters:
-
shape(tuple[int, int], default:None) –Shape to resample the atlas to, as (height, width). Labels are resampled nearest-neighbour, so no new region ids are introduced. Defaults to the shipped atlas shape.
Returns:
-
tuple[ndarray, ndarray]–tuple[np.ndarray, np.ndarray]: Left and right hemisphere label maps. The right map is the mirror image of the left.
Source code in src/mesoscopy/resources/__init__.py
atlas_shape()
Get the shape of the shipped atlas.
Returns:
-
tuple[int, int]–tuple[int, int]: The atlas shape, as (height, width).
template_shape(scale)
Get the shape of the atlas scaled by a uniform factor, as (height, width).
Parameters:
-
scale(float) –Scale factor relative to the shipped atlas.
Returns:
-
tuple[int, int]–tuple[int, int]: The scaled shape, rounded to whole pixels.
Raises:
-
ValueError–If the scale is not positive.
Source code in src/mesoscopy/resources/__init__.py
template_scale(shape)
Get the per-axis scale of a template shape relative to the shipped atlas.
Parameters:
-
shape(tuple[int, int]) –Template shape, as (height, width).
Returns:
-
tuple[float, float]–tuple[float, float]: Scale factors as (x, y), i.e. (width, height), matching the landmark coordinate convention.
Source code in src/mesoscopy/resources/__init__.py
scale_landmarks(landmarks, scale)
Scale landmark coordinates to a resampled image.
Pixel centres sit at integer coordinates, so a coordinate is shifted by half a pixel before and
after scaling. This keeps a landmark over the same pixel as resize_labels and the image
midline in place at any scale.
Parameters:
-
landmarks(dict) –Landmarks as {name: (x, y)}.
-
scale(tuple[float, float]) –Scale factors as (x, y).
Returns:
-
dict(dict) –The scaled landmarks, in the same order.
Source code in src/mesoscopy/resources/__init__.py
resize_labels(labels, shape)
Resample a label map to a new shape by nearest neighbour.
Each output pixel takes the label under its centre in the input, so no new labels are created.
Parameters:
-
labels(ndarray) –2D label map.
-
shape(tuple[int, int]) –Output shape, as (height, width).
Returns:
-
ndarray–np.ndarray: The resampled label map, with the same dtype as the input.
Raises:
-
ValueError–If the shape is not two positive integers.