fix(SegmentationState): only activate first segment if it exists #2479
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
This change was already there in a previous version:
cornerstone3D/packages/tools/src/stateManagement/segmentation/internalAddSegmentationRepresentation.ts
Lines 37 to 44 in b1979f6
But was removed again in the current
mainbranch (via a1ed218):cornerstone3D/packages/tools/src/stateManagement/segmentation/internalAddSegmentationRepresentation.ts
Lines 53 to 60 in e7b0cea
-> this breaks the expected behavior of segmentations, as they now always load with an empty segment with index 1, because
activateSegmentIndexis called and this creates the non-existing segment with an empty label''. We should not do this, and rather expect the application to handle the case of an initially empty segmentation.If we add an empty segment automatically, it is harder for the application to handle the initial state for empty segmentations -> they might need to always remove this segment if it exists, e.g., if they want to check if no segment exists yet. Otherwise the user might start drawing with a non-existent segment index.
Changes & Results
Before: empty segmentations are loaded with an empty segment with index 1.
After: empty segmentations are empty after loading (contain no segments).
Testing
Checklist
PR
semantic-release format and guidelines.
Code
etc.)
Public Documentation Updates
additions or removals.
Tested Environment