Skip to content

Commit

Permalink
Rework cli tutorial organisation for brainmapper
Browse files Browse the repository at this point in the history
  • Loading branch information
willGraham01 committed Dec 20, 2023
1 parent d551c41 commit 5ad13ef
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ training/index

```{toctree}
:maxdepth: 1
/tutorials/cellfinder-cli/index
/tutorials/brainmapper/index
```

## Troubleshooting
Expand Down
25 changes: 25 additions & 0 deletions docs/source/tutorials/brainmapper/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Whole brain cell detection and registration with the `brainmapper` command line tool

Although the `brainmapper` command line tool is designed to be easy to install and use, if you're coming to it with fresh eyes, it's not always clear where to start.
We provide an example brain to get you started, and also to illustrate how to play with the parameters to better suit your data.

:::{caution}
**The test dataset is large** $\approx 250$GB.
It is recommended that you try this tutorial out on the fastest machine you have, with the fastest hard drive possible (ideally SSD) and an NVIDIA GPU.
:::

## Tutorial

The tutorial is quite long, and is split into a number of sections.
Please be aware that downloading the data and running `brainmapper` may take a long time (e.g., overnight x2) if you don't have access to a particularly high-powered computer, or fast network connection.

Please go through the following sections in order:

```{toctree}
:maxdepth: 1
setting-up
running-brainmapper
visualising-the-results
exploring-the-numerical-results
visualising-your-data-in-brainrender
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Running cellfinder
# Running `brainmapper`

`cellfinder` runs with a single command, with various arguments that are detailed in [Command line options](/documentation/cellfinder/user-guide/command-line/cli). To analyse the example data, the flags we need are:
`brainmapper` runs with a single command, with various arguments that are detailed in [Command line options](/documentation/brainglobe-workflows/brainmapper/user-guide/command-line/cli).
To analyse the example data, the flags we need are:

- `-s` The primary **s**ignal channel: `test_brain/ch00`.
- `-b` The secondary autofluorescence channel (or **b**ackground): `test_brain/ch01`.
Expand All @@ -16,7 +17,7 @@ If your machine has less than 32GB of RAM, you should use the `allen_mouse_25um`
Putting this all together into a single command gives:

```bash
cellfinder -s test_brain/ch00 -b test_brain/ch01 -o test_brain/output -v 5 2 2 --orientation psl --atlas allen_mouse_10um
brainmapper -s test_brain/ch00 -b test_brain/ch01 -o test_brain/output -v 5 2 2 --orientation psl --atlas allen_mouse_10um
```

This command will take quite a long time (anywhere from 2-10 hours) to run, depending on:
Expand All @@ -26,7 +27,7 @@ This command will take quite a long time (anywhere from 2-10 hours) to run, depe
- The GPU you have

:::{hint}
You'll know `cellfinder` has finished when you see something like this:
You'll know `brainmapper` has finished when you see something like this:
`2020-10-14 00:07:20 AM - INFO - MainProcess main.py:86 - Finished. Total time taken: 3:22:42`
:::

Expand All @@ -36,12 +37,12 @@ If you just want to check that everything is working, we can speed everything up
- Using a lower-resolution atlas, using the flag: `--atlas allen_mouse_25um`

```bash
cellfinder -s test_brain/ch00 -b test_brain/ch01 -o test_brain/output -v 5 2 2 --orientation psl --atlas allen_mouse_25um --start-plane 1500 --end-plane 1550
brainmapper -s test_brain/ch00 -b test_brain/ch01 -o test_brain/output -v 5 2 2 --orientation psl --atlas allen_mouse_25um --start-plane 1500 --end-plane 1550
```

:::{hint}
If the cell classification step takes a (very) long time, it may not be using the GPU.
If you have an NVIDIA GPU, see [Speeding up cellfinder](/documentation/cellfinder/troubleshooting/speed-up) to make sure that your GPU is set up properly.
If you have an NVIDIA GPU, see [Speeding up brainmapper](/documentation/brainglobe-workflows/brainmapper/troubleshooting/speed-up) to make sure that your GPU is set up properly.
:::

Once cellfinder has run, you can go onto [Visualising the results](visualising-the-results).
Once `brainmapper` has run, you can go onto [Visualising the results](visualising-the-results).
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Installation and download

- First install the `cellfinder` command line tool, following the [Installation guide](/documentation/cellfinder/installation).
- First install the `brainmapper` command line tool, following the [Installation guide](/documentation/brainglobe-workflows/installation).
- Download the data from [here](https://gin.g-node.org/cellfinder/data/raw/master/test\_brain\_SK\_AA\_71\_3.zip) (it will take a long time to download). Thanks to [Sepiedeh Keshavarzi](https://www.keshavarzilab.com/) for sharing the data.
- Unzip the data to a directory of your choice (doesn't matter where). You should end up with a directory called `test_brain` with two directories, each containing 2800 images.
- Open a terminal (Linux) or your command prompt (Windows).
Expand All @@ -14,21 +14,21 @@ The test data supplied is purposefully not the "best".
It has a low SNR, and some artefacts such as fluorescent vasculature, and bright spots on the surface of the brain.
In addition, the cell classification network was trained on different data, to give you an idea of "real world" performance.

The aim of this tutorial is not to show `cellfinder` performing perfectly.
The aim of this tutorial is not to show `brainmapper` performing perfectly.
It is instead to illustrate how it deals with less than perfect data, and how to improve the performance.

With all analysis methods, please test it out on your data to see if it works for you, and feel free [to get in touch](/contact).
:::

## Before you start

To run `cellfinder`, you need to know:
To run `brainmapper`, you need to know:

- Where your data is (in this case, it's the path to the `test_brain` directory).
- Which image is the primary signal channel (the one with the labelled cells) and which is the secondary autofluorescence channel. In this case, `test_brain/ch00` is the signal channel and `test_brain/ch01` is the autofluroescence channel.
- Where you want to save the output data (we'll just save it into a directory called `cellfinder_output`in the same directory as the `test_brain`).
- Where you want to save the output data (we'll just save it into a directory called `brainmapper_output` in the same directory as the `test_brain`).
- The pixel sizes of your data in microns (see [Image definition](/documentation/setting-up/image-definition) for details). In this case, our data is 2μm per pixel in the coronal plane and the spacing of each plane is 5μm.
- The orientation of your data. For atlas registration (using [brainreg](/documentation/brainreg/index)) the software needs to know how you acquired your data (coronal, sagittal etc.). For this cellfinder uses [bg-space](/documentation/bg-space/index). Full details on how to enter your data orientation can also be found in the [Image definition](/documentation/setting-up/image-definition) section. For this tutorial, the orientation is `psl`, which means that the data origin is the most **p**osterior, **s**uperior, **l**eft voxel.
- The orientation of your data. For atlas registration (using [brainreg](/documentation/brainreg/index)) the software needs to know how you acquired your data (coronal, sagittal etc.). For this `brainmapper` uses [bg-space](/documentation/bg-space/index). Full details on how to enter your data orientation can also be found in the [Image definition](/documentation/setting-up/image-definition) section. For this tutorial, the orientation is `psl`, which means that the data origin is the most **p**osterior, **s**uperior, **l**eft voxel.
- Which atlas you want to use (you can see which are available by running `brainglobe list`). In this case, we want to use a mouse atlas (as that's what our data is), and we'll use the 10μm version of the [Allen Mouse Brain Atlas](https://mouse.brain-map.org/static/atlas).

Now you're ready to start [Running cellfinder](running-cellfinder).
Now you're ready to start [Running brainmapper](running-brainmapper).
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ description: How to inspect the results in napari

# Visualising the results

`cellfinder` comes with a plugin for [napari](https://napari.org/) for easily visualising the results.
For more information, see [Visualisation](/documentation/cellfinder/user-guide/command-line/visualisation).
`brainmapper` comes with the `cellfinder` package, which includes a plugin for [napari](https://napari.org/) for easily visualising the results.
For more information, see [Visualisation](/documentation/brainglobe-workflows/brainmapper/user-guide/command-line/visualisation).
To quickly view your data:

- Open napari (type `napari` into a command window).
- Into the window then drag and drop:
- The signal channel directory (`test_brain/ch00`),
- The entire cellfinder output directory.
- The entire brainmapper output directory.

![cellfinder results viewed in napari](../images/cellfinder_results.png)
![brainmapper results viewed in napari](../images/brainmapper_results.png)

The napari window then will then be populated with different layers (left-hand side) that can be toggled:

Expand All @@ -23,7 +23,7 @@ The napari window then will then be populated with different layers (left-hand s
- `Non cells` The cell candidates classified as artefacts (blue).
- `Cells` The cell candidates classified as cells (yellow).

If you click on the image above to enlarge, you should get a good idea of how `cellfinder` works:
If you click on the image above to enlarge, you should get a good idea of how `brainmapper` works:

- The coloured regions and the outlines show the segmentation of the brain (following atlas registration).
- The yellow circles show the detected cells (mostly in retrosplenial cortex and thalamus). There are also a few false positives (such as three on the surface of the brain and one outside the brain). This shows that the cell classification network (trained on other brains) is not quite 100%, and should be retrained with the addition of some data from this brain.
Expand All @@ -33,5 +33,5 @@ If you click on the image above to enlarge, you should get a good idea of how `c
To make the results a bit more obvious when zoomed out, the contrast of the raw data (`ch00`) has been adjusted along with changing the symbol for the cells to `disc` and increasing the size.
::

These images are useful to assess how well `cellfinder` performed, but not much use for any kind of numerical analysis.
To see what data is exported from cellfinder, take a look at [Exploring the numerical results](exploring-the-numerical-results).
These images are useful to assess how well `brainmapper` performed, but not much use for any kind of numerical analysis.
To see what data is exported from `brainmapper`, take a look at [Exploring the numerical results](exploring-the-numerical-results).
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Visualising your data in brainrender

<img src="../images/cellfinder_brainrender.webp" alt="3D brainrender visualisation of cellfinder results" width="500" />
<img src="../images/cellfinder_brainrender.webp" alt="3D brainrender visualisation of brainmapper results" width="500" />

To generate 3D figures of your data in atlas space, you can use [brainrender](/documentation/brainrender/index).
cellfinder automatically exports a file in a brainrender compatible format, which can be found at
brainmapper automatically exports a file in a brainrender compatible format, which can be found at
`test_brain/output/points/points.npy`.

Once you've [installed brainrender](/documentation/brainrender/installation), you can try something like this:
Expand Down
30 changes: 8 additions & 22 deletions docs/source/tutorials/cellfinder-cli/index.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
# Whole brain cell detection and registration with the `cellfinder` command line tool
# `cellfinder` CLI has moved to `brainmapper`

Although the `cellfinder` command line tool is designed to be easy to install and use, if you're coming to it with fresh eyes, it's not always clear where to start. We provide an example brain to get you started, and also to illustrate how to play with the parameters to better suit your data.
The `cellfinder` command-line tool was renamed with the release of `cellfinder` version `1.0.0`.
You can read about these changes [on our blog](/blog/version1/cellfinder_migration_live).
What you'll most likely want to do is follow the links in the blog post to:

:::{caution}
**The test dataset is large** \(~250GB\).
It is recommended that you try this tutorial out on the fastest machine you have, with the fastest hard drive possible (ideally SSD) and an NVIDIA GPU.
:::

## Tutorial

The tutorial is quite long, and is split into a number of sections.
Please be aware that downloading the data and running `cellfinder` may take a long time (e.g., overnight x2) if you don't have access to a particularly high-powered computer, or fast network connection.

Please go through the following sections in order:

```{toctree}
:maxdepth: 1
setting-up
running-cellfinder
visualising-the-results
exploring-the-numerical-results
visualising-your-data-in-brainrender
```
- Upgrade your version of the `cellfinder` package,
- Install `brainglobe-workflows` to get `brainmapper`, the same command-line tool but under it's new name.

You can then [head to the `brainmapper` tutorial](../brainmapper/index.md) and follow the steps there.

0 comments on commit 5ad13ef

Please sign in to comment.