Skip to main content

A package to align histology to 3D brain atlases

Project description

DOI PyPI - Version Pepy Total Downloads

Alt DeepSlice is a python library which automatically aligns mouse histology with the allen brain atlas common coordinate framework (and now rat brain histology to the Waxholm rat brain atlas, though this is in beta). The alignments are viewable, and refinable, using the QuickNII software package. DeepSlice requires no preprocessing and works on any stain, however we have found it performs best on brightfield images. At present one limitation is that it only works on Coronally cut sections, we will release an update in the future for sagittal and horizontally cut histology. Alt DeepSlice automates the process of identifying exactly where in the brain a section lies, it can accomodate non-orthogonal cutting planes and will produce an image specific annotation for each section in your brain.

Citation

If you use DeepSlice in your work please cite Carey et al, 2023. It may also be useful if you mention the version you use :)

In addition, you should also remember to cite Wang et al, 2020 if you use the Allen CCFv3 atlas for the Mouse model and Kleven et al, 2023 if you use the Waxholm Atlas of the Sprague Dawley Rat for the Rat model.

Workflow

DeepSlice is fully integrated with the QUINT workflow. Quint helps you register, segment and quantify brain wide datasets!   🐭🧠🔬💻🤖

Web Application

If you would like to use DeepSlice but don't need your own personal installation, check out DeepSlice Flask, a web application which will allow you to upload your dataset and download the aligned results. Some more advanced options are only available in the Python package. The web interface was developed by Michael Pegios.

Installation: How to install DeepSlice

Usage: How to align using DeepSlice

For a jupyter notebook example check out

Happy Aligning :)


Installation

From PIP

This is the easy and recommended way to install DeepSlice, first make sure you have Python 3.11 installed and then simply:
pip install DeepSlice

And you're ready to go! 🚀 Check out the PyPi package here

If you run into any problems create a github issue and I will help you solve it.


Basic Usage

On start

After cloning our repo and navigating into the directory open an ipython session and import our package.

from DeepSlice import DSModel     

Next, specify the species you would like to use and initiate the model.

species = 'mouse' #available species are 'mouse' and 'rat'

Model = DSModel(species)

Important

  • Sections in a folder must all be from the same brain

  • DeepSlice uses all the sections you select to inform its prediction of section angle. Thus it is important that you do not include sections which lie outside of the Allen Brain Atlas. This include extremely rostral olfactory bulb and caudal medulla. If you include these sections in your selected folder it will reduce the quality of all the predictions.

  • If you are not using the web version and would like to include these sections in your alignment, you can now label them as "bad sections" (see below), which will tell DeepSlice not to weight these sections in the propagation.

  • The sections do not need to be in any kind of order.

  • The model downsamples images to 299x299, you do not need to worry about this but be aware that there is no benefit from using higher resolutions.


Predictions

Now your model is ready to use, just direct it towards the folder containing the images you would like to align.

eg:

    
 ├── your_brain_folder
    ├── brain_slice_1.png 
    ├── brain_slice_2.png     
    ├── brain_slice_3.png


To align these images using DeepSlice simply call

folderpath = 'examples/example_brain/GLTa/'
#here you run the model on your folder
#try with and without ensemble to find the model which best works for you
#if you have section numbers included in the filename as _sXXX specify this :)
Model.predict(folderpath, ensemble=True, section_numbers=True)    
#This is an optional stage if you have damaged sections, or hemibrains they may negatively effect the 
#propagation for the entire dataset simply set the bad sections here using a string which is unique to 
#those each section you would like to label as bad. DeepSlice will not include it in the propagation 
#and instead it will infer its position based on neighbouring sections.
Model.set_bad_sections(bad_sections=["_s094", "s199"])
#If you would like to normalise the angles (you should)
Model.propagate_angles()                     
#To reorder your sections according to the section numbers 
Model.enforce_index_order()    
#alternatively if you know the precise spacing (ie; 1, 2, 4, indicates that section 3 has been left out.    
#Furthermore if you know the exact section thickness in microns this can be included instead of None
#if your sections are numbered rostral to caudal you will need to specify a negative section_thickness      
Model.enforce_index_spacing(section_thickness = None)
#now we save which will produce a json file which can be placed in the same directory as your images 
#and then opened with QuickNII. 
Model.save_predictions(folderpath + 'MyResults')                                                                                                             

Acknowledgements

We are grateful to Ann Goodchild for her time-saving blunt assessments of many failed prototypes, for the motivation provided by Dr William Redmond, and especially to Veronica Downs, Freja Warner Van Dijk and Jayme McCutcheon, whose Novice alignments were instrumental to this work. We would like to thank Gergely Csúcs for providing his expertise and many atlasing tools. Work in the authors’ laboratories is supported by the National Health & Medical Research Council of Australia, the Hillcrest Foundation, and Macquarie University (SMcM), and from the European Union’s Horizon 2020 Framework Program for Research and Innovation under the Specific Grant Agreement No. 945539 (Human Brain Project SGA3) and the Research Council of Norway under Grant Agreement No. 269774 (INCF, JGB). We are grateful to Macquarie University for access to their HPC resources, essential for production of early DeepSlice prototypes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deepslice-1.2.8.tar.gz (28.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deepslice-1.2.8-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file deepslice-1.2.8.tar.gz.

File metadata

  • Download URL: deepslice-1.2.8.tar.gz
  • Upload date:
  • Size: 28.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for deepslice-1.2.8.tar.gz
Algorithm Hash digest
SHA256 35fd51d5edc8326a37fa7fc0bf0fc467e06201fa813a3375993198b5b2048680
MD5 8995952148b59bd4d2d0ed941bcbc924
BLAKE2b-256 a25b5783da4cf10a6ab795128edeff1f10760bf3571b7c67dc904a99739eb354

See more details on using hashes here.

File details

Details for the file deepslice-1.2.8-py3-none-any.whl.

File metadata

  • Download URL: deepslice-1.2.8-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for deepslice-1.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 6e962dd0d4ce8c3ba081fd053cdec1533f3556b3224de67b6b80df38d45a16ce
MD5 0f7f8f84fb89665a13d5c5d3bf620ca8
BLAKE2b-256 dcc91720d847d830162982890ade7cb37b85b74c411b6e718f9bd979c1d98567

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page