iblatlas.flatmaps

Techniques to project the brain volume onto 2D images for visualisation purposes.

Functions

circles

param N:

number of circles

swanson

A rasterized rendition of the Swanson projection of the mouse brain, which is a 2D representation of the mouse brain.

swanson_json

Vectorized version of the swanson bitmap file.

Classes

FlatMap

class FlatMap(flatmap='dorsal_cortex', res_um=25)[source]

Bases: AllenAtlas

plot_flatmap(depth=0, volume='annotation', mapping='Allen', region_values=None, ax=None, **kwargs)[source]

Displays the 2D image corresponding to the flatmap.

If there are several depths, by default it will display the first one.

Parameters:
  • depth (int) – Index of the depth to display in the flatmap volume (the last dimension).

  • volume ({'image', 'annotation', 'boundary', 'value'}) –

    • ‘image’ - Allen image volume.

    • ’annotation’ - Allen annotation volume.

    • ’boundary’ - outline of boundaries between all regions.

    • ’volume’ - custom volume, must pass in volume of shape BrainAtlas.image.shape as

      regions_value argument.

  • mapping (str, default='Allen') – The brain region mapping to use.

  • region_values (numpy.array) – An array the shape of the brain atlas image containing custom region values. Used when volume value is ‘volume’.

  • ax (matplotlib.pyplot.Axes, optional) – A set of axes to plot to.

  • **kwargs – See matplotlib.pyplot.imshow.

Returns:

The plotted image axes.

Return type:

matplotlib.pyplot.Axes

extent_flmap()[source]

Returns the boundary coordinates of the flat map.

Returns:

The bounding coordinates of the flat map image, specified as (left, right, bottom, top).

Return type:

numpy.array

circles(N=5, atlas=None, display='flat')[source]
Parameters:
  • N – number of circles

  • atlas – brain atlas at 25 m

  • display – “flat” or “pyramid”

Returns:

2D map of indices, ap_coordinate, ml_coordinate

swanson(filename='swanson2allen.npz')[source]

A rasterized rendition of the Swanson projection of the mouse brain, which is a 2D representation of the mouse brain. Each pixel in the image corresponds to a region index in the Allen CCFv2 annotation volume. [1] J. D. Hahn et al., “An open access mouse brain flatmap and upgraded rat and human brain flatmaps based on current reference atlases,” J Comp Neurol, vol. 529, no. 3, pp. 576–594, Feb. 2021, doi: 10.1002/cne.24966.

Parameters:

filename

swanson_json(filename='swansonpaths.json', remap=True)[source]

Vectorized version of the swanson bitmap file. The vectorized version was generated from swanson() using matlab contour to find the paths for each region. The paths for each region were then simplified using the Ramer Douglas Peucker algorithm https://rdp.readthedocs.io/en/latest/

Parameters:
  • filename

  • remap