brainmapper cell transformation widget#

Details#

The brainmapper widget allows the full brainmapper workflow to be run within napari, i.e.:

  1. Detect cells using cellfinder

  2. Register the brain to the atlas using brainreg

  3. Transform cells to the atlas and assign each one to an atlas region using this widget

Hint

To get started, it may be helpful to follow the analysing brainwide distribution of cells tutorial.

How to install#

The widget is part of brainglobe-utils. It can be installed in three ways:

Hint

If you’re not sure, we recommend installing the metapackage

How to use#

Prerequisites#

Before you use this widget you need three things:

  1. Your raw image data

  2. The brainreg output directory, generated by registering your raw data to a BrainGlobe atlas

  3. Some points defined in the raw data space, e.g. cells detected by cellfinder.

Hint

This widget will support any points that can be loaded into napari. Many file formats (e.g. the BrainGlobe xml format, or a csv from BiaPy) can be loaded by dragging and dropping them onto the napari window.

Using the widget#

  1. Load the raw data into napari

  2. Load the points data into napari

  3. Open the brainmapper widget by selecting Plugins > brainmapper (BrainGlobe)

  4. Select the Points layer and Raw data layer

  5. Click Transform points and when prompted, select your brainreg output directory

Results#

Transformed points#

This widget will produce two new layers:

  • Points in downsampled space - this is the points layer, but each point is transformed to the same space as the downsampled.tiff image generated by brainreg. This is the same coordinate space as the raw data, but resampled and realigned to match the atlas. This is saved for completeness, but likely is not needed for most analyses.

  • Points in atlas space - this is the points layer, but each point is transformed to the atlas space. Importantly, this is defined at the resolution of the atlas. These points may need to be scaled up to micron space (i.e. by multiplying the coordinates by the resolution) to visualise in tools such as brainrender (see below).

These layers can be saved to disk with any appropriate napari plugin, such as brainglobe-napari-io.

To export your transformed points for visualisation in brainrender, click the Export to brainrender button, and choose a filename (ending in .npy). This file can be visualised in brainrender by following the visualising your data in brainrender tutorial.

Numerical results#

Points summary#

Each cell will be assigned an atlas region, and a summary of these results will be displayed within the widget:

structure_name

left_cell_count

right_cell_count

Retrosplenial area, ventral part, layer 5

1853

814

Lateral dorsal nucleus of thalamus

1541

0

Retrosplenial area, ventral part, layer 2/3

163

686

Retrosplenial area, dorsal part, layer 5

561

82

Retrosplenial area, dorsal part, layer 2/3

194

245

Ventral anterior-lateral complex of the thalamus

412

0

Example of the results displayed within napari after running the widget

The full summary results can be saved to csv by clicking the Save points summary button and choosing a filename:

structure_name

left_cell_count

right_cell_count

total_cells

left_volume_mm3

right_volume_mm3

total_volume_mm3

left_cells_per_mm3

right_cells_per_mm3

Retrosplenial area, ventral part, layer 5

1853

814

2667

0.952479

0.966508

1.918987

1945.44971595174

842.207203665153

Lateral dorsal nucleus of thalamus

1541

0

1541

0.597768

0.534717

1.132485

2577.92320766585

0

Retrosplenial area, ventral part, layer 2/3

163

686

849

0.57638

0.614387

1.190767

282.79954196884

1116.56008346531

Retrosplenial area, dorsal part, layer 5

561

82

643

0.611487

0.644904

1.256391

917.435693645163

127.150707702232

Retrosplenial area, dorsal part, layer 2/3

194

245

439

0.460668

0.492384

0.953052

421.127579949117

497.579125235589

Ventral anterior-lateral complex of the thalamus

412

0

412

0.397422

0.365181

0.762603

1036.6814116984

0

Example of full point summary results that can be saved to disk

All point information#

The details of every single point can be saved to csv by clicking on the Save all points information button and choosing a filename:

coordinate_raw_axis_0

coordinate_raw_axis_1

coordinate_raw_axis_2

coordinate_atlas_axis_0

coordinate_atlas_axis_1

coordinate_atlas_axis_2

structure_name

hemisphere

20

2441

1674

1208

348

586

arbor vitae

left

120

2810

2194

1154

444

690

Medulla

left

122

1891

1634

1169

363

460

Fastigial nucleus

right

183

2528

3363

1121

723

663

Medulla

left

187

2763

2158

1122

437

679

Medial vestibular nucleus

left

200

3150

1661

1128

313

733

arbor vitae

left

Example of the individual point data that can be saved to disk