Skip to main content

Braintracer

Braintracer is a processing pipeline extension for the BrainGlobe API. It enables high-throughput processing with cellfinder, quantifies cell positions and produces figures for visualising cell distributions across datasets.

NOTE:
Braintracer has been tested on Windows 10 Enterprise (22H2) only. It should also work on macOS and Linux using bt.sh instead of bt.bat, although the shell script has not been maintained recently. Python 3.11 is required.


Installation

First, install Anaconda or Miniconda on your machine.
Open Anaconda Prompt.
Create a Python environment and install braintracer:
conda create -n env_name python=3.11.13
conda activate env_name
pip install braintracer

View your downloaded BrainGlobe atlases with brainglobe list
Install the 10um Allen mouse brain atlas: brainglobe install -a allen_mouse_10um

Add your data into your working directory as follows:

├── WorkingDirectory
│   ├── bt.bat
│   ├── bt_visualiser.ipynb
│   ├── DatasetName1
│   |   ├── SignalChannelName
│   |   |   ├── section_001_01
│   |   |   ├── section_001_02
│   |   ├── BackgroundChannelName
│   ├── DatasetName2

bt.bat and bt_visualiser.py must be copied into the working directory.
On Windows, these files are found here:
Users/USERNAME/miniconda3/envs/ENV_NAME/Lib/site-packages/braintracer/braintracer

It is also recommended to install CUDA for usage of the GPU in cellfinder:
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
Then confirm the GPU is detected by tensorflow:
python
import tensorflow as tf
tf.config.list_physical_devices('GPU')

To generate the braintracer directory structure inside WorkingDirectory:
• Open Anaconda Prompt
• Activate your environment: conda activate env_name
• Navigate to WorkingDirectory
• Run the braintracer pre-processing tool: bt.bat (or sh bt.sh on macOS/Linux - not maintained)
• The tool can then be closed - the directories are generated immediately


Usage

braintracer has two main workflows - pre-processing and visualisation.

Pre-processing

• Open Anaconda Prompt
• Activate your environment: conda activate env_name
• Navigate to WorkingDirectory
• Run the braintracer pre-processing tool: bt.bat (or sh bt.sh on macOS/Linux - not maintained)
• Follow the instructions in the terminal

If you already have a .csv from cellfinder containing cell coordinates, follow the above steps but answer y when asked Do results already exist ready for copying?

Visualisation

• Open Anaconda Prompt
• Activate your environment: conda activate env_name
• Navigate to WorkingDirectory
• Open Jupyter with jupyter-lab
• In the browser tab that appears, open bt_visualiser.ipynb
• Play with your results and save figures all within Jupyter Notebook!


Sample data

If you don't have access to any raw data, you can use the sample data provided.
Move the sample data files into the WorkingDirectory\braintracer\cellfinder\ directory.
You should then be able to explore this data with the bt_visualiser.ipynb notebook with jupyter notebook or jupyter-lab


Measure performance with ground truth

To assess the classifier's performance, you will need to generate ground truth data.
Braintracer requires ground truth coordinates in atlas space, so these should be generated in napari with the cellfinder curation plugin.
• Open napari with napari
• Navigate to dataset\\cellfinder_[]\\registration
• Load the signal channel downsampled_standard_channel_0 and background channel downsampled_standard
• Open the cellfinder curation plugin and select these layers as the signal and background channels
• Click 'Add training data layers' and select some cells in the cells layer!
• Select both cell layers and go to File... Save selected layer(s)
• Save the file in the following format: groundtruth_[].xml (you must type .xml!) within braintracer\\ground_truth


Generate training data to improve the classifier

The classifier requires some feedback to be improved, or retrained.
You can generate training data easily in napari. • Open napari with napari
• Drag the dataset\\cellfinder_[] folder onto the napari workspace
• Drag the folders containing your signal and background channels
• Move the signal and background channel layers down to the bottom of the layer manager (with signal channel above the background!)
• Make the atlas layer (allen_mouse_10um) visible and decrease the opacity to reveal areas during curation
• Go to Plugins > cellfinder > Curation
• Set the signal and background image fields to your signal and background layers
• Click Add training data layers
• Select the layer you are interested in (Cells to mark false positives; Non cells for false negatives)
• Select the magnifying glass to move the FOV such that the entire area to be curated is visible but cell markers can still large enough
• You are then able to select the arrow icon to make markers selectable and not have to switch back and forth between the two tools
• Begin curation from the caudal end (towards slice #0) and work your way through each slice, switching between the Cells and Non cells layers depending on the type of false label
• Depending on the strategy, either review all cells (even confirming correct classifications by selecting Mark as cell(s) for the Cells layer or Mark as non cell(s) for the Non cells layer) or only the subset of cells that appear to be classified incorrectly
• When finished, click Save training data and select the output folder
• The plugin will create a file called training.yml and folders called cells and non_cells containing the TIFFs that the classifier will be shown
• Additionally, select both training data layers and go to File... Save selected layer(s)
• Save the file as name.xml (you must type .xml!)
The YML file can then be used to retrain the network.

Metadata

Release files for braintracer 0.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for braintracer 0.4.2
File Size Uploaded Provenance Actions
braintracer-0.4.2.tar.gz 5.8 MB Without provenance Details for braintracer-0.4.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for braintracer 0.4.2
File Interpreter ABI Platform Actions
braintracer-0.4.2-py3-none-any.whl Python 3 none any Details for braintracer-0.4.2-py3-none-any.whl

Total release size: 11.6 MB

Release files / braintracer-0.4.2.tar.gz

Download URL braintracer-0.4.2.tar.gz
Size 5.8 MB
Tags Source
SHA-256 checksum
How to use checksums
6084e1fa2185310b797a3ae70fae88c1a5d81717a631cd277c6454fcd9bca381
BLAKE2b-256 checksum
How to use checksums
c16993ef39e9c7592d19361a0e2fcda969ce6396187c5358be40fe6f25754709
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / braintracer-0.4.2-py3-none-any.whl

Download URL braintracer-0.4.2-py3-none-any.whl
Size 5.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
efe8eb336ac1cff50d77d4ed4109f86de32bd6837713fbefe1a6a75633a80dcb
BLAKE2b-256 checksum
How to use checksums
adec81714242f11c3e8c4e5499ae87927c7290d6529201c2a23ed5cac3af28a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Security for braintracer 0.4.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page