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

BUG: Ensure DICOMUtils.loadLoadables do not return temporary nodes #7079

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jcfr
Copy link
Member

@jcfr jcfr commented Jul 10, 2023

Since loader may add temporary nodes to the scene while loading a file, this function makes sure these are not included in the list of returned node IDs.

Example of such loaded is UltrasoundImage3dReaderFileReader adding a temporary node to construct the volume sequence.

See https://github.com/SlicerHeart/SlicerHeart/blob/52eeb23576c7eda14dbe3e602667f4c5b68c4475/UltrasoundImage3dReader/UltrasoundImage3dReader.py#L172-L173

@jcfr jcfr requested a review from lassoan July 10, 2023 22:27
@jcfr jcfr force-pushed the ensure-DICOMUtils-loadLoadables-filterout-temporary-nodes branch from 8841356 to 72df345 Compare July 10, 2023 22:28
Copy link
Contributor

@lassoan lassoan left a comment

Choose a reason for hiding this comment

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

It looks OK to me, but I think this is an error case, so we should log a warning to make developers aware that something is not correct.

@lassoan lassoan added this to the Slicer 5.3 milestone Jul 12, 2023
@jcfr
Copy link
Member Author

jcfr commented Jul 12, 2023

re: so we should log a warning to make developers aware that something is not correct.

Nodes may have been removed in two cases:

  1. An exception was raised during import and partially initialized nodes are removed
  2. A temporary was legitimately created as part of the import. For, see UltrasoundImage3dReader.py1

To "fix" UltrasoundImage3dReader.py, should we create a miniScene and only copy node into the main scene at the end of the reading process ? Similar to what is done in ReadDataRequestScene::Execute()2 ?

We could then recommend this pattern for reader plugin creating multiple nodes.

Footnotes

  1. https://github.com/SlicerHeart/SlicerHeart/blob/52eeb23576c7eda14dbe3e602667f4c5b68c4475/UltrasoundImage3dReader/UltrasoundImage3dReader.py#L172-L173

  2. https://github.com/Slicer/Slicer/blob/cecf2c5f45af0a1361c1b1b9555eef82b9355eb7/Base/Logic/vtkSlicerApplicationLogicRequests.h#L293

@jcfr
Copy link
Member Author

jcfr commented Jul 25, 2023

Following July 25th developer meeting, observing the scene node removed event should allow to more cleanly handle this.

@jcfr jcfr self-assigned this Jul 27, 2023
jcfr and others added 2 commits July 31, 2023 19:57
Since loader may add temporary nodes to the scene while loading a file,
this function makes sure these are not included in the list of returned
node IDs.
…robust

To ensure that only node effectively removed from the scene are
excluded from the "loadedNodeIDs" list, this commit revisits the approach
to observe the "NodeRemoveEvent".

Co-authored-by: Sam Horvath <[email protected]>
@jcfr jcfr force-pushed the ensure-DICOMUtils-loadLoadables-filterout-temporary-nodes branch from 72df345 to 5d88db5 Compare August 1, 2023 02:52
@jcfr
Copy link
Member Author

jcfr commented Aug 1, 2023

Thanks @sjh26 and @lassoan for the feedback, I will add a test for this and then this will be ready for integration.

@jcfr jcfr modified the milestones: Slicer 5.3, Slicer 5.5 Aug 1, 2023
@jcfr jcfr modified the milestones: Slicer 5.5, Slicer 5.7 Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants