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

Cellprofiler app + plugin #1724

Merged
merged 34 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
563393f
first version of cellprofiler plugin
binliunls Jul 23, 2024
386307c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 23, 2024
9657320
add vista support
binliunls Jul 30, 2024
02745d5
fix some issues
binliunls Aug 1, 2024
ab24f92
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 1, 2024
dcfe2b1
update the plugin part
binliunls Aug 2, 2024
a611b4f
Merge branch 'add-vsita2d-to-cellprofiler' of https://github.com/binl…
binliunls Aug 2, 2024
25a3f33
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 2, 2024
6d97251
fix format
binliunls Aug 6, 2024
a370cfa
Merge branch 'add-vsita2d-to-cellprofiler' of https://github.com/binl…
binliunls Aug 6, 2024
23e6d7e
fix plugin doc
binliunls Aug 7, 2024
5b438bd
remove redundant imports
binliunls Aug 9, 2024
5852e0a
add the test case
Aug 12, 2024
f37c05d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 12, 2024
71a13a9
add mock test
binliunls Aug 13, 2024
ca99c89
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 13, 2024
0a20ba1
add unit test
Aug 14, 2024
1f1045d
add readme for cellprofiler plugin
binliunls Aug 15, 2024
d7adf0d
add the cellprofiler image
binliunls Aug 15, 2024
c80c53d
update readme file
binliunls Aug 16, 2024
02bbc82
remove the unnecessary file
binliunls Aug 18, 2024
ed36f3a
fix import
binliunls Aug 19, 2024
ec832fd
add return
binliunls Aug 19, 2024
ad41a8d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 19, 2024
becf05c
update vista app readme
binliunls Aug 19, 2024
8b031d5
Merge branch 'add-vsita2d-to-cellprofiler' of https://github.com/binl…
binliunls Aug 19, 2024
4679ac7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 19, 2024
6ac2f48
Merge branch 'main' into add-vsita2d-to-cellprofiler
binliunls Aug 19, 2024
79de3fe
rename the vista app to vista2d app
binliunls Aug 21, 2024
3bba98b
fix vista to vista2d
binliunls Aug 25, 2024
99e9e35
fix the bundle name from cell_vista_segmentation to vista2d
binliunls Aug 25, 2024
9975265
add vista2d model
binliunls Aug 25, 2024
57d027d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 25, 2024
71bbd07
fix readme issue
binliunls Aug 28, 2024
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
Binary file added docs/images/cellprofiler.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/cellprofiler_plugin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions monailabel/tasks/infer/basic_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,10 @@
if path:
checkpoint = torch.load(path, map_location=torch.device(device))
model_state_dict = checkpoint.get(self.model_state_dict, checkpoint)

if set(self.network.state_dict().keys()) != set(checkpoint.keys()):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this change break any existing checkpoints for other models? bundles? other apps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. Because of this line model_state_dict = checkpoint.get(self.model_state_dict, checkpoint). If the checkpoint is the model_state_dict, then it will return the checkpoint directly. Otherwise it will return the model_state_dict. I think this is why this line exists here. And the old condition logic which uses the checkpoint looks like a bug to me. Please correct me if there are other cases.

Thanks
Bin

if set(self.network.state_dict().keys()) != set(model_state_dict.keys()):

Check warning on line 470 in monailabel/tasks/infer/basic_infer.py

View check run for this annotation

Codecov / codecov/patch

monailabel/tasks/infer/basic_infer.py#L470

Added line #L470 was not covered by tests
logger.warning(
f"Checkpoint keys don't match network.state_dict()! Items that exist in only one dict"
f" but not in the other: {set(self.network.state_dict().keys()) ^ set(checkpoint.keys())}"
f" but not in the other: {set(self.network.state_dict().keys()) ^ set(model_state_dict.keys())}"
)
logger.warning(
"The run will now continue unless load_strict is set to True. "
Expand Down
51 changes: 51 additions & 0 deletions plugins/cellprofiler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!--
Copyright (c) MONAI Consortium
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# MONAI Label Plugin for CellProfiler
CellProfiler 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.

CellProfiler is designed to serve biologists as well as bioimage analysts who want a flexible system that is easy to deploy to collaborators who lack computational skills. It is commonly used for small-scale experiments involving a few images but is also routinely run on millions of images using cluster or cloud computing resources at some of the largest pharmaceutical companies and academic screening centers in the world.

<img src="../../docs/images/cellprofiler.jpg" width=70% />

### Table of Contents
- [Supported Applications](#supported-applications)
- [Installing CellProfiler](#installing-cellprofiler)
- [Install MONAI Label Extension From Binaries](#install-monai-label-extension)
- [Using the Plugin](#using-the-plugin)

### Supported Applications
Users can find supported applications in the [sample-apps](../../sample-apps/monaibundle/) folder and use the cell_vista_segmentation bundle. Currently, only this bundle can be used to create and refine labels for medical imaging tasks in CellProfiler.

### Installing CellProfiler

To use MONAILabel with CellProfiler, you first need to install CellProfiler from source code following the installation part of [CellProfiler WiKi](https://github.com/CellProfiler/CellProfiler/wiki). Once you have CellProfiler installed, you can install the MONAILabel plugin as shown in the `Install MONAI Label Extension` part.

Please note these tips when installing the software:
1. After cloned the source code, you must switch to a specific version tag of the repo to start installation.
1. For Macbooks with Apple Silicon, please note [this issue](https://github.com/CellProfiler/CellProfiler/issues/4932) before you start to install.
1. Before actually running the command `pip install -e .`, you may need to install numpy if it doesn't exist in your environment.

### Install MONAI Label Extension
1. Save the runvista2d.py file to a local path.
1. Start CellProfiler from CLI, open the `File-->preferences` option and fill in the `CellProfiler plugin directory` parameter with your local path.

## Using the Plugin

1. Start the MONAI Label server with cell_vista_segmentation bundle.
1. Add the `RunVISTA2D` module to your pipeline for object processing.
1. Make sure the MONAILabel Server URL is correctly set in the plugin input.
1. Click the `Analyse Images` or `Start Test Mode` button to execute the pipeline.
1. Update masks and perform the sequential modules to get measurement results.

<img src="../../docs/images/cellprofiler_plugin.png" width=70% />
Binary file added plugins/cellprofiler/resources/vista2d_test.tiff
Binary file not shown.
Loading