# Spatial brain maps
Spatial brain maps is a tool for viewing 3D gene expression in the Mouse brain. by fetching registration data shared via EBRAINS and ISH data shared via the Allen Institute, spatial brain maps reconstructs the 3D patterns of gene expression in a standardised coordinate space. Data can be reconstructed as either a 3D volume, or point cloud.
## Usage
There are many ways to interact with this package but the easiest entrypoint is the interactive search hosted at
https://neural-systems-at-uio.github.io/spatial_brain_maps/. This is integrated with the Siibra explorer atlas viewer so you can interactively search for genes which are up or down regulated in any given region, and explore those volumes of gene expression in 3D.
## Installation
```bash
pip install spatial-brain-maps
```
you can view the PyPi package [here](https://pypi.org/project/spatial-brain-maps/)
## Quick CLI Usage
After installation a CLI command `spatial_brain_maps` is available.
### 1. Create a point cloud for an experiment ID.
experiment IDs can be found via the [Allen Institutes mouse brain map portal](https://mouse.brain-map.org).
here we choose a resolution of 25 microns and only show values with an intesity greater than 30 (values are between 0 and 255).
```bash
spatial_brain_maps points --id 71717640 --mode expression --res 25 --cut 30
# Produces: 71717640_expression_cut30.json (MeshView compatible)
```
The above command produces a json file which you can view with [MeshView](https://meshview.apps.ebrains.eu/?atlas=ABA_Mouse_CCFv3_2017_25um)
### 2. Create a point cloud for a gene (aggregate all experiments)
If you wish to aggregate all experiments for a particular gene we can provide --gene instead of --id
```bash
spatial_brain_maps points --gene Adora2a --mode expression --res 25 --cut 30
```
The above command for instance returns a json which when loaded in MeshView looks like this

### 3. Reconstruct a volume for an experiment ID and save to NIfTI
if we instead want a 3D volume we use the volume command like such.
```bash
spatial_brain_maps volume --id 71717640 --mode expression --res 25 --out-nifti outputs/exp71717640
# Produces: outputs/exp71717640.nii.gz
```
This produces a nifti file, which when viewed in software such as ITK Snap looks like this.

Since we didn't choose to interpolate the data there are obvious gaps between the sections, this can be fixed by specifying --interpolate
### 4. Reconstruct an averaged gene expression volume (with interpolation)
in the same way as we are able to aggregate the data for the point clouds we can so again here. For the volumes we are also able to include the interpolate argument which fills the empty space between each section. Be careful as this is quite computationally intensive. If this is taking a long time you can instead choose a lower resolution.
```bash
spatial_brain_maps volume --gene Cnp --mode expression --res 25 --interpolate --out-nifti outputs/Cnp_mean
```
The above command produces this volume.  Since the underlying experiments have each been interpolated before averaging the volume is smooth without obvious gaps.
## Python API Examples
We also provide a Python package which provides the same functionality
### 1. Reconstructing volumes
```python
from spatial_brain_maps import gene_to_volume, write_nifti
# 1. Single experiment volume (returns a numpy array)
vol = gene_to_volume('Adora2a', resolution=25)
# 2. Save a volume to NIfTI
write_nifti(vol, resolution=25, output_path="outputs/exp71717640")
```
This can be used alongside packages such as [brainglobe-atlasapi](https://github.com/brainglobe/brainatlas-api) for plotting and visualisation (see [examples/plot_with_brainglobe.py](examples/plot_with_brainglobe.py))

### 2. Producing point clouds.
## License
Distributed under the terms of the MIT License (see `LICENSE`).
## Acknowledgements
- Allen Institute for Brain Science for raw ISH data, segmentations, and the Common Coordinate Framework.
---
Feel free to open issues or pull requests for feature requests, bug reports, or improvements.
Raw data
{
"_id": null,
"home_page": "https://github.com/Neural-Systems-at-UIO/spatial_brain_maps",
"name": "spatial-brain-maps",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "neuroscience, brain, gene expression, allen brain atlas, neuroinformatics",
"author": "Neural Systems @ UiO",
"author_email": "\"Neural Systems @ UiO\" <harry.carey@medisin.uio.no>",
"download_url": null,
"platform": null,
"description": "\n# Spatial brain maps\n\nSpatial brain maps is a tool for viewing 3D gene expression in the Mouse brain. by fetching registration data shared via EBRAINS and ISH data shared via the Allen Institute, spatial brain maps reconstructs the 3D patterns of gene expression in a standardised coordinate space. Data can be reconstructed as either a 3D volume, or point cloud. \n\n## Usage \nThere are many ways to interact with this package but the easiest entrypoint is the interactive search hosted at \nhttps://neural-systems-at-uio.github.io/spatial_brain_maps/. This is integrated with the Siibra explorer atlas viewer so you can interactively search for genes which are up or down regulated in any given region, and explore those volumes of gene expression in 3D. \n## Installation\n\n```bash\npip install spatial-brain-maps\n```\nyou can view the PyPi package [here](https://pypi.org/project/spatial-brain-maps/) \n\n\n## Quick CLI Usage\n\nAfter installation a CLI command `spatial_brain_maps` is available. \n\n### 1. Create a point cloud for an experiment ID. \nexperiment IDs can be found via the [Allen Institutes mouse brain map portal](https://mouse.brain-map.org). \nhere we choose a resolution of 25 microns and only show values with an intesity greater than 30 (values are between 0 and 255).\n```bash\nspatial_brain_maps points --id 71717640 --mode expression --res 25 --cut 30\n# Produces: 71717640_expression_cut30.json (MeshView compatible)\n```\nThe above command produces a json file which you can view with [MeshView](https://meshview.apps.ebrains.eu/?atlas=ABA_Mouse_CCFv3_2017_25um)\n### 2. Create a point cloud for a gene (aggregate all experiments)\nIf you wish to aggregate all experiments for a particular gene we can provide --gene instead of --id\n```bash\nspatial_brain_maps points --gene Adora2a --mode expression --res 25 --cut 30\n```\nThe above command for instance returns a json which when loaded in MeshView looks like this\n\n### 3. Reconstruct a volume for an experiment ID and save to NIfTI\nif we instead want a 3D volume we use the volume command like such. \n```bash\nspatial_brain_maps volume --id 71717640 --mode expression --res 25 --out-nifti outputs/exp71717640\n# Produces: outputs/exp71717640.nii.gz\n```\nThis produces a nifti file, which when viewed in software such as ITK Snap looks like this.\n\nSince we didn't choose to interpolate the data there are obvious gaps between the sections, this can be fixed by specifying --interpolate\n\n### 4. Reconstruct an averaged gene expression volume (with interpolation)\nin the same way as we are able to aggregate the data for the point clouds we can so again here. For the volumes we are also able to include the interpolate argument which fills the empty space between each section. Be careful as this is quite computationally intensive. If this is taking a long time you can instead choose a lower resolution. \n```bash\nspatial_brain_maps volume --gene Cnp --mode expression --res 25 --interpolate --out-nifti outputs/Cnp_mean\n```\nThe above command produces this volume.  Since the underlying experiments have each been interpolated before averaging the volume is smooth without obvious gaps. \n## Python API Examples\nWe also provide a Python package which provides the same functionality\n### 1. Reconstructing volumes\n\n```python\nfrom spatial_brain_maps import gene_to_volume, write_nifti\n\n# 1. Single experiment volume (returns a numpy array)\nvol = gene_to_volume('Adora2a', resolution=25)\n\n# 2. Save a volume to NIfTI \nwrite_nifti(vol, resolution=25, output_path=\"outputs/exp71717640\")\n```\nThis can be used alongside packages such as [brainglobe-atlasapi](https://github.com/brainglobe/brainatlas-api) for plotting and visualisation (see [examples/plot_with_brainglobe.py](examples/plot_with_brainglobe.py)) \n \n\n### 2. Producing point clouds. \n\n\n## License\n\nDistributed under the terms of the MIT License (see `LICENSE`).\n\n## Acknowledgements\n\n- Allen Institute for Brain Science for raw ISH data, segmentations, and the Common Coordinate Framework.\n\n\n---\n\nFeel free to open issues or pull requests for feature requests, bug reports, or improvements.\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Spatial brain maps: reconstruct 3D mouse brain gene expression volumes and point clouds",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/Neural-Systems-at-UIO/spatial_brain_maps"
},
"split_keywords": [
"neuroscience",
" brain",
" gene expression",
" allen brain atlas",
" neuroinformatics"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "4b5a9070020765a9204c35aaa51418ac67b35d323275f4d7d5a7a65762bdea25",
"md5": "f427e9fd43968d8f71a52c767df4a161",
"sha256": "87616b94fc36d9cd03b9a2ce23ffdd7dfc4f09d8437d5daf843394eeda198934"
},
"downloads": -1,
"filename": "spatial_brain_maps-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f427e9fd43968d8f71a52c767df4a161",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 187349,
"upload_time": "2025-08-15T18:08:44",
"upload_time_iso_8601": "2025-08-15T18:08:44.223788Z",
"url": "https://files.pythonhosted.org/packages/4b/5a/9070020765a9204c35aaa51418ac67b35d323275f4d7d5a7a65762bdea25/spatial_brain_maps-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-15 18:08:44",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Neural-Systems-at-UIO",
"github_project": "spatial_brain_maps",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "spatial-brain-maps"
}