From ca6465296a5e3f336b8563704aec28fffc32a6be Mon Sep 17 00:00:00 2001 From: laynholt Date: Fri, 9 May 2025 21:38:47 +0000 Subject: [PATCH] added references --- README.md | 23 ++++++++++++++++++++++- core/segmentator.py | 9 +++++++++ core/utils/measures.py | 5 ++--- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b2e5c1c..9e391b0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Cell Segmentator +--- + ## Overview This repository provides two main scripts to configure and run a cell segmentation workflow: @@ -7,6 +9,8 @@ This repository provides two main scripts to configure and run a cell segmentati * **generate\_config.py**: Interactive script to create JSON configuration files for training or prediction. * **main.py**: Entry point to train, test, or predict using the generated configuration. +--- + ## Installation 0. **Install uv**: @@ -40,6 +44,8 @@ Follow the official guide at [https://docs.astral.sh/uv/](https://docs.astral.sh uv sync ``` +--- + ## Dataset Structure Your data directory must follow this hierarchy: @@ -75,6 +81,8 @@ In this case, set the `masks_subdir` field in your dataset configuration to the **Mask format**: Instance masks should be provided for multi-label segmentation with channel-last ordering, i.e., each mask array must have shape `(H, W, C)`. +--- + ## generate\_config.py This script guides you through creating a JSON configuration for either training or prediction. @@ -101,6 +109,8 @@ Generated config includes sections: * `wandb_config`: Weights & Biases integration settings * *(If training)* `criterion`, `optimizer`, `scheduler` +--- + ## main.py Entrypoint to run training, testing, or prediction using a config file. @@ -125,6 +135,8 @@ python main.py [-c CONFIG] [-m {train,test,predict}] [--no-save-masks] [--only-m 5. **Run** training or inference (`.run()`). 6. **Save** model checkpoint and upload to W\&B if in training mode. +--- + ## Configurable Parameters A brief overview of the key parameters you can adjust in your JSON config: @@ -155,6 +167,8 @@ A brief overview of the key parameters you can adjust in your JSON config: > **Batch size note:** Validation, testing, and prediction runs always use a batch size of `1`, regardless of the `batch_size` setting in the training configuration. +--- + ## Examples ### Generate a training config @@ -177,4 +191,11 @@ python main.py -c config/templates/train/YourConfig.json -m train python main.py -c config/templates/predict/YourConfig.json -m predict ``` ---- \ No newline at end of file +--- + +## Acknowledgments + +This project was developed building upon the following open-source repositories: + +* [Cellpose](https://github.com/MouseLand/cellpose) by the MouseLand Lab. +* [MEDIAR](https://github.com/Lee-Gihun/MEDIAR) by Lee Gihun. diff --git a/core/segmentator.py b/core/segmentator.py index 52e3575..a93f20b 100644 --- a/core/segmentator.py +++ b/core/segmentator.py @@ -1,3 +1,12 @@ +""" +This code is adapted from the following codes: +[1] https://github.com/MouseLand/cellpose/blob/main/cellpose/utils.py +[2] https://github.com/MouseLand/cellpose/blob/main/cellpose/dynamics.py +[3] https://github.com/MouseLand/cellpose/blob/main/cellpose/metrics.py +[4] https://github.com/Lee-Gihun/MEDIAR/tree/main/core +[5] https://github.com/Lee-Gihun/MEDIAR/tree/main/core/MEDIAR +""" + import random import numpy as np from numba import njit, prange diff --git a/core/utils/measures.py b/core/utils/measures.py index ffe1fba..c628a0c 100644 --- a/core/utils/measures.py +++ b/core/utils/measures.py @@ -1,7 +1,6 @@ """ -Adapted from: -[1] https://github.com/JunMa11/NeurIPS-CellSeg/blob/main/baseline/compute_metric.py -[2] https://github.com/stardist/stardist/blob/master/stardist/matching.py +This code is adapted from the following codes: +[1] https://github.com/Lee-Gihun/MEDIAR/blob/main/train_tools/measures.py """ import numpy as np