Skip to content

Commit 1653188

Browse files
Merge branch 'main' into win-ci
2 parents f6853d5 + 20cc7b1 commit 1653188

30 files changed

+699
-82
lines changed

.github/workflows/build_docs.yaml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ jobs:
2525
- name: Set up Micromamba
2626
uses: mamba-org/setup-micromamba@v2
2727
with:
28-
micromamba-version: "latest" # Use the latest version of micromamba
29-
environment-file: environment_cpu.yaml # Reference your environment.yml file
28+
micromamba-version: "latest"
29+
environment-file: environment.yaml
3030
init-shell: bash
3131
cache-environment: true
3232
post-cleanup: 'all'
33-
# cache: true # Cache the micromamba environment
3433

3534
- name: Install package
3635
shell: bash -l {0}
@@ -50,7 +49,6 @@ jobs:
5049
- name: Upload Documentation Artifact
5150
uses: actions/upload-pages-artifact@v3
5251
with:
53-
# name: documentation
5452
path: doc/
5553

5654
deploy:
@@ -64,14 +62,5 @@ jobs:
6462
name: github-pages
6563
url: ${{ steps.deployment.outputs.page_url }}
6664
steps:
67-
# - name: Download Documentation Artifact
68-
# uses: actions/download-artifact@v4
69-
# with:
70-
# name: documentation
71-
# path: .
72-
7365
- name: Deploy to GiHub Pages
7466
uses: actions/deploy-pages@v4
75-
# with:
76-
# artifact_name: documentation
77-

.github/workflows/run_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Setup micromamba
2828
uses: mamba-org/setup-micromamba@v1
2929
with:
30-
environment-file: environment_cpu.yaml
30+
environment-file: ${{ runner.os == 'Windows' && 'environment_cpu_win.yaml' || 'environment.yaml' }}
3131
create-args: >-
3232
python=${{ matrix.python-version }}
3333

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ scripts/cooper/training/copy_testset.py
1212
scripts/rizzoli/upsample_data.py
1313
scripts/cooper/training/find_rec_testset.py
1414
synapse-net-models/
15+
scripts/portal/upscale_tomo.py

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
SynapseNet is a tool for segmentation and analysis of synapses in electron microscopy.
44

5-
To learn how to use SynapseNet, check out [the documentation](https://computational-cell-analytics.github.io/synapse-net/).
5+
To learn how to use SynapseNet, check out [the documentation](https://computational-cell-analytics.github.io/synapse-net/) and [the tutorial video](https://youtu.be/7n8Oq1uAByE).
66
To learn more about how it works, check out [our preprint](https://www.biorxiv.org/content/10.1101/2024.12.02.626387v1).
77

88
See an example reconstruction of a mossy fibre synapse with SynapseNet.

doc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
video/

doc/start_page.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ It provides deep neural networks for:
1010

1111
It also offers functionality for quantifying synaptic ultrastructure based on segmentation results, for example by measuring vesicle or structure morphology, measuring distances between vesicles and structures, or assigning vesicles into different pools.
1212
SynapseNet mainly targets electron tomography, but can also be appled to other types of electron microscopy,
13-
especially throught the [domain adaptation](domain-adaptation) functionality.
13+
especially throught the [domain adaptation](#domain-adaptation) functionality.
1414

15-
SynapseNet offers a [napari plugin](napari-plugin), [command line interface](command-line-interface), and [python library](python-library).
15+
SynapseNet offers a [napari plugin](#napari-plugin), [command line interface](#command-line-interface), and [python library](#python-library).
1616
Please cite our [bioRxiv preprint](https://www.biorxiv.org/content/10.1101/2024.12.02.626387v1) if you use it in your research.
1717

1818

1919
## Requirements & Installation
2020

21-
SynapseNet was developed and tested on Linux. It should be possible to install and use it on Mac or Windows, but we have not tested this.
21+
SynapseNet was developed and tested on Linux. It is possible to install and use it on Mac or Windows, but we have not extensively tested this.
2222
Furthermore, SynapseNet requires a GPU for segmentation of 3D volumes.
2323

2424
You need a [conda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html) or [mamba](https://mamba.readthedocs.io/en/latest/installation/mamba-installation.html) installation. Follow the instruction at the respective links if you have installed neither. We assume you have `conda` for the rest of the instructions. After installing it, you can use the `conda` command.
@@ -36,6 +36,7 @@ cd synapse-net
3636
```bash
3737
conda env create -f environment.yaml
3838
```
39+
If you are using Windows then you have to use a different environment file for the installation: Use `environment_gpu_win.yaml` if you have a GPU and `environment_cpu_win.yaml` without a GPU.
3940
- You will need to confirm this step. It will take a while. Afterwards you can activate the environment:
4041
```bash
4142
conda activate synapse-net
@@ -72,6 +73,8 @@ We currently offer seven different models for segmenting synaptic structures:
7273

7374
## Napari Plugin
7475

76+
You can find a video tutorial for the SynapseNet napari plugin [on YouTube](https://youtu.be/7n8Oq1uAByE). Below, we explain the different plugin components with screenshots.
77+
7578
After installing SynapseNet you can start napari by activating the `synapse-net` environment (or another environment you installed it in) and executing the `napari` command.
7679
Once napari is opened, you can load a tomogram (or other image data), by drag'n'dropping the corresponding mrc file onto the napari window.
7780

@@ -110,7 +113,7 @@ The screenshot below shows a grouping of vesicles into 'close' (red) and 'far' (
110113
In addition, the `Segmentation Postprocessing` widget can be used to filter out objects that do not overlap with a mask, e.g. a synaptic compartment, or to intersect a segmentation with the boundaries of a mask.
111114

112115

113-
## Command Line Functionality
116+
## Command Line Interface
114117

115118
SynapseNet provides a command line interface to segment synaptic structures in mrc files (or other image formats), and to export segmentation results to IMOD.
116119

@@ -161,3 +164,10 @@ Domain adaptation is implemented in `synapse_net.training.domain_adaptation`. Yo
161164

162165
We also provide functionality for 'regular' neural network training. In this case, you have to provide data **and** manual annotations for the structure(s) you want to segment.
163166
This functionality is implemented in `synapse_net.training.supervised_training`. You can find an example script that shows how to use it [here](https://github.com/computational-cell-analytics/synapse-net/blob/main/examples/network_training.py).
167+
168+
## Segmentation for the CryoET Data Portal
169+
170+
We have published segmentation results for tomograms of synapses stored in the [CryoET Data Portal](https://cryoetdataportal.czscience.com/). So far we have made the following depositions:
171+
- [CZCDP-10330](https://cryoetdataportal.czscience.com/depositions/10330): Contains synaptic vesicle segmentations for over 50 tomograms of synaptosomes. The segmentations were made with a model domain adapted to the synaptosome tomograms.
172+
173+
The scripts for the submissions can be found in [scripts/cryo/cryo-et-portal](https://github.com/computational-cell-analytics/synapse-net/tree/main/scripts/cryo/cryo-et-portal).

environment.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
channels:
2-
- pytorch
3-
- nvidia
42
- conda-forge
53
name:
64
synapse-net
@@ -13,10 +11,10 @@ dependencies:
1311
- pyqt
1412
- python-elf
1513
- pytorch
16-
- pytorch-cuda=12.4
1714
- tensorboard
1815
- torch_em
1916
- torchvision
2017
- trimesh
18+
- zarr < 3
2119
- pip:
2220
- napari-skimage-regionprops

environment_cpu.yaml renamed to environment_cpu_win.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@ channels:
44
name:
55
synapse-net
66
dependencies:
7+
- cpuonly
78
- bioimageio.core
89
- cpuonly
910
- kornia
11+
# This pin is necessary because later nifty versions have import errors on windows.
12+
- nifty =1.2.1=*_4
1013
- magicgui
1114
- napari
15+
- protobuf <5
1216
- pip
1317
- pyqt
1418
- python-elf
1519
- pytorch
20+
- torchvision
1621
- tensorboard
1722
- torch_em
1823
- trimesh

environment_gpu_win.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
channels:
2+
- pytorch
3+
- nvidia
4+
- conda-forge
5+
name:
6+
synapse-net
7+
dependencies:
8+
- bioimageio.core
9+
- kornia
10+
# This pin is necessary because later nifty versions have import errors on windows.
11+
- nifty =1.2.1=*_4
12+
- magicgui
13+
- napari
14+
- protobuf <5
15+
- pip
16+
- pyqt
17+
- python-elf
18+
- pytorch
19+
- pytorch-cuda>=11.7 # you may need to update the cuda version to match your system
20+
- torchvision
21+
- tensorboard
22+
- torch_em
23+
- trimesh
24+
- pip:
25+
- napari-skimage-regionprops

examples/analysis_pipeline.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import os
2+
3+
import imageio.v3 as imageio
14
import napari
25
import pandas as pd
36
import numpy as np
@@ -128,6 +131,13 @@ def save_analysis(segmentations, vesicle_attributes, save_path):
128131
vesicle_attributes.to_excel(save_path, index=False)
129132

130133

134+
def save_segmentations(segmentations):
135+
output_folder = "segmentations"
136+
os.makedirs(output_folder, exist_ok=True)
137+
for name, segmentation in segmentations.items():
138+
imageio.imwrite(os.path.join(output_folder, f"{name}.tif"), segmentation, compression="zlib")
139+
140+
131141
def main():
132142
"""This script implements an example analysis pipeline with SynapseNet and applies it to a tomogram.
133143
Here, we analyze docked and non-attached vesicles in a sample tomogram."""
@@ -150,7 +160,11 @@ def main():
150160
vesicle_attributes = assign_vesicle_pools(vesicle_attributes)
151161

152162
# Visualize the results.
153-
visualize_results(tomogram, segmentations, vesicle_attributes)
163+
# visualize_results(tomogram, segmentations, vesicle_attributes)
164+
165+
# Save the segmentation results to tif files so that they can be re-used later.
166+
# They will be saved to the folder 'segmentations'.
167+
save_segmentations(segmentations)
154168

155169
# Compute the vesicle radii and combine and save all measurements.
156170
save_path = "analysis_results.xlsx"

0 commit comments

Comments
 (0)