Package: brainreg
brainregbrainreg is an update toamap(which is itself a port
of theoriginal Java software) to include multiple registration backends, and to support the many atlases provided bybrainglobe-atlasapi.
It also comes with an optionalnapari pluginif you'd rather use brainreg with through graphical interface.Documentation for both the command-line tool and graphical interface can be foundhere.
If you have any issues, please get in touchon the forum,on Zulip, or byraising an issue.For segmentation of bulk structures in 3D space (e.g. injection sites, Neuropixels probes), please seebrainglobe-segmentation.DetailsThe aim of brainreg is to register the template brain (e.g. from theAllen Reference Atlas) to the sample image.
Once this is complete, any other image in the template space can be aligned with the sample (such as region annotations, for segmentation of the sample image).
The template to sample transformation can also be inverted, allowing sample images to be aligned in a common coordinate space.To do this, the template and sample images are filtered, and then registered in a three step process (reorientation, affine registration, and freeform registration).
The resulting transform from template to standard space is then applied to the atlas.Full details of the process are in theoriginal aMAP paper.InstallationTo install both the command line tool and the napari plugin, runpipinstallbrainreg[napari]in your desired Python environment.
To only install the command line tool with no GUI (e.g. to run brainreg on an HPC cluster), just run:pipinstallbrainregInstalling on macOSIf you are using macOS, please runcondainstall-cconda-forgeniftyregin your environment before installing, to ensure all dependencies are installed.Command line usageBasic usagebrainreg/path/to/raw/data/path/to/output/directory-v522--orientationpslFull command-line arguments are available withbrainreg -h, but pleaseget in touchif you have any questions.Mandatory argumentsPath to the directory of the images. This can also be a text file pointing to the files.Output directory for all intermediate and final results.You must also specify the voxel sizes with the-vflag, seespecifying voxel sizefor details.AtlasBy default, brainreg will use the 25um version of theAllen Mouse Brain Atlas.
To use another atlas (e.g. for another species, or another resolution), you must use the--atlasflag, followed by the string describing the atlas, e.g.:--atlasallen_mouse_50umTo find out which atlases are available, once brainreg is installed, please runbrainglobe list.
The name of the resulting atlases is the string to pass with the--atlasflag.Input data orientationIf your data does not match the BrainGlobe default orientation (the origin voxel is the most anterior, superior, left-most voxel), then you must specify the orientation by using the--orientationflag.
What follows must be a string in thebrainglobe-space"initials" form, to describe the origin voxel.If the origin of your data (first, top left voxel) is the most anterior, superior, left part of the brain, then the orientation string would be "asl" (anterior, superior, left), and you would use:--orientationaslRegistration optionsTo change how the actual registration performs, seeregistration parametersAdditional options-aor--additionalPaths to N additional channels to downsample to the same coordinate space.--sort-input-fileIf set to true, the input text file will be sorted using natural sorting. This means that the file paths will be sorted as would be expected by a human and not purely alphabetically.--brain_geometryCan be one offull(default) for full brain registration,hemisphere_lfor left hemisphere data-set andhemisphere_rfor right hemisphere data-set.Misc options--n-free-cpusThe number of CPU cores on the machine to leave unused by the program to spare resources.--debugDebug mode. Will increase verbosity of logging and save all intermediate files for diagnosis of software issues.--save-original-orientationOption to save the registered atlas with the same orientation as the input data.Visualising resultsIf you have installed the optionalnapariplugin, you can use napari to view your data.
The plugin automatically fetches thebrainglobe-napari-iowhich provides this functionality.
If you have installed only the command-line tool you can still manually installbrainglobe-napari-ioand follow the steps below.Sample spaceOpen napari and drag your brainreg output directory (the one with the log file) onto the napari window.Various images should then open, including:Registered image- the image used for registration, downsampled to atlas resolutionatlas_name- e.g.allen_mouse_25umthe atlas labels, warped to your sample brainBoundaries- the boundaries of the atlas regionsIf you downsampled additional channels, these will also be loaded.
Most of these images will not be visible by default - click the little eye icon to toggle visibility.Note:If you use a high resolution atlas (such asallen_mouse_10um), then the files can take a little while to load.ContributingContributions to brainreg are more than welcome.
Please see thedevelopers guide.Citing brainregIf you find brainreg useful, and use it in your research, please let us know and also cite the paper:Tyson, A. L., Vélez-Fort, M.,  Rousseau, C. V., Cossell, L., Tsitoura, C., Lenzi, S. C., Obenhaus, H. A., Claudi, F., Branco, T.,  Margrie, T. W. (2022). Accurate determination of marker location within whole-brain microscopy images. Scientific Reports, 12, 867doi.org/10.1038/s41598-021-04676-9Please also cite aMAP (the original pipeline from which this software is based):Niedworok, C.J., Brown, A.P.Y., Jorge Cardoso, M., Osten, P., Ourselin, S., Modat, M. and Margrie, T.W., (2016). AMAP is a validated pipeline for registration and segmentation of high-resolution mouse brain data. Nature Communications. 7, 1–9.https://doi.org/10.1038/ncomms11879Lastly, if you can, please cite the BrainGlobe Atlas API that provided the atlas:Claudi, F., Petrucco, L., Tyson, A. L., Branco, T., Margrie, T. W. and Portugues, R. (2020). BrainGlobe Atlas API: a common interface for neuroanatomical atlases. Journal of Open Source Software, 5(54), 2668,https://doi.org/10.21105/joss.02668Finally,don't forget to cite the developers of the atlas that you used (e.g. the Allen Brain Atlas)!