Skip to content

Conversation

AksharaSBhat
Copy link
Contributor

What does this PR do?

This PR ensures that the peeled brain is treated as a regular surface but restricts color changes.
It also fixes an issue where the peeled brain was not saved and restored when reopening a project.

Changes made

Added peel attribute to Surface to track peeled surfaces.
Updated CreateSurfaceFromPolydata to properly assign peel=True.
Modified SavePlist and OpenPlist to persist peel state.
Disabled "Change Color" button for peeled surfaces in the UI.
Disabled button_colour for peel in task_surface.py

How to test

Create a peeled brain surface.
Save and close InVesalius.
Reopen the project and check if the peeled brain is restored.
Right-click on the peeled brain → "Change Color" should be disabled.

Closes #796

@AksharaSBhat
Copy link
Contributor Author

@vhosouza @rmatsuda @henrikkauppi
Hi! Please take a look at this PR when you get a chance. I'd appreciate any feedback or suggestions. Thanks!

@rmatsuda
Copy link
Collaborator

Hi @AksharaSBhat! Thanks for the PR. I tested the changes, and the peel surface looks weird. I think the transformations are incorrect. Please check brainmesh_handler.py.
We need to be able to freely adjust the peeling depth and brain opacity. It should not create a new 3D surface but rather overlap the existing one.

Here are the steps to create the peel surface:

  • Create the mask for brain segmentation: Tools -> Segmentation -> Brain Segmentation (MRI T1).

  • Go to the Tractography tab, press the Peel button, then select From Mask and choose the brain-segmented mask.

Note: You should have Transcranial Magnetic Stimulation mode enabled. You can find it under Mode -> Navigation Mode.

It should look like this:
image

Fixes:
Now the user can freely adjust the peeling depth and brain opacity, without creating a new surface
The peeled surface is handled separately in AddSurface so that it is rendered properly
@AksharaSBhat
Copy link
Contributor Author

Hi @rmatsuda Thanks for the feedback. I have fixed the issues now. The user can freely adjust the peeling depth and brain opacity. It won't create a new 3D surface but rather overlap the existing one.

Changes

Modified AddSurface method handle peeled surface separately as it was being handled earlier instead of being handled as any other surface.
Created attribute peeled_surface_index to keep track of the peeled surface so that it is overwritten instead of creating a new 3D surface

This is the peeled surface in after the latest commit in this branch
brain_peelsurface

And this is the peeled surface in the master branch of Invesalius3
brain_peelmastersurface

I am using the InVesaliuus MRI T1 file given the Downloads section of the Invesalius website. If the issue persists, could you give the file you are using and segmentation parameters (overlap, level of certainity etc...) So that I can reproduce it.

Note: Unchecking the Peel surface check box no longer disappears the peeled surface as it is being treated as regular surface now.
Peeled surface cannot be duplicated

@rmatsuda
Copy link
Collaborator

Hi! Many thanks for the fixes.

I found a bug: I tried to create a peel using a mask file, but it is not applying the transformations. It’s supposed to be overlapping each other. Please take a look at the brain mesh handler.
image

Another thing, the opacity is too blurry now. Look at how it was before:
image

@rmatsuda
Copy link
Collaborator

Regarding performance, it takes a while to change the peeling depth. I also noticed that the peel blinks twice. Could you try to optimize it, please?

@AksharaSBhat
Copy link
Contributor Author

Hi, could you guide me as to how can I get a mask file for creating a peel surface. Regarding the opacity, due to a bug in my code, opacity is treated as transparency, I will fix it. Could you please check and verify if reducing opacity(reducing transparency) removes the blurriness. I will also look into blinking of surface while changing depth, I believe it is being re-rendered twice

@AksharaSBhat
Copy link
Contributor Author

I have fixed the issue with opacity and added back face culling for peeled surfaces to remove the blurriness. Also, it no longer re-renders twice, so it only blinks once and it is relatively quick. I extracted a mask_1.plist from the inv3 file and used it to generate a peel surface and it perfectly overlapped with existing 3D surface. Could you tell me how can I reproduce the issues you are facing?

@AksharaSBhat
Copy link
Contributor Author

Could you please look into this again and if issues persist, tell me how to reproduce the issue @rmatsuda @paulojamorim. extracted a mask_1.plist from the inv3 file and used it to generate a peel surface and it perfectly overlapped with existing 3D surface. I have fixed the blurriness and blinking issue.

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.

Include the peeled brain surface in the Data menu as another "Surface"
2 participants