Instance segmentation of membranes
Project description
morphodeep
[](https://github.com/Gitlab /morphodeep/raw/main/LICENSE)
[](https://github.com/Gitlab /morphodeep/actions)
[](https://codecov.io/gh/Gitlab /morphodeep)
MorphoDeep
MorphoDeep is a Python package for performing membrane instance segmentation using a pre-trained U-Net model based on the Semantic format.
It produces a dense labels image where each unique integer corresponds to a segmented cell instance.
It also includes a napari plugin
The plugin is designed for:
- fluorescence images of cell membranes
- 2D and 3D volumes (with optional isotropic rescaling)
- interactive use in napari or scripted use in Python
Key features
- Pre-trained U-Net for 2D / pseudo-3D membrane instance segmentation
- Napari widget with:
- image layer selection
- network patch size (
128or256) - 2D / 3D mode
- optional tiling (“patches mode”) for large images
- voxel size and Z-axis selection
- optional isotropic rescaling for anisotropic volumes
- Automatic model download and caching on first use
Installation
Setup your environnement
conda create -y -n morphodeep-env python=3.10
conda activate morphodeep-env
You can install morphodeep via ffpip:
pip install morphodeep
Installation with napari
Setup your environnement
conda create -y -n napari-env -c conda-forge python=3.11
conda activate napari-env
You can install morphodeep plugin with napari and Qt via:
pip install "napari[all]"
pip install "morphodeep[napari]"
MorphoDeep library Usage
You have 3 way to use the morphodeep library:
- with a command line :
python morphodeep.py <args> - directly inside the python code using the semantic library:
MorphoModel(args) - directly in napari with the morphodeep plugin
Arguments
JOBS (run the command line in a job )
--job: Launch the corresponding job--exe: Execute the method ( ground_truth ... )--path_jobs: path job output--job_number: Launch a sepecif job in job array list--job_filename: The file of the job array list
ACTION
--train: Launch the training--predict: Launch the prediction--ground_truth: Generate all the ground truth--setdata: Generate the data list files used for train/test/predict--export: Compute the testing set and plot the results in figures--evolution: Evaluation the testing set throught the different epochs--export_evol: Predict for each epochs--eval: Evaluation of training database--plot: Compute export and plot loss--plot_loss: Plot the loss and accuracy
METHOD
-mode: 2D or 3D--img_size: image size--full: Use a several layers to complete a tiles network to a work with image size--weight_files: weight files
TRAINING
--batch_size: "batch_size--steps_per_epoch: steps_per_epoch--epochs: number of epochs--log_path: log path for tensorboard--specie: which specie ? (PM,DR,AT,DM,or PM-AT, PM-DM-AT, CP (for CellPose)--microscope: which microscope ? (SPIM (for lightsheet), CONF (for confocal),SIM (for simulated))--augmentation: Use Data Augmentation ? Default is False--pondere: Keep only the worst element (10%) for training
DATA Management
--input_path: Input Path (depend on the called method )--output_path: Output Path (depend on the called method--membrane_filename: Filename membrane")--nucleus_filename: Filename nucleus")--segmented_filename: Filename segmented")--embryo_name: Embryo Name")--ratio: Resize the full database")--input_method: Input Method (for Ground Truth Calculcation)")
DATASET
--dataset_file: Dataset File without .train, .valid and .test--test_split: Float between 0 and 1. Fraction of the data to be used as test data.--validation_split: Float between 0 and 1. Fraction of the data to be used as validate data.
PREDICTION
--input_file: Input Filename to predict--output_file: Output Filename of the predicted image--patches: uses for prediction
RESULT
--export_path: The export path for the results
DATA PREPARATION
1. Extract segmentation and Raw Images data
SPIM PHALLUSIA MAMILATA
example :python morphodeep.py --microscope SPIM --specie PM --phallusia_data
CONF ARABIDOPSSIS
example :python morphodeep.py --microscope CONF --specie AT --arabidopsis_data
CONF LATERAL ROOTS
example :python morphodeep.py --microscope CONF --specie LP --plantseg_data
CONF OVULES
example :python morphodeep.py --microscope CONF --specie OV --plantseg_data
CONF SEA STAR
example :python morphodeep.py --microscope CONF --specie SS --seastar_data
CONF C ELEGANS
example :python morphodeep.py --microscope CONF --specie CE --celegans_data
2. Generate all Ground Truth
args : --ground_truth
example :python morphodeep.py --ground_truth --microscope CONF --specie SS
3. Split Train,Test Valid data
args : --setdata
example :python morphodeep.py --setdata --microscope CONF --specie SS
3.b To transfert your data in 128 patches
example : python morphodeep.py --setdata --img_size 128
4. Predict Cellpose (on test data)
args : --predict_cellpose
example :python morphodeep.py --predict_cellpose --exe --microscope SPIM --specie PM
5. Predict PlantSeg (on test data)
args : --predict_plantseg
example :python morphodeep.py --predict_plantseg --exe --microscope CONF --specie OV
6. DataManagement
To compress or uncompress data from $STORE path in Jean Zay : morphodeep/DataManagement/store_data.py
example :python store_data.py --compress --microscope CONF --specie PM
7. Train Semantic Networks
args : --train
example : python morphodeep.py --train --microscope SPIM --specie PM
8. Compute accuracy and plot loss evolution
args : --plot
example : python morphodeep.py --plot --microscope CONF --specie AT
9. Benchmark Test data (from figures path)
example : python Benchmark.py --predict
11. Benchmark on external data
args : python Benchmark.py --predict -f figure_5/EXTERNAL_DATA/external_data_3D.txt
2D
Everything is by default in 3D, add --mode 2D to comptue evertyhing in 2D
1. Convert in 2D DATA (and generate txt files)
We extract all the 3D datbase to 2D slices
args : --extract_2D
example :python morphodeep.py --mode 3D --microscope ALL --specie all --extract_2D [-wh <test;train;valid>]
2. Generate all Ground Truth for all species (includ in all)
args : --ground_truth
example :python morphodeep.py --mode 2D --ground_truth --microscope SPIM --specie PM
3. Predict Cellpose (on test data)
args : --predict_cellpose
example :python morphodeep.py --mode 2D --predict_cellpose
4. Predict PlantSseg (on test data)
args : --predict_plantseg
example :python morphodeep.py --mode 2D --predict_plantseg
6. DataManagement
To compress or uncompress data from $STORE path in Jean Zay : semantic/DataManagement/store_data.py
example :python store_data.py --mode 2D --compress --microscope CONF --specie PM
7. Train Semantic Networks
args : --train
example : python morphodeep.py --mode 2D --batch_size 32 --train
8. Compute accuracy and plot loss evolution
args : --plot
example : python morphodeep.py --mode 2D --plot
12. Benchmark Test data (from figures path)
example : python Benchmark.py --predict -t 2D -p True
12. Benchmark on external data
example : python Benchmark.py --predict -t 2D -p True -n DUNNET -f /lustre/fsn1/projects/rech/dhp/uhb36wd/DATA_INTEGRATION//EXTERNAL_DATA_2D/external_data_2D.txt
This napari plugin was generated with copier using the napari-plugin-template (None).
Contributing
Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.
License
Distributed under the terms of the GNU LGPL v3.0 license, "morphodeep" is free and open source software
Issues
If you encounter any problems, please [file an issue] along with a detailed description.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file morphodeep-0.0.1.tar.gz.
File metadata
- Download URL: morphodeep-0.0.1.tar.gz
- Upload date:
- Size: 117.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
247e19f2d6d11a891a7129cc172dbe7f01026910b3ea0d1d2b8e8386c834d009
|
|
| MD5 |
c6f819a8eb4ac93c500304745a677321
|
|
| BLAKE2b-256 |
c239eca1ba38a74b6cdefd1ec95bb105b5789071fd972022ed2354c0afb4b7c4
|
File details
Details for the file morphodeep-0.0.1-py3-none-any.whl.
File metadata
- Download URL: morphodeep-0.0.1-py3-none-any.whl
- Upload date:
- Size: 145.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c5efbfb5ff70e285bc9cae9d1946dd747ce4ae6613eb1fbd223c599f2bc099d
|
|
| MD5 |
67867a04b3f76ee19aa691122985c63a
|
|
| BLAKE2b-256 |
26275b84a28227b1727832230e08c8545704b3e8519f424331b9e72889dad792
|