|
1 | | -# AI4LIfe_OC_StaphInTissue |
2 | | -Repo for the AI4Life Open Call 3 project that we are solving internally. This repo is meant to keep track of the code internally |
| 1 | +# Project #19: Segmentation of sparse bacteria in human tissue |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This repository contains the code and notebooks for preparing ground truth data for training, training a 3D Stardist model, and then use it on unseen data for **Sparse bacteria segmentation in tissue samples**. |
| 8 | +The project implements deep learning approaches for automated detection and segmentation of bacterial cells in complex tissue environments using 3D microscopy data. |
| 9 | +Developed as part of the [AI4Life project](https://ai4life.eurobioimaging.eu), it uses data provided by ***. |
| 10 | +All images used in this tutorial are licensed under **CC-BY**. If any of the instructions are not working, please [open an issue] |
| 11 | + |
| 12 | + |
| 13 | +## 🎯 Objective |
| 14 | + |
| 15 | +The main goal is to develop robust AI models for: |
| 16 | +- Automated segmentation of *Staphylococcus aureus* bacteria in tissue samples |
| 17 | +- 3D cell detection and counting in microscopy images |
| 18 | +- Quality control and validation of segmentation results |
| 19 | + |
| 20 | +## 📁 Repository Structure |
| 21 | + |
| 22 | +``` |
| 23 | +AI4LIfe_OC_StaphInTissue/ |
| 24 | +├── notebooks/ |
| 25 | +│ ├── 0_dataset_split_train_test.ipynb # Dataset preparation and splitting |
| 26 | +│ ├── 0.1_Label_watershed.ipynb # Watershed-based labeling |
| 27 | +│ ├── 0.2_train_dataset_normalize_crop.ipynb # Data preprocessing |
| 28 | +│ ├── StarDist_3D_DL4MicEverywhere_Modified_AI4LifeOC.ipynb # Main StarDist 3D notebook for training and inference |
| 29 | +│ └── data_identifier.csv # Dataset metadata |
| 30 | +├── env_requirements.txt # Python dependencies |
| 31 | +├── LICENSE # MIT License |
| 32 | +└── README.md # This file |
| 33 | +``` |
| 34 | + |
| 35 | +## 🚀 Getting Started |
| 36 | + |
| 37 | +### Prerequisites |
| 38 | + |
| 39 | +- CUDA-compatible GPU (recommended for training) |
| 40 | +- Sufficient RAM for 3D image processing |
| 41 | +- [DL4MicEverywhere](https://github.com/HenriquesLab/DL4MicEverywhere) |
| 42 | + |
| 43 | +### Installation |
| 44 | + |
| 45 | +1. Follow the [DL4MicEverywhere](https://github.com/HenriquesLab/DL4MicEverywhere) installation instructions and load the Stardist 3D ZeroCostDL4Mic environment. |
| 46 | + |
| 47 | +2. In the Jupyter notebook interface, clone this repository: |
| 48 | +```bash |
| 49 | +git clone https://github.com/ai4life-opencalls/****.git |
| 50 | +``` |
| 51 | + |
| 52 | +## 📊 Workflow |
| 53 | + |
| 54 | +The project follows a structured workflow for bacterial segmentation: |
| 55 | + |
| 56 | +### 1. Data Preparation (`0_dataset_split_train_test.ipynb`) |
| 57 | +- Cross-reference of images with metadata |
| 58 | +- Generate summary of available data |
| 59 | +- Allows for informed dataset splitting into training and testing sets by the user |
| 60 | + |
| 61 | +### 2. Label Refinement (`0.1_Label_watershed.ipynb`) |
| 62 | +- Handling of touching/overlapping bacteria labeled together |
| 63 | +- Application of watershed algorithm for improved instance labeling |
| 64 | + |
| 65 | +### 3. Data Preprocessing (`0.2_train_dataset_normalize_crop.ipynb`) |
| 66 | +- Image normalization and cropping |
| 67 | +- Preparation of training dataset for StarDist 3D model |
| 68 | +- Reduction of empty background regions to optimize training efficiency |
| 69 | + |
| 70 | +### 4. Model Training (`StarDist_3D_DL4MicEverywhere_Modified_AI4LifeOC.ipynb`) |
| 71 | +- StarDist 3D model implementation |
| 72 | +- Custom modifications for large image handling |
| 73 | +- Training and validation procedures |
| 74 | +- Model evaluation and quality control |
| 75 | + |
| 76 | +## 🔬 Methodology |
| 77 | + |
| 78 | +The project utilizes **StarDist 3D**, a state-of-the-art deep learning approach for: |
| 79 | +- Star-convex object detection in 3D microscopy images |
| 80 | +- Accurate segmentation of spherical bacterial cells |
| 81 | +- Instance segmentation for overlapping objects |
| 82 | + |
| 83 | +### Key Features: |
| 84 | +- **3D segmentation**: Full volumetric processing of microscopy stacks |
| 85 | +- **Quality control**: Comprehensive validation metrics (IoU, precision, recall) |
| 86 | +- **Visualization**: Interactive tools for result inspection |
| 87 | +- **Scalability**: Tiled processing for large images |
| 88 | + |
| 89 | +## 📈 Results |
| 90 | + |
| 91 | +The model provides: |
| 92 | +- Segmentation masks for individual bacteria |
| 93 | +- Quality metrics and validation reports |
| 94 | +- Interactive visualization of results |
| 95 | + |
| 96 | +## 🛠️ Usage |
| 97 | + |
| 98 | +### Training a New Model |
| 99 | + |
| 100 | +1. If multiple image sets have the same source prepare a metadata file like `data_identifier.csv` |
| 101 | +2. Run the data preparation notebooks in sequence: |
| 102 | + ``` |
| 103 | + notebooks/0_dataset_split_train_test.ipynb |
| 104 | + notebooks/0.1_Label_watershed.ipynb |
| 105 | + notebooks/0.2_train_dataset_normalize_crop.ipynb |
| 106 | + ``` |
| 107 | +3. Train the StarDist model: |
| 108 | + ``` |
| 109 | + notebooks/StarDist_3D_DL4MicEverywhere_Modified_AI4LifeOC.ipynb |
| 110 | + ``` |
| 111 | + |
| 112 | +### Inference on New Data |
| 113 | + |
| 114 | +Use the trained model section in the main notebook to process new images. |
| 115 | + |
| 116 | +## 📚 References |
| 117 | + |
| 118 | +- Schmidt, U., et al. "Cell detection with star-convex polygons." MICCAI 2018. |
| 119 | +- Weigert, M., et al. "Star-convex polyhedra for 3d object detection and segmentation in microscopy." WACV 2020. |
| 120 | +- von Chamier, L., et al. "Democratising deep learning for microscopy with ZeroCostDL4Mic." Nature Communications 2021. |
| 121 | + |
| 122 | +## Acknowledgements |
| 123 | +AI4Life has received funding from the European Union’s Horizon Europe research and innovation programme under grant agreement number 101057970. Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or the European Research Council Executive Agency. Neither the European Union nor the granting authority can be held responsible for them. |
0 commit comments