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

README.md Update and Documentation Proposal #105

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 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
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ Wish to contribute to the development of this 3D Slicer module/extension? As a t

* [PEP8 style guide official documentation](https://peps.python.org/pep-0008/)
* [Polytechnique Montreal Home-Made Guide for programming style (in French)](https://github.com/INF1007-Gabarits/Guide-codage-python)

[GO on Documentation Welcome Page](./SlicerCART/documentation/welcome.md).
[GO on README.md Page](README.md).
114 changes: 20 additions & 94 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,105 +2,31 @@
![](SlicerCART/src/Resources/Icons/SlicerCART.png)
SlicerCART: Configurable Annotation and Review Tool.
maxradx marked this conversation as resolved.
Show resolved Hide resolved

## Description
This is a 3D Slicer extension aimed to improve workflow in manual
segmentation, classification and revision tasks. For example, SlicerCART
maxradx marked this conversation as resolved.
Show resolved Hide resolved
enables to
quickly load specific volumes of a dataset and navigate through them,
perform manual segmentation of medical images (e.g. annotating
multiple sclerosis lesions on MRI) or compare different segmentation
versions (e.g. lesion segmentation generated by a deep learning-based model).

* 3D Slicer extension
* Adapted from code of Dr. Laurent Létourneau-Guillon and his team in [ICH_SEGMENTER_V2](https://github.com/laurentletg/ICH_SEGMENTER_V2), [SlicerCART](https://github.com/laurentletg/SlicerCART), and [Brain_Extraction](https://github.com/MattFr56/CT_Brain_Extraction/blob/main/Brain_Extraction/Brain_Extraction/Brain_Extraction.py). This is an effort to create a unified code for a configurable 3D Slicer extension.
* Inspired from [Neuropoly](https://neuro.polymtl.ca/)'s workflow.
* This tool is made to improve manual segmentation and classification workflows across different teams.
###### [Installation](./SlicerCART/documentation/installation.md)
maxradx marked this conversation as resolved.
Show resolved Hide resolved
maxradx marked this conversation as resolved.
Show resolved Hide resolved

**Keywords:** medical imaging, manual segmentation, manual correction, workflow, ground-truth segmentation, quality control
###### [QuickStart](./SlicerCART/documentation/quickstart.md)
maxradx marked this conversation as resolved.
Show resolved Hide resolved
maxradx marked this conversation as resolved.
Show resolved Hide resolved

**Abbreviations:**
##### [See Documentation](./SlicerCART/documentation/welcome.md)
maxradx marked this conversation as resolved.
Show resolved Hide resolved
maxradx marked this conversation as resolved.
Show resolved Hide resolved

- MRI - Magnetic Resonance Imaging
- CT - Computed Tomography
- BIDS - Brain Imaging Data Structure
- GUI - Graphical User Interface
- QC - Quality Control

**Rationale:**

* Manual segmentation and classification tasks are required in the research setting related to medical imaging artificial intelligence tool development
* An open-source solution for such tasks would better benefit the research setting
* Actual open-source solutions that enable imaging viewing and annotation are not optimal from an end-user standpoint (especially from various background), increasing the already high burden of manual segmentation and classification tasks
* A workflow aimed to efficiently navigate through a dataset while performing manual segmentation / correction, including revision steps and robust annotation consistency assessment is crucial for handling large amount of data and provide the best ground-truth references segmentation as possible.

**Module specific functions (in details)**

This module has been adapted to perform several tasks. Among other things, it allows the user to:

* Customize configuration preferences (see below for details)
* Customize keyboard shortcuts
* Identify the name, degree and revision step related to the human annotator
* Select folder of interest where volumes are saved (and possibly impose BIDS)
* Select the output folder where processing and work is preferred to be saved
* Select a ground-truth folder where references studies can be used for iterative self-assessment
* Display in the GUI a case list of all the studies of interests for the segmentation task (*from a site directory or a customized list)
* Select from the GUI case list any volume of interest to display
* Navigate through case list from next and previous buttons
* Load automatically the first remaining case for segmentation in a customized list
* Create automatically all required segments that may be used according to the project configuration each time a volume is displayed
* Toggle interpolation of the volume loaded
* Execute multiple automated functions when saving segmentation masks for a given volume. Indeed, the automated functions:
* Save segmentation masks in the selected output folder with volume file hierarchy
* Track the different versions (save the following version if previous version(s) already exist(s)) **N.B. limitation to 99 versions for a single volume*
* Save a .csv file with segmentation statistics (e.g. subject, annotator's name and degree, revision step, date and time, total duration, duration of each label annotation)
* Save a .csv file with classification statistics (e.g. subject, annotator's name and degree, revision step, date and time, checkboxes / dropdown / free text fields)
* Go to the next remaining case and make it ready to segment without any further action
* Load a pre-existing segmentation for further modification (will be saved as a new version of the segmentation)

### Requirements

* MacOS Sonoma or Sequoia is recommended
* A working version of [3D Slicer](https://download.slicer.org).
* N.B. The version currently used to develop this module is the version 5.6.2 (most stable release as of 2024-10-22). The version 5.2.2 has also been used.

This module has been developed on:

* MacOS Sonoma version 14.1.1 and Sequoia 15.0.1
* 3D Slicer version 5.6.2

Although it may work on other versions and/or operating system, please note that it has not been tested.

## Installation steps

If previous version of Slicer ---» delete the app. If on MacOS, you can do it by doing right lick on the app in the application folder --- move to trash --- go to trash --- empty the trash --- restart your computer.


1. Install [3D Slicer](https://download.slicer.org).
2. Clone this repository in the location of your choice.
3. Then, go in the finder --- find the file SlicerCART.py file, and copy the pathname.
4. Open 3D Slicer.
5. Activate the checkbox `Enable developer mode` in `Edit -> Application Settings -> Developer -> Enable developer mode`.
6. Add the path of the `SlicerCART.py` file in `Edit -> Application Settings -> Modules -> Additional module paths`.(N.B. 1) You must have the file: if it is the folder path, then the module will not work; 2) in the Additional modul path section, the path copied might be shown to the folder: this is a Slicer thing, and should not affect working property of the module if it was the file that you copied).
7. The module can be found under `Examples -> SlicerCART`: the module should now be opened (N.B. 1) If first use, you may have additional requirements to install. A pop-up window from Slicer advertising you should pop-up if so: just click ok).
8. (Optional) Set the SlicerCART module to launch at 3DSlicer startup. To do so, go to `Edit -> Application Settings -> Modules -> Default startup module`
9. There might be errors. These would be seen in the Python Console: if any errors, we highly recommend you to fix them before any further use!

### Trouble shooting

* Qt might need to be installed. The first five steps of the following procedure might be useful for this: [procedure](https://web.stanford.edu/dept/cs_edu/resources/qt/install-mac).

### Other extensions that could be useful
* `SlicerJupyter` to be able to use Jupyter Notebooks connected to 3D Slicer.

### Documentation
TODO (after sufficient development has been made)

### Video tutorials
TODO (after sufficient development has been made)
### Contributors

### Other resources
* [3D Slicer Tutorials](https://www.youtube.com/watch?v=QTEti9aY0vs&)
* [3D Slicer Documentation](https://www.slicer.org/wiki/Documentation/Nightly/Training)
1. Adapted from code of Dr. Laurent Létourneau-Guillon and his team in [ICH_SEGMENTER_V2](https://github.com/laurentletg/ICH_SEGMENTER_V2), [SlicerCART](https://github.com/laurentletg/SlicerCART), and [Brain_Extraction](https://github.com/MattFr56/CT_Brain_Extraction/blob/main/Brain_Extraction/Brain_Extraction/Brain_Extraction.py). This is an effort to create a unified code for a configurable 3D Slicer extension.
2. Inspired from [Neuropoly](https://neuro.polymtl.ca/)'s workflow.

### Contributors
[![Contributors](https://img.shields.io/github/contributors/neuropoly/slicer-manual-annotation/graphs/contributors)](https://github.com/neuropoly/slicer-manual-annotation/graphs/contributors), including:
1. [![Contributors](https://img.shields.io/github/contributors/neuropoly/slicer-manual-annotation/graphs/contributors)](https://github.com/neuropoly/slicer-manual-annotation/graphs/contributors), including:

* Laurent Létourneau-Guillon
* Emmanuel Montagnon
* An Ni Wu
* Maxime Bouthillier
* Delphine Pilon
* Neuropoly Team
* Laurent Létourneau-Guillon
* Emmanuel Montagnon
* An Ni Wu
* Maxime Bouthillier
* Delphine Pilon
* Neuropoly Team
83 changes: 83 additions & 0 deletions SlicerCART/documentation/functionalities.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# SlicerCART Functionalities

This section lists the functionalities of SlicerCART. If the function you
are looking for is not found below, it is likely that SlicerCART does not have
yet
this feature: you are invited to open an issue on the [Github Repository](https://github.com/neuropoly/slicer-manual-annotation/issues) to
request the functionality you are looking for.

**Specific functions (in details)**

This module has been adapted to perform several tasks. Among other things, it allows the user to:

* Customize configuration preferences for optimizing workflow for
segmentation or classification tasks, including:
* Task Selection (Segmentation and/or Classification)
* Modality to be viewed/process/annotated (CT or MRI)
* (Must one or the other for now. Does not currently take DICOM images)
* Brain Imaging Data Structure (BIDS) format imposition (test quickly if a
dataset respects the BIDS convention through a BIDS-validator script:
makes unable to load a dataset if it does not respect BIDS format)
* View to be displayed by default in the Slicer viewer (e.g.
axial, sagittal, etc.)
* Interpolation of images (by default, Slicer images that are displayed
get "interpolated" (i.e. smoother): with SlicerCART, you can select this
option that can be relevant for segmentation tasks)
* For CT-Scans:
* Specify the range of Houndsfield units for which a segmentation mask
will be feasible (e.g. 45 to 90): otherwise, segmentation mask will
not be created.
* Customize keyboard shortcuts
* Customize mouse button functions
* Configure from the GUI the segmentation labels,
including:
* Label name
* Label value
* Color
* Adding/Removal of labels
* Select if timer should be displayed during segmentation task
* Configure from the GUI the classification labels,
including adding/Removal of:
* Labels
* Checkbox
* DropDown Menu with choice selection
* Text field
* (Specify to save all segments to one file or multiple files)TO DO
* Identify the name, degree and revision step related to the human annotator
* Select folder of interest where volumes are saved (and possibly impose BIDS)
* Displays automatically the PATH of the loaded volume
* Select the output folder where processing and work is preferred to be saved
* (Select a ground-truth folder where references studies can be used for
iterative self-assessment)TO COME
* Display in the GUI a case list of all the studies of interests for the segmentation task (*from a site directory or a customized list)
* Select from the GUI case list any volume of interest to display
* Navigate through case list from next and previous buttons
* (Load automatically the first remaining case for segmentation in a
customized list)TO COME
* Create automatically all required segments that may be used according to the project configuration each time a volume is displayed
* From the Segmentation window:
* Open quickly the Segment Editor
* Start Painting for the first label
* Erase any part of visible masks
* Select Lasso Paint (fills the space of a contour-based geometrical
annotation)
* (Place a measurement line) TO COMPLETE
* Toggle interpolation of the volume loaded
* Execute multiple automated functions when saving segmentation masks for a given volume. Indeed, the automated functions:
* Save segmentation masks in the selected output folder with volume file hierarchy
* Track the different versions (save the following version if previous version(s) already exist(s)) **N.B. limitation to 99 versions for a single volume*
* Save a .csv file with segmentation statistics (e.g. subject, annotator's name and degree, revision step, date and time, total duration, duration of each label annotation)
* Save a .csv file with classification statistics (e.g. subject, annotator's name and degree, revision step, date and time, checkboxes / dropdown / free text fields)
* (Go to the next remaining case and make it ready to segment without any
further action)TO COME
* Load a pre-existing segmentation for further modification (will be saved as a new version of the segmentation)
* Compare different versions of segmentation TO COMPLETE
* Specify versions to be loaded at the same time
* Display multiple versions of segmentation masks at the same time
* Modify specific segments of different versions
* Save all segments displayed +- modified on the viewer as a version += 1
of segments in the output folder

[GO BACK on Documentation Welcome Page](welcome.md).
[Go BACK to User Guide](userguide.md).
[CONTINUE to Purpose](purpose.md).
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions SlicerCART/documentation/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# SlicerCART Installation

## Requirements

* MacOS Sonoma or Sequoia (15.0.1) is recommended
Copy link
Member

Choose a reason for hiding this comment

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

that's way too specific. What if 15.0.2 comes out? Can I use it? likely so. I suggest another wording, be more general to other distros (see eg how we do it in SCT).

* A working version of [3D Slicer](https://download.slicer.org) (version 5.6.2).
maxradx marked this conversation as resolved.
Show resolved Hide resolved
* Qt: might need to be installed.
Copy link
Member Author

Choose a reason for hiding this comment

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

@sandrinebedard from your comments "2- Can you open the python console and screenshot the line where there is the error? (there should have some errors when a slicer module cannot be instantiated).

same thing again, here is the error in the python console:"

Copy link
Member

Choose a reason for hiding this comment

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

? it should or it should not. This statement is confusing for the user

* The first five steps of the following procedure might be useful for this: [procedure](https://web.stanford.edu/dept/cs_edu/resources/qt/install-mac).
* You can try importing Qt in the Slicer python console (e.g. `import slicer ` then `from slicer.util import Qt`)

*Although it may work on other versions and/or operating system, please note
that it has not been tested.

If 3D Slicer has not been already installed, you can follow these steps:
1. Install [3D Slicer](https://download.slicer.org):
2. Make sure that you are able to open and use the 3D Slicer software before
trying installing any extension/module.
3. If you encounter some problems, you are encouraged to refer to:
* [3D Slicer Documentation](https://slicer.readthedocs.io/en/latest/)
* [3D Slicer forum](https://discourse.slicer.org/) (very active community)

## Installation Steps

1. Clone the [SlicerCART repository](https://github.com/neuropoly/slicer-manual-annotation) in the location of your choice.

Choose a reason for hiding this comment

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

Not so obvious how to clone a github page

Suggested change
1. Clone the [SlicerCART repository](https://github.com/neuropoly/slicer-manual-annotation) in the location of your choice.
1. Open a terminal and clone the [SlicerCART repository](https://github.com/neuropoly/slicer-manual-annotation) by taping the following command:
```bash
git clone https://github.com/neuropoly/slicer-manual-annotation.git

Choose a reason for hiding this comment

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

Turns out slicedCARD doesn't work if not installed in the root directory (tried to copy it on my desktop so I would suggest this new version. So I would definitely not put in the location of your choice.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok. Hm thats a problem. On my side, it is installed in the location of my choice (not on my desktop --- somewhere in documents etc.) Also, I would avoid the recomandation to use terminal: here, targeted audience includes non-technical staff (e.g. clinicians) for which the word 'terminal' sounds nothing... will keep the discussion open so we can discuss about this point

Copy link
Member

@sandrinebedard sandrinebedard Nov 21, 2024

Choose a reason for hiding this comment

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

maybe say download instead of cloning, cloning is also very technical, and say how to download, just linking to the repository doesn't help:
image
or link to a releas or dowload link: Download ZIP

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree with @sandrine . but how to link to the zip download as you did? also to keep the latest version always so no need to update very time?

Copy link
Member

Choose a reason for hiding this comment

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

that discussion thread should go in a specific issue

2. Open 3D Slicer.
3. Activate the checkbox `Enable developer mode` in `Edit
-> Application
Settings -> Developer -> Enable developer mode`.
4. Open Finder (on macOS). Go to the location of the SlicerCART Repository.
Go to the location of the python file `SlicerCART.py` (_should only have one
FILE of that name. Note that if you add the path of the folder SlicerCART,
it will not work: you MUST add the path of SlicerCART.py FILE_) in `Edit -> Application Settings
-> Modules -> Additional module paths`. See image example below:
Comment on lines +29 to +33

Choose a reason for hiding this comment

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

All of this part is not clear. I think some words are missing and the parentheses don't really help the understanding. I would go for something like this:

Suggested change
4. Open Finder (on macOS). Go to the location of the SlicerCART Repository.
Go to the location of the python file `SlicerCART.py` (_should only have one
FILE of that name. Note that if you add the path of the folder SlicerCART,
it will not work: you MUST add the path of SlicerCART.py FILE_) in `Edit -> Application Settings
-> Modules -> Additional module paths`. See image example below:
4. Open Finder (on macOS). Go to the location of the slicer-manual-annotation Repository (where you cloned the github).
Then find the file `SlicerCART.py` under `slicer-manual-annotation/SlicerCART/src/SlicerCART.py.
After that open in Slicer 3D `Edit -> Application Settings
-> Modules ` and drag and drop SlicerCART.py in the `Additional module paths` box. See image example below:

Copy link
Member Author

Choose a reason for hiding this comment

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

Little typo: After that, (should have a comma)

Copy link
Member

Choose a reason for hiding this comment

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

@maxradx Thomas' suggestion is excellent-- accept and fix the typo so others can comment on the new modifications

![](images/module_filepath.png)
maxradx marked this conversation as resolved.
Show resolved Hide resolved

(N.B. 1- You must drag the file SlicerCART.py in the additionnal module path section:
if you drag the folder path (SlicerCART folder), then the module will not work; 2- in the
Additional modul path section, you will see the module folder path and not the SlicerCART.py file path: this is a
Slicer thing, and should not affect working property of
the module if it was the file that you copied).
maxradx marked this conversation as resolved.
Show resolved Hide resolved

5. The Application will ask to Restart: click Ok.
![](images/example_restart.png)

6. The module can be found under `Examples -> SlicerCART`: the module should
now be opened (N.B. If first use, you may have additional requirements
to install. A pop-up window from Slicer advertising you should pop-up if so: just click ok).
![](images/example_slicercart.png)
maxradx marked this conversation as resolved.
Show resolved Hide resolved


8. (Optional) Set the SlicerCART module to launch at 3DSlicer startup. To do so, go to `Edit -> Application Settings -> Modules -> Default startup module`
9. There might be errors. These would be seen in the Python Console: if any errors, we highly recommend you to fix them before any further use!
maxradx marked this conversation as resolved.
Show resolved Hide resolved

**In Summary:**

Install 3D Slicer --- Enable Developer Mode --- Add the PATH of SlicerCART.
py file in the modules list --- (Optional) Select to launch SlicerCART at 3D
Slicer --- restart 3D Slicer --- READY FOR USE!
maxradx marked this conversation as resolved.
Show resolved Hide resolved
maxradx marked this conversation as resolved.
Show resolved Hide resolved

![](images/module_filepath.png)
maxradx marked this conversation as resolved.
Show resolved Hide resolved
maxradx marked this conversation as resolved.
Show resolved Hide resolved


### Troubleshooting

* Qt might need to be installed. The first five steps of the following procedure might be useful for this: [procedure](https://web.stanford.edu/dept/cs_edu/resources/qt/install-mac).
maxradx marked this conversation as resolved.
Show resolved Hide resolved

### Other extensions that could be useful
* `SlicerJupyter` to be able to use Jupyter Notebooks connected to 3D Slicer.
maxradx marked this conversation as resolved.
Show resolved Hide resolved

[GO BACK on Documentation Welcome Page](welcome.md).
[CONTINUE to QuickStart](quickstart.md).
maxradx marked this conversation as resolved.
Show resolved Hide resolved
16 changes: 16 additions & 0 deletions SlicerCART/documentation/purpose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SlicerCART Purpose

This section explains the rationale behind SlicerCART and its purpose.


**Rationale:**

* Manual segmentation and classification tasks are required in the research setting related to medical imaging artificial intelligence tool development
* An open-source solution for such tasks would better benefit the research setting
* Actual open-source solutions that enable imaging viewing and annotation are not optimal from an end-user standpoint (especially from various background), increasing the already high burden of manual segmentation and classification tasks
* A workflow aimed to efficiently navigate through a dataset while performing manual segmentation / correction, including revision steps and robust annotation consistency assessment is crucial for handling large amount of data and provide the best ground-truth references segmentation as possible.

[GO BACK on Documentation Welcome Page](welcome.md).
[GO BACK on List of Functionalities Page](functionalities.md).
[CONTINUE to Developer Guide](../../CONTRIBUTING.md).

Loading