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

Added Mask 3D edit #822

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

henriquenunez
Copy link

@henriquenunez henriquenunez commented Aug 7, 2024

3D edit of masks in InVesalius

These improvements are the result of the Google Summer of Code 2024 project for the InVesalius organization.

The proposal of this project was to include a tool for editing masks in 3D for InVesalius, which can speed up the process of reviewing and adjusting scans. For more information, please visit my blog post.

In a nutshell, the changes I have made in the project were:

  1. Menu changes, including buttons and other controls to configure the mask cutting operation
  2. Interactor style for volume. VTK is based on interaction styles, which will bind functions to user input.
  3. Module for managing the mask cut information. It receives information from the menu and the interaction styles.
  4. Cython code to speed up the cutting operation.

Said so, when the "Edit in 3D" checkbox is toggled, the user can draw several polygons on the volume viewer, and when "Cut" is clicked, the operation will be performed. Note that several polygons can be added, as well as arbitrary complex polygons can be used.

Visual demo:

  1. New buttons in the "Manual Edition" menu

image

  1. Polygon selection in the volume viewer:

image

  1. Different modes for mask cut:

    Mode Before Edit After Edit
    Include inside polygon image image
    Exclude inside polygon image image
    Include inside polygon within depth image image
    Exclude inside polygon within depth image image

Remaining Work

  • Create documentation
  • Localize the new user interface
  • Polish the depth cut mode
  • Correct some bugs
  • Edit polygons withing volume viewer

Future improvements

  • Create 3D widgets to edit the mask with (like ellipsoids etc)

The absence of the channel was causing pytorch not to be found on
a windows installation (windows 10 22H2, miniconda3, conda 24.4.0)
task_slice.py:
- Checkbox for enabling the 3D mask edit
- Button for performing the edit
- Combobox for choosing the edit mode

constants.py:
- Style ID for mask edit
- Operation constants and mode strings (not localized yet)
Copy link
Member

@tfmoraes tfmoraes left a comment

Choose a reason for hiding this comment

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

I think it's better to remove the files non related to your work in this PR. Like files from folders bundle_tools, docs/devel and scripts

Comment on lines 8 to 16
DTYPEF64 = np.float64
ctypedef np.float64_t DTYPEF64_t

ctypedef fused image_t:
np.float64_t
np.int16_t
np.uint8_t

ctypedef np.uint8_t mask_t
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

Thank you, I have solved that. Please check the new code

UI modifications to allow drawing a polygon in the volume renderer

- Canvas Handler for simple polygon selection and rendering;
- Interaction style to create this polygon and communicate to mask edit.
Functionality for using the polygon drawn in the volume viewer to cut
the mask has been implemented.
@henriquenunez
Copy link
Author

I think it's better to remove the files non related to your work in this PR. Like files from folders bundle_tools, docs/devel and scripts

I also removed that PR. I had run ruff on all files, but that is probably unneeded.

The user can now select multiple polygons in the volume renderer to
perform the edit.
Added controls in task_slice for toggling the "3D mask cut with depth"
functionality.
Added the button for cleaning up the polygons in the volume viewer.
Implemented with a spin control from 0 to 1.

Function parameter improvements in mask_3d_edit.py
@henriquenunez henriquenunez changed the title Added Mask 3D edit (frontal) Added Mask 3D edit Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants