Package: brainglobe-template-builder
brainglobe-template-builderBuild unbiased anatomical templates from individual imagesOverviewInstallationBackgroundOn templates and atlasesSingle-subject vs population templatesTemplate construction with ANTsLicensePackage blueprintOverviewbrainglobe-template-builderprovides a streamlined process to create unbiased anatomical reference images, or templates, from multiple high-resolution brain images. While primarily designed for brain imaging, its versatility extends to any organ with available 3D digital images, especially those produced by 3D volumetric microscopy like serial two-photon tomography (STPT) and light-sheet microscopy (LSM).brainglobe-template-builderaims to:Offer an intuitive Python interface to theoptimised ANTs template construction pipeline.Support 3D volumetric microscopy images, such as STPT and LSM.Generate templates compatible with theBrainGlobe ecosystem, especially theBrainGlobe Atlas API.WarningEarly development phase. Stay tunedInterface may undergo changes.InstallationWarningANTs, whichwe depend on, is a large package. The installation may take a while.ANTs is only available for Linux and macOS. If you are on Windows, you can useWSLWe recommend installingbrainglobe-template-builderwithin acondaormambaenvironment. Instructions assumecondausage, butmamba/micromambaare interchangeable.Use the providedenvironment.yamlfile to create a new environment.gitclonehttps://github.com/brainglobe/brainglobe-template-buildercdbrainglobe-template-builder
condaenvcreate-fenvironment.yaml-ntemplate-builder
condaactivatetemplate-builderWe have called the environmenttemplate-builder, but you can choose any name you like.To install the latest development version ofbrainglobe-template-builder,pipinstall-e.[dev]For zsh users (default shell on macOS):pipinstall-e'.[dev]'BackgroundOn templates and atlasesIn brain imaging, atemplateserves as a standard reference for brain anatomy, often used interchangeably with the termreference image. By aligning multiple brain images to a common template, researchers can standardize their data, facilitating easier data-sharing, cross-study comparisons, and meta-analyses.Anatlaselevates this concept by annotating a template with regions of interest, often called labels or parcellations. With an atlas, researchers can pinpoint specific brain regions and extract quantitative data from them.The entire process, from registration to data extraction, hinges on the quality of the template image. A high-quality template can significantly improve registration accuracy and the precision of atlas label annotations.The aim ofbrainglobe-template-builderis to assist researchers in constructing such high-quality templates.Single-subject vs population templatesTemplates can be derived in two primary ways. Asingle-subjecttemplate is based on the brain of one individual. While this approach is simpler and may be suitable for some applications, it risks being unrepresentative, as the chosen individual might have unique anatomical features. On the other hand,populationtemplates are constructed by aligning and averaging brain images from multiple subjects. This method captures the anatomical variability present in a population and reduces biases inherent in relying on a single subject. Population templates have become the standard in human MRI studies and are increasingly being adopted for animal brain studies.Template construction with ANTsbrainglobe-template-builderleverages the power ofANTs (Advanced Normalisation Tools), a widely used software suite for image registration and segmentation.ANTs includes a template construction piepline - implemented in theantsMultivariateTemplateConstruction2.shscript - that iteratively aligns and averages multiple images to produce an unbiased population template (seethis issuefor details).Anoptimsed implementation of the above pipeline, developed by theCoBra lab, lies at the core of thebrainglobe-template-builder's functionality.License⚖️BSD 3-ClausePackage blueprintThis package layout and configuration (including pre-commit hooks and GitHub actions) have been copied from thepython-cookiecuttertemplate.