Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move segmentation 1d and 3d to tutorials/ #103

Merged
merged 8 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions docs/source/documentation/brainglobe-segmentation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ Alternatively, the plugin can be installed into a Python environment with `pip i
```{toctree}
:maxdepth: 1
user-guide/index
user-guide/segmenting-1d-tracks
user-guide/segmenting-3d-structures
user-guide/analysing-external-segmentation
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ At this point you could load a layer segmented previously and saved to disk
add the region/points from the layer to the `brainglobe-segmentation` analysis list (in the same way as if it had been
analysed manually within `brainglobe-segmentation`).
- Follow the instructions for either:
- [1D track analysis](segmenting-1d-tracks)
- [2/3D region analysis](segmenting-3d-structures)
- [1D track analysis](../../../tutorials/segmenting-1d-tracks)
- [2/3D region analysis](../../../tutorials/segmenting-3d-structures)

:::{note}
All data will be saved into your brainreg output directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ enhancement, contrast limits (right-click for finer control) and the colormap us
The buttons directly below the layers can be used to rotate the data, reset the view and view in 3D.

For information on how to segment specific types of structure, see:
- [Segmenting 1D tracks](./segmenting-1d-tracks)
- [Segmenting 2/3D structures](segmenting-3d-structures)
- [Segmenting 1D tracks](../../../tutorials/segmenting-1d-tracks)
- [Segmenting 2/3D structures](../../../tutorials/segmenting-3d-structures)
- [Analysing segmentation from other napari plugins](analysing-external-segmentation)

This file was deleted.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions docs/source/tutorials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ Visualise atlas data in napari
:link-type: doc
Registering a whole-brain dataset to an atlas.
:::

:::{grid-item-card} {fas}`brain;sd-text-primary` Track segmentation
:img-bottom: images/brainglobe-segmentation-1d-icon.png
:link: segmenting-1d-tracks
:link-type: doc
Manually segmenting a 1d track.
:::

:::{grid-item-card} {fas}`brain;sd-text-primary` Structure segmentation
:img-bottom: images/brainglobe-segmentation-3d-icon.png
:link: segmenting-3d-structures
:link-type: doc
Manually segmenting a 3d structure
:::
::::

## Specific applications
Expand Down Expand Up @@ -54,6 +68,8 @@ Whole brain cell detection and registration
:hidden:
visualise-atlas-napari
tutorial-whole-brain-registration
segmenting-1d-tracks
segmenting-3d-structures
silicon-probe-tracking
tracing-tracking
cellfinder-cli/index
Expand Down
67 changes: 67 additions & 0 deletions docs/source/tutorials/segmenting-1d-tracks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Segmenting a 1D track

In this tutorial, you will use the [brainglobe-segmentation](../documentation/brainglobe-segmentation/index.md) plugin for [napari](https://napari.org) to segment a 1D track, such as a fibre track, or a silicon probe track. As a prerequisite, you will need to have registered your data to an atlas [using `brainreg`](../documentation/brainreg/index.md) and know what folder you saved this in (your "`brainreg` output directory"). If you don't have this, please follow [our registration tutorial](./tutorial-whole-brain-registration.md) first.

The focus of this tutorial is simply to successfully register a single, straight 1D track. For more information about how to process silicon probe tracks, please see [Silicon probe tracking](/tutorials/silicon-probe-tracking).

:::{note}
You will need `napari` installed on your computer - please follow [`napari`'s installation instructions](https://napari.org/stable/tutorials/fundamentals/installation.html) to do so (including their recommendation to use a `conda` environment).
:::

1. Open `napari`.
2. Install `brainglobe-segmentation` by selecting `Plugins > Install/Uninstall plugins` and searching for `brainglobe-segmentation` in the searchbox. If it is not installed yet, click on the `Install` button.

:::{caution}
On Silicon Macs you may have to run `conda install hdf5` on the command line (in your conda environment) first for the installation to be successful.
:::

3. Open the `brainglobe-segmentation` widget by selecting `Plugins > Region/track segmentation (brainglobe-segmentation)` in the napari menu bar near the top left of the window.
![brainglobe segmentation widget](./images/brainglobe-segmentation/brainglobe-segmentation-open-plugin.png)

**The brainglobe segmentation widget appears on the right-hand side of the window.**

4. Load your registered data in atlas space by clicking on `Load project (atlas space)` and navigating to your `brainreg` output directory.
5. If required, adjust the contrast on the registered image by selecting the `Registered Image` layer on the left of the screen, and clicking on `Autocontrast: once` on the top left of the screen.
6. Select the `Track tracing` button in the `Segmentation` panel.
7. Click the `Add track` button.

![Segmenting a 1D track](./images/brainglobe-segmentation/brainglobe-segmentation-added-new-track.png)
**A new Points layer named `track_0` appears on the left hand side.**

8. If required, rename the track (by selecting the `track_0` text).
9. Navigate in the image to where you want to draw your track.
10. Make sure the add points mode is activated (by selecting the `+` symbol on the top left - find out [more about how to add/delete/select points in napari](https://napari.org/stable/howtos/layers/points.html#adding-deleting-and-selecting-points)).
11. Trace your track by clicking along it. You can add as many, or as few, points as you like, and this can be done in 3D by changing the viewer plane as you go along.

![Segmenting a 1D track](./images/brainglobe-segmentation/brainglobe-segmentation-added-points.png)

**Points appear where you've clicked in the image**

:::{caution}
Make sure you select the points in the order you wish them to be joined.
:::

12. (Optional) If you want to add an additional first point exactly at the surface of the brain, click `Add surface points`. Selecting this option will add an additional point at the closest part of the brain surface (based on the registration) to the first point, so that the track starts there.
13. Join the points using spline interpolation by clicking `Trace tracks`. You can change:
* `Summarise` - Defaults to on, this will save a csv file, showing the brain area for each part of the interpolated track (determined by `Spline points` )
* `Save tracing` - Defaults to off. This will save your segmentation layer at the same time as running the analysis
(this may make your analysis take longer)
* `Fit degree` - What order spline fit to use (the default is 3, cubic)
* `Spline smoothing` - How closely or not to fit the points (lower numbers fit more closely, for a less smooth interpolation)
* `Spline points` - This doesn't affect the interpolation, but determines how many points are sampled from the interpolation (used for the summary)
* `Add surface points` - Selecting this option will add an additional point at the closest part of the brain surface to the first point, so that the track starts there.


![Segmenting a 1D track](./images/brainglobe-segmentation/brainglobe-segmentation-fitted-points.png)
**A new Points layer containing the fitted points named `track_0_fit` appears on the left hand side and in the napari window, and a `.csv` file will be saved, showing the brain region for every spline point along the track.**

:::{note}
All data will be saved into your brainreg output directory
:::

14. (Optional) Use the `Save` button to save your points to be reloaded at a later date.

:::{hint}
For more information about how to use automated methods to segment your feature of interest, please see [Analysing segmentation from other napari plugins](../documentation/brainglobe-segmentation/user-guide/analysing-external-segmentation).
For full information on how to use brainglobe-segmentation, please see the [brainglobe-segmentation page](/documentation/brainglobe-segmentation/index)
:::
55 changes: 55 additions & 0 deletions docs/source/tutorials/segmenting-3d-structures.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Segmenting 2/3D structures

In this tutorial, you will use the [brainglobe-segmentation](../documentation/brainglobe-segmentation/index.md) plugin for [napari](https://napari.org) to segment a a 3D (or 2D) structure, such as an injection site. As a prerequisite, you will need to have registered your data to an atlas [using `brainreg`](../documentation/brainreg/index.md) and know what folder you saved this in (your "`brainreg` output directory"). If you don't have this, please follow [our registration tutorial](./tutorial-whole-brain-registration.md) first.

:::{note}
You will need `napari` installed on your computer - please follow [`napari`'s installation instructions](https://napari.org/stable/tutorials/fundamentals/installation.html) to do so (including their recommendation to use a `conda` environment).
:::

1. Open `napari`.
2. Install `brainglobe-segmentation` by selecting `Plugins > Install/Uninstall plugins` and searching for `brainglobe-segmentation` in the searchbox. If it is not installed yet, click on the `Install` button.

:::{caution}
On Silicon Macs you may have to `conda install hdf5` first for the installation to be successful.
:::

3. Open the `brainglobe-segmentation` widget by selecting `Plugins > Region/track segmentation (brainglobe-segmentation)` in the napari menu bar near the top left of the window.
![The brainglobe-segmentation widget appears](./images/brainglobe-segmentation/brainglobe-segmentation-open-plugin.png)

**The brainglobe segmentation widget appears on the right-hand side of the window.**

4. Load your registered data in atlas space by clicking on `Load project (atlas space)` and navigating to your `brainreg` output directory.
5. If required, adjust the contrast on the registered image by selecting the `Registered Image` layer on the left of the screen, and clicking on `Autocontrast: once` on the top left of the screen.
6. Click the `Region Segmentation` button in the
`Segmentation` panel.
7. Click the `Add new region` button.

![A new Labels layer appears](./images/brainglobe-segmentation/brainglobe-segmentation-added-new-region.png)

**A new Labels layer named `region_0` appears on the left hand side.**

8. If required, rename this region (by selecting the e.g. `region_0` text)
9. Navigate to where you want to draw your region of interest.
10. Choose a brush size (top left box).
11. Make sure painting mode is activated (by selecting the paintbrush icon, top left). You can go back to the navigation mode by selecting the magnifying glass.
12. Colour in your region that you want to segment by holding down the left mouse button, ensuring that you make a solid object. For 3D structures, set `n edit dim` to `3` to paint a sphere instead of a circle, or paint circles across several slices. You can change slice using the slider at the bottom of the screen.

![A brain region is coloured in](./images/brainglobe-segmentation/brainglobe-segmentation-painted-new-region.png)

13. Repeat steps 6.-11. for each other region you would like to segment.
14. Click `Analyse regions` to analyse the spatial distribution of the regions you have drawn.
* If `Calculate volumes` is selected, the volume of each brain area included in the segmented region will be calculated and saved.
* If `Summarise volumes` is selected, then each region will be summarised (centers, volumes etc)
* If `Save segmentation` is selected, then the segmented layer will be saved at the same time as the analysis is run
(this may make your analysis take longer)

15. (Optional) Use the `Save` button to save your segmented regions to be reloaded at a later date.

:::{note}
All data will be saved into your brainreg output directory
:::

:::{hint}
For more information about how to use automated methods to segment your feature of interest, please see [Analysing segmentation from other napari plugins](../documentation/brainglobe-segmentation/user-guide/analysing-external-segmentation).
For full information on how to use brainglobe-segmentation, please see the [brainglobe-segmentation page](/documentation/brainglobe-segmentation/index)
:::
2 changes: 1 addition & 1 deletion docs/source/tutorials/silicon-probe-tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ To open the graphical user interface, open napari and then load the `brainglobe-
[User guide](/documentation/brainglobe-segmentation/user-guide/index)).

The `brainglobe-segmentation`graphical user interface opens and shows a set of tools.You can then load your brainreg output
directory, and follow the main brainglobe-segmentation instructions [here](/documentation/brainglobe-segmentation/user-guide/segmenting-1d-tracks) for
directory, and follow the main brainglobe-segmentation instructions [here](./segmenting-1d-tracks) for
segmenting a 1D track. Setting `Spline points` will determine how many times along the length of the track that
the brain region is sampled at. This can be used to determine the brain region for each recording site on your probe.

Expand Down
2 changes: 1 addition & 1 deletion docs/source/tutorials/tracing-tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ To use Otsu's method from the `napari-simpleitk-image-processing` plugin, follow

- Select the image layer to be thresholded and click `run`. This will automatically segment your image using Otsu's
algorithm. This will create a new labels layer.
- Follow the instructions for [2/3D region analysis](/documentation/brainglobe-segmentation/user-guide/segmenting-3d-structures)
- Follow the instructions for [2/3D region analysis](./segmenting-3d-structures)
to analyse the distribution of the thresholded voxels.

**Instructions by** [**Sara Mederos**](https://www.sainsburywellcome.org/web/people/sara-mederos).
Loading