Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1802-Add the monai label tutorial for cellprofiler #1803

Merged
merged 6 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion monailabel/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MONAI Label End-To-End Tutorial Series

This folder contains end-to-end tutorials of MONAI Label applications. Sample apps including `radiology`, `pathology`, `endoscopy` and `monaibundle`.
This folder contains end-to-end tutorials of MONAI Label applications. Sample apps including `radiology`, `pathology`, `endoscopy`, `VISTA2D` and `monaibundle`.

![image](https://raw.githubusercontent.com/Project-MONAI/MONAILabel/main/docs/images/sampleApps_index.jpeg)

Expand Down Expand Up @@ -32,6 +32,9 @@ Each tutorial provides MONAI Label plugin installation steps associated with the
- **Endoscopy App**:
- Viewer: [CVAT](https://github.com/opencv/cvat) | Datastore: Local | Task: Segmentation
- [MONAILabel: Tooltracking with CVAT](monailabel_endoscopy_cvat_tooltracking.ipynb): Surgical tool segmentation with CVAT/Nuclio setup.
- **VISTA2D App**:
- Viewer: [CellProfiler](https://github.com/CellProfiler/CellProfiler) | Datastore: Local | Task: Segmentation
- [MONAILabel: Cell Segmentation with CellProfiler](monailabel_vista2d_cell_segmentation_CellProfiler.ipynb): Cell images segmentation with CellProfiler setup.


## Hardware Requirements
Expand Down
KumoLiu marked this conversation as resolved.
Show resolved Hide resolved
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
180 changes: 180 additions & 0 deletions monailabel/monailabel_vista2d_cell_segmentation_CellProfiler.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Copyright (c) MONAI Consortium \n",
"Licensed under the Apache License, Version 2.0 (the \"License\"); \n",
"you may not use this file except in compliance with the License. \n",
"You may obtain a copy of the License at \n",
"    http://www.apache.org/licenses/LICENSE-2.0 \n",
"Unless required by applicable law or agreed to in writing, software \n",
"distributed under the License is distributed on an \"AS IS\" BASIS, \n",
"WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \n",
"See the License for the specific language governing permissions and \n",
"limitations under the License. \n",
"\n",
"# MONAI Label VISTA2D App - CellProfiler Cell Profile Example\n",
"\n",
"***The cell bioimage profile with MONAI Label***\n",
"\n",
"In this notebook, we show the example of MONAI Label VISTA2D usecase. The cell profile is demonstrated in this notebook. This tutorial uses CellProfiler as the client viewer, and we demonstrate the end-to-end workflow with MONAI Label + CellProfiler integration.\n",
"\n",
"![cellprofiler1](./figures/monailabel_vista_cellprofiler/cellprofiler_open.jpg)\n",
"\n",
"## 1. Prepare MONAI Label"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup environment\n",
"\n",
"### Prerequisites\n",
"- **Install MONAI Label** weekly preview release: "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip install monailabel"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.1 Download VISTA2D app\n",
"Choose \"vista2d\" as the app"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!monailabel apps --download --name vista2d --output apps"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.2 Download sample data\n",
"Download the [cellpose dataset](https://www.cellpose.org/dataset) and save to the **datasets** folder for further use. Please convert the image format from `png` to `tiff` before loading to the CellProfiler. Here is a short code for reference:\n",
"```python\n",
"from PIL import Image\n",
"image_path = \"/path/to/your/image.png\"\n",
"tif_path = \"/path/to/save/image.tiff\"\n",
"img = Image.open(image_path)\n",
"img.save(tif_path)\n",
"```"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.3 Starting MONAI Label Server\n",
"\n",
"The command will start MONAI Label server with VISTA2D.\n",
"\n",
"```bash\n",
"monailabel start_server --app apps/vista2d --studies datasets --conf models vista2d --conf preload true --conf skip_trainers true\n",
"```\n",
"In the command, ```--app``` specifies the VISTA2D app path, ```--studies``` specifies the dataset folder path.\n",
"\n",
"**Note:** If you are running a MONAI Label server in this notebook and plan to close the notebook, ensure that you terminate the kernel first. Failing to do so might result in an issue where the port remains occupied from the previous session when you try to restart the server later. To prevent this, always terminate the kernel before closing the notebook."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2. Install CellProfiler and MONAI Label Plugin\n",
"\n",
"\n",
"[CellProfiler](https://cellprofiler.org/) is a free open-source software designed to enable biologists without training in computer vision or programming to quantitatively measure phenotypes from thousands of images automatically.\n",
"\n",
"Note: Nvidia does not maintain the thrid-party visualization tools. Please refer to installation part in the [CellProfiler WiKi](https://github.com/CellProfiler/CellProfiler/wiki) for details or trouble shooting. \n",
"\n",
"After installed the CellProfiler, please download the [plugin python file](https://github.com/Project-MONAI/MONAILabel/blob/main/plugins/cellprofiler/runvista2d.py) and add the path to the file to `File-->preferences-->CellProfiler plugin directory`. Please add the folder path instead of the file path.\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3. Cell Profile with CellProfiler\n",
"\n",
"Below is a step-by-step tutorial for cell profile using CellProfiler. Pre-trained model is provided and loaded by MONAI Label server. We prepared an example pipeline named `cellprofiler_demo_pipeline.cpproj` in the extra_files folder to illustrate the use case. Feel free to update it according your own requirements.\n",
"\n",
"\n",
"### 3.1 Start CellProfiler and Load the Example Pipleline\n",
"\n",
"- Once finished the installation, drag the example pipeline to the CellProfiler pipeline window. Then the pipeline will be loaded into the screen as shown in the red box.\n",
"\n",
"<p align = \"center\"><img src=\"./figures/monailabel_vista_cellprofiler/cellprofiler_pipeline.jpg\" alt=\"drawing\" width=\"800\"/></p>\n",
"\n",
"### 3.2 Start CellProfiler and Load the Example Pipleline\n",
"\n",
"- Load your local samples to CellProfiler by dropping the sample folder or samples.\n",
"\n",
"<p align = \"center\"><img src=\"./figures/monailabel_vista_cellprofiler/cellprofiler_samples.jpg\" alt=\"drawing\" width=\"800\"/></p>\n",
"\n",
"### 3.3 Run the CellProfiler Pipeline and Edit the Segmentation Mask\n",
"\n",
"- After loading samples, click the `Analyse Images` button to start the profile. The demo pipeline provide the option to edit the output mask. Then the output profile will be generated based on the edited mask.\n",
"\n",
"<p align = \"center\"><img src=\"./figures/monailabel_vista_cellprofiler/cellprofiler_edit.jpg\" alt=\"drawing\" width=\"800\"/></p>\n",
"\n",
"<p align = \"center\"><img src=\"./figures/monailabel_vista_cellprofiler/cellprofiler_run.jpg\" alt=\"drawing\" width=\"800\"/></p>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4. Conclusion\n",
"\n",
"This tutorial demonstrates the basic usage of MONAI Label with the VISTA2D app, the cell profile task is introduced. We provided an example pipeline to show case the whole workflow. \n",
"\n",
"In the VISTA2D usecase, we highlight the profile pipeline with the CellProfiler on cell bioimages. \n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
},
"vscode": {
"interpreter": {
"hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1"
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}
1 change: 1 addition & 0 deletions runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ doesnt_contain_max_epochs=("${doesnt_contain_max_epochs[@]}" monailabel_radiolog
doesnt_contain_max_epochs=("${doesnt_contain_max_epochs[@]}" monailabel_wholebody_totalSegmentator_3dslicer.ipynb)
doesnt_contain_max_epochs=("${doesnt_contain_max_epochs[@]}" monailabel_monaibundle_3dslicer_lung_nodule_detection.ipynb)
doesnt_contain_max_epochs=("${doesnt_contain_max_epochs[@]}" monailabel_pathology_HoVerNet_QuPath.ipynb)
doesnt_contain_max_epochs=("${doesnt_contain_max_epochs[@]}" monailabel_vista2d_cell_segmentation_CellProfiler.ipynb)
doesnt_contain_max_epochs=("${doesnt_contain_max_epochs[@]}" example_feature.ipynb)
doesnt_contain_max_epochs=("${doesnt_contain_max_epochs[@]}" ssl_train.ipynb)
doesnt_contain_max_epochs=("${doesnt_contain_max_epochs[@]}" ssl_finetune.ipynb)
Expand Down
Loading