Skip to content

Commit

Permalink
Vista3d main (#30)
Browse files Browse the repository at this point in the history
Fixes # .

### Description

A few sentences describing the changes proposed in this pull request.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] In-line docstrings updated.

---------

Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: heyufan1995 <[email protected]>
Co-authored-by: Wenqi Li <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Wenqi Li <[email protected]>
Co-authored-by: mingxueg-nv <[email protected]>
  • Loading branch information
5 people authored Jul 30, 2024
1 parent 1e7f3cc commit aa08093
Show file tree
Hide file tree
Showing 233 changed files with 97,328 additions and 23,715 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/premerge-py-min.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: premerge-min

on:
# quick tests for pull requests and the releasing branches
push:
branches:
- vista3d
- main
pull_request:

concurrency:
# automatically cancel the previously triggered workflows when there's a newer version
group: py-min-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
min-dep-py3: # min dependencies installed tests for different python
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11']
timeout-minutes: 40
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Prepare pip wheel
run: |
which python
python -m pip install --user --upgrade pip setuptools wheel
- name: cache weekly timestamp
id: pip-cache
run: |
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
shell: bash
- name: cache for pip
uses: actions/cache@v4
id: cache
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ubuntu-latest-latest-pip-${{ steps.pip-cache.outputs.datew }}
- name: Install the dependencies
run: |
python -m pip install torch --extra-index-url https://download.pytorch.org/whl/cpu
python -m pip install "monai[all]"
python -m pip list
shell: bash
- name: Run quick tests (CPU ${{ runner.os }})
run: |
python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))'
python -c "import monai; monai.config.print_config()"
python -m unittest -v
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ temp/
runs
*.gz
*.pth
*.pt
lib/
pip-wheel-metadata/
share/python-wheels/
Expand Down
15 changes: 7 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
Expand All @@ -27,23 +27,23 @@ repos:
- id: end-of-file-fixer
- id: mixed-line-ending
- repo: https://github.com/psf/black
rev: "23.3.0"
rev: "24.4.2"
hooks:
- id: black
- id: black-jupyter
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.261
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.0
hooks:
- id: ruff
args: ['--fix']

- repo: https://github.com/asottile/yesqa
rev: v1.4.0
rev: v1.5.0
hooks:
- id: yesqa
name: Unused noqa
Expand All @@ -54,8 +54,7 @@ repos:
- pep8-naming
exclude: |
(?x)^(
monai/__init__.py|
docs/source/conf.py|
.*/__init__.py|
tests/utils.py
)$
Expand Down
6 changes: 0 additions & 6 deletions 3rdParty/data_license.txt

This file was deleted.

File renamed without changes.
183 changes: 2 additions & 181 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,184 +11,5 @@ See the License for the specific language governing permissions and
limitations under the License.
-->

# MONAI VISTA

MONAI **V**ersatile **I**maging **S**egmen**T**ation and **A**nnotation

<div align="center"> <img src="./assets/imgs/demo_gif.gif" width="800"/> </div>

*(We're seeking collaborators.
If your institution is interested, please fill out the survey: https://forms.office.com/r/RedPQc9fmw)*

### Table of Contents
- [Overview](#overview)
- [MONAI VISTA Training and FineTuning](training/)
- [MONAI VISTA with MONAI Label](#monai-label-integration)
- [Step 1. Installation](#installation)
- [Step 2. MONAI Label monaivista app](#monai-vista-app)
- [Step 3. MONAI VISTA - Label Plugins](#monai-vista-viewer-plugins)
- [Step 4. Data Preparation](#sample-data)
- [Step 5. Start MONAI Label Server and Start Annotating!](#start-monai-label-server-with-vista-model)
- [Video Demo](https://drive.google.com/file/d/1rEF1y9ZKo3Kj0Zms_gxkKwHlz75CYjwA/view?usp=sharing)
- [Community](#community)
- [License](#license)
- [Reference](#reference)

## Overview

[MONAI Meetup presentation at MIDL 2023](https://docs.google.com/presentation/d/1evp8txCyTzkqLT0fVE_0eFlXL4hux5myb7ggFhokRFQ)

MONAI VISTA provides domain-specific workflows for building and utilizing foundation models
for medical image segmentation.
It leverages state-of-the-art deep learning technology to establish a
new collaborative approach for developing robust and versatile
segmentation models and applications.

This repository hosts the ongoing effort of building MONAI VISTA and
is currently under active development.



<div align="center"> <img src="./assets/imgs/montage.png" width="800"/> </div>


## MONAI Label Integration
This section provides MONAI Label integration and sample apps. The integration is a server-client
system that facilitates interactive medical image segmentation using VISTA via the sample 3D slicer plugin.

### Installation

MONAI VISTA models are integrated based on [MONAI Label](https://docs.monai.io/projects/label/en/latest/index.html#).
Start using MONAI Label locally and run the installation with your familiar visualization tools.
Stable version software represents the currently tested and supported visualization tools with
the latest release of MONAI Label.

Refer to [MONAI Label installation](https://docs.monai.io/projects/label/en/latest/installation.html) page
for details. For milestone releases, users can install from PyPl with the command:

```bash
pip install monailabel

```

For Docker and Github installation, refer to MONAI Label [Github](https://github.com/Project-MONAI/MONAILabel)

### MONAI VISTA APP

Based on MONAI Label, MONAI VISTA is developed as an app. This app has example models
to do both interactive and "Everything" segmentation over medical images.
Prompt-based segment experience is highlighted. Including class prompts and point click prompts, Segmentation with the latest deep learning architectures (e.g., Segmentation Anything Model (SAM)) for multiple lung, abdominal, and pelvis
organs. Interactive tools include control points and class prompt check boxes developed with viewer plugins.

Get the monaivista app with:

```bash
# Clone MONAI VISTA repo
git clone [email protected]:Project-MONAI/VISTA.git
# the sample monaivista app is in the monailabel folder
cd VISTA/monailabel
```

For more details on `monaivista` app, see the [sample-app page](https://github.com/Project-MONAI/VISTA/tree/main/monailabel/monaivista).

### MONAI VISTA Viewer Plugins

The interactive annotation experience with prompt-based segmentation models needs the integration of medical image viewers.
MONAI VISTA and MONAI Label support multiple open-sourced viewers, such as [3D Slicer](https://www.slicer.org/) and [OHIF](https://ohif.org/).

Example of 3D Slicer integration:

3D Slicer is a free, open-source software for visualization, processing, segmentation, registration,
and other 3D images and meshes. 3D Slicer is a mature and well-tested viewer for radiology studies and algorithms.

#### Installing 3D Slicer

To use MONAI Label with 3D Slicer, you'll need to download and install 3D Slicer.
MONAI Label supports stable and preview versions of 3D Slicer, version 5.0 or higher.
For more information on installing 3D Slicer,
check out the [3D Slicer Documentation](https://slicer.readthedocs.io/en/latest/user_guide/getting_started.html#installing-3d-slicer)

#### Install MONAI VISTA-Label plugin of 3D Slicer

The plugin needs to be added in developer mode. Please follow the below steps.

##### Plugin in Developer Mode

- `git clone [email protected]:Project-MONAI/VISTA.git`
- Find the plugin folder: `plugins/slicer/MONAILabel`
- Open 3D Slicer: Go to **Edit** -> **Application Settings** -> **Modules** -> **Additional Module Paths**
- Add New Module Path: _<FULL_PATH>_/plugins/slicer/MONAILabel (You can drag the slicer/MONAILabel folder to the module panel.)
- _**Restart**_ 3D Slicer

<div align="center"> <img src="./assets/imgs/3dslicer_module.png" width="500"/> </div>

<div align="center"> <img src="./assets/imgs/3dslicer_plugin.png" width="500"/> </div>

### Sample Data

Prepare some sample data to start with:

Download MSD pancreas dataset as the sample dataset using monailabel API.
The task is the volumetric (3D) segmentation of the pancreas from CT image.
The dataset is from the 2018 MICCAI challenge.

```bash
monailabel datasets --download --name Task07_Pancreas --output .
```

### Start MONAI Label Server with VISTA Model

Specify the sample app and sample datasets' path in the following command:

```bash
monailabel start_server --app monaivista --studies ./Task07_Pancreas/imagesTs --conf models vista_point_2pt5
```

- Open 3D Slicer and MONAI VISTA-Label plugin.
<div align="center"> <img src="./assets/imgs/3dslicer_open.jpeg" width="800"/> </div>

- Connect to the monailabel server, start annotating!
<div align="center"> <img src="./assets/imgs/3dslicer_annotating.png" width="800"/> </div>

## Community

Join the conversation on Twitter [@ProjectMONAI](https://twitter.com/ProjectMONAI) or join
our [Slack channel](https://projectmonai.slack.com/archives/C031QRE0M1C).

Ask and answer questions on [MONAI VISTA's GitHub discussions tab](https://github.com/Project-MONAI/VISTA/discussions).

## License

The model is licensed under the Apache 2.0 license.

## Reference

The current model is trained and developed based on [Segment Anything Model (SAM)](https://github.com/facebookresearch/segment-anything). Check the 3rd party license for reference.

We greatly appreciate the authors of [`Segment Anything`](https://github.com/facebookresearch/segment-anything) and [`TotalSegmentator`](https://github.com/wasserth/TotalSegmentator) for releasing their work under a permissive license to the community.

```
@article{kirillov2023segany,
title={Segment Anything},
author={Kirillov, Alexander and Mintun, Eric and Ravi, Nikhila and Mao, Hanzi and Rolland, Chloe and Gustafson, Laura and Xiao, Tete and Whitehead, Spencer and Berg, Alexander C. and Lo, Wan-Yen and Doll{\'a}r, Piotr and Girshick, Ross},
journal={arXiv:2304.02643},
year={2023}
}
@article{wasserthal2022totalsegmentator,
title={TotalSegmentator: robust segmentation of 104 anatomical structures in CT images},
author={Wasserthal, Jakob and Meyer, Manfred and Breit, Hanns-Christian and Cyriac, Joshy and Yang, Shan and Segeroth, Martin},
journal={arXiv preprint arXiv:2208.05868},
year={2022}
}
```

This integration is based on MONAI Label:

```bash
@article{diaz2022monai,
title={Monai label: A framework for ai-assisted interactive labeling of 3d medical images},
author={Diaz-Pinto, Andres and Alle, Sachidanand and Nath, Vishwesh and Tang, Yucheng and Ihsani, Alvin and Asad, Muhammad and P{\'e}rez-Garc{\'\i}a, Fernando and Mehta, Pritesh and Li, Wenqi and Flores, Mona and others},
journal={arXiv preprint arXiv:2203.12362},
year={2022}
}
```
# MONAI VISTA Repository
This is the repository for VISTA3D and VISTA2D For the older VISTA2.5d code, please checkout the vista2.5d branch
Binary file removed assets/img.png
Binary file not shown.
Binary file removed assets/img_1.png
Binary file not shown.
Binary file removed assets/imgs/3dslicer_annotating.png
Binary file not shown.
Binary file removed assets/imgs/3dslicer_module.png
Binary file not shown.
Binary file removed assets/imgs/3dslicer_open.jpeg
Binary file not shown.
Binary file removed assets/imgs/3dslicer_plugin.png
Binary file not shown.
46 changes: 0 additions & 46 deletions monailabel/monaivista/README.md

This file was deleted.

12 changes: 0 additions & 12 deletions monailabel/monaivista/lib/activelearning/__init__.py

This file was deleted.

Loading

0 comments on commit aa08093

Please sign in to comment.