Camilo Laiton commited on
Commit
77ffef6
·
1 Parent(s): 0fd5655

updating readme and aind model metadata

Browse files
Files changed (2) hide show
  1. README.md +87 -0
  2. model.json +89 -0
README.md CHANGED
@@ -1,3 +1,90 @@
1
  ---
2
  license: cc-by-4.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: cc-by-4.0
3
  ---
4
+ ---
5
+ license: mit
6
+ language:
7
+ - en
8
+ tags:
9
+ - segmentation
10
+ - microscopy
11
+ - tissue
12
+ ---
13
+ # aind-brain-tissue-segmentation
14
+
15
+ <p align="center">
16
+ <img src="https://allenneuraldynamics.github.io/assets/img/AIND_logo.png" width="400"/>
17
+ <p>
18
+
19
+ <p align="center">
20
+ <a href=""><b>AIND</b></a> &nbsp&nbsp | &nbsp&nbsp 🖥️ <a href="https://github.com/AllenNeuralDynamics/aind-brain-segmentation">GitHub</a> &nbsp&nbsp | &nbsp&nbsp🤗 <a href="https://huggingface.co/AllenInstitute">Hugging Face</a>&nbsp&nbsp | &nbsp&nbsp🤖 <a href="https://www.allenneuraldynamics.org/">Allen Institute for Neural Dynamics</a>&nbsp&nbsp
21
+ <br>
22
+
23
+ -----
24
+
25
+ [**Brain Tissue Segmentation - Lightsheet Microscopy**]() <be>
26
+
27
+ In this repository, we present a tool for fast brain tissue segmentation in lightsheet microscopy. This model was trained in entire 2D slices of data coming from our SmartSPIM Lightsheet Microscopes. We used a downsampled resolution corresponding to 14.4 microns in XY and 16.0 microns in Z that then were resized to 1024x1024.
28
+
29
+ We also provide a script that perform fast inference in entire brains stored in OMEZarr format.
30
+
31
+
32
+ ## Brain Segmentation Examples
33
+
34
+ <a href="https://github.com/user-attachments/assets/1021a3a3-cfa1-460c-b1d7-29746ecf764c">Video Sample 771602</a>
35
+
36
+ <a href="https://github.com/user-attachments/assets/66ec0a36-6798-4081-98e4-b6e744355e99">Video Sample 782499</a>
37
+
38
+ ## 📑 Todo List
39
+ - [ ] Multi-channel segmentation.
40
+ - [ ] Generalization to other microscopes. E.g., (ExASPIM, TissueCyte)
41
+
42
+
43
+ ## Inference
44
+
45
+ It supports two processing modes:
46
+ 1. **Lazy segmentation**: For large datasets that cannot fit into memory, images are resized to **1024x1024**, normalized, segmented, upsampled, and stored in a Zarr format.
47
+ 2. **In-memory segmentation**: For smaller datasets, a multiscale version is loaded into memory for processing.
48
+
49
+ The model was trained with a resolution of **14.4 microns in XY** and **16 microns in Z**.
50
+
51
+ <a href="https://github.com/AllenNeuralDynamics/aind-brain-segmentation/blob/main/code/large_scale_mask_prediction.py">Whole-brain segmentation script</a>
52
+
53
+
54
+ ```
55
+ python large_scale_mask_prediction.py --input_path path/to/your/image.zarr
56
+ ```
57
+
58
+ ## Input Parameters
59
+ | Parameter | Description |
60
+ |-----------|-------------|
61
+ | `image_path` | Path to the OME-Zarr dataset (local or S3). Example: `s3://bucket/SmartSPIM_Dataset/Ex_639_Em_667.zarr` |
62
+ | `model_path` | Path to the trained segmentation model. |
63
+ | `output_folder` | Directory where results will be saved. |
64
+ | `target_size_mb` | Memory allocation target for large-scale predictions. |
65
+ | `n_workers` | Number of workers for PyTorch DataLoader. |
66
+ | `super_chunksize` | Data shard size for optimized cloud communication. |
67
+ | `scale` | Name of the multiscale dataset to use for segmentation. |
68
+ | `scratch_folder` | Path for temporary files (Raw data). |
69
+ | `image_height` | Resize height for segmentation (Default: `1024`). |
70
+ | `image_width` | Resize width for segmentation (Default: `1024`). |
71
+ | `prob_threshold` | Probability threshold for segmentation mask generation. |
72
+
73
+ ## Outputs
74
+ | Output File | Description |
75
+ |-------------|-------------|
76
+ | `probabilities.zarr` | Zarr dataset containing segmentation probabilities (useful for post-processing). |
77
+ | `segmentation_mask.zarr` | Segmentation mask in the original image space (before resizing). |
78
+ | `data.zarr` | Raw input data used for segmentation (optional). |
79
+
80
+ #### Installation
81
+ Clone the repo:
82
+ ```
83
+ git clone https://github.com/AllenNeuralDynamics/aind-brain-segmentation
84
+ cd aind-brain-segmentation
85
+ ```
86
+
87
+ Install dependencies:
88
+ ```
89
+ docker build -t brain_seg -f Dockerfile .
90
+ ```
model.json ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "describedBy": "https://raw.githubusercontent.com/AllenNeuralDynamics/aind-data-schema/main/src/aind_data_schema/core/model.py",
3
+ "schema_version": "0.0.1",
4
+ "name": "smartspim_tissue_segmentation.ckpt",
5
+ "license": "CC-BY-4.0",
6
+ "developer_full_name": [
7
+ "Camilo Laiton"
8
+ ],
9
+ "developer_institution": {
10
+ "name": "Allen Institute for Neural Dynamics",
11
+ "abbreviation": "AIND",
12
+ "registry": {
13
+ "name": "Research Organization Registry",
14
+ "abbreviation": "ROR"
15
+ },
16
+ "registry_identifier": "04szwah67"
17
+ },
18
+ "modality": [
19
+ {
20
+ "name": "Selective plane illumination microscopy",
21
+ "abbreviation": "SPIM"
22
+ }
23
+ ],
24
+ "architecture": {
25
+ "backbone": "UNet",
26
+ "software": [
27
+ {
28
+ "name": "lightning",
29
+ "version": "2.5.0.post0",
30
+ "url": null,
31
+ "parameters": {}
32
+ }
33
+ ],
34
+ "layers": null,
35
+ "parameters": {
36
+ "image_width": 1024,
37
+ "image_height": 1024
38
+ },
39
+ "notes": null
40
+ },
41
+ "intended_use": "2D tissue segmentation from SmartSPIM datasets",
42
+ "limitations": "Only trained on 639 channel using a resolution",
43
+ "pretrained_source_url": null,
44
+ "training": [
45
+ {
46
+ "name": "Model training",
47
+ "software_version": null,
48
+ "start_date_time": "2025-03-01T12:00:00-08:00",
49
+ "end_date_time": "2025-03-01T14:00:00-08:00",
50
+ "input_location": [
51
+ "s3://aind-msma-morphology-data/test_data/SmartSPIM/brain_segmentation_2d_allaxis_channel_639"
52
+ ],
53
+ "output_location": "Path to deployment",
54
+ "code_url": "https://github.com/AllenNeuralDynamics/aind-brain-segmentation",
55
+ "code_version": null,
56
+ "parameters": {
57
+ "learning_rate": 0.00001,
58
+ "batch_size": 32,
59
+ "augmentation": true
60
+ },
61
+ "outputs": {},
62
+ "notes": "Slices were pulled from a multiscaled image (14.4 microns in XY and 16.0 microns in Z) and then resized to 1024x1024",
63
+ "resources": null,
64
+ "train_performance": [
65
+ {
66
+ "name": "dice",
67
+ "value": 0.96
68
+ },
69
+ {
70
+ "name": "jaccard",
71
+ "value": 0.93
72
+ }
73
+ ],
74
+ "test_performance": [
75
+ {
76
+ "name": "precision",
77
+ "value": 0.95
78
+ },
79
+ {
80
+ "name": "recall",
81
+ "value": 0.91
82
+ }
83
+ ],
84
+ "test_data": "4:1 train/test split"
85
+ }
86
+ ],
87
+ "evaluations": [],
88
+ "notes": null
89
+ }