Skip to content

Conversation

@sedghi
Copy link
Member

@sedghi sedghi commented Dec 17, 2025

This pull request adds support for splitting multiframe 4D images (such as NM Multi-frame SPECT/PET) by leveraging DICOM's TimeSlotVector and SliceVector tags. The main focus is on enabling correct grouping of image frames by time slots and slices for advanced 4D image handling. Additionally, it updates the ImageVolume class to improve its handling of time points and dynamic volume detection.

Multiframe 4D support and image grouping:

  • Added logic in splitImageIdsBy4DTags.ts to detect and handle multiframe 4D images using the DICOM TimeSlotVector (0054,0070) and SliceVector (0054,0080) tags, generating frame-specific imageIds and grouping them by time slot. This enables correct splitting of NM multi-frame images for 4D visualization and analysis. [1] [2]
  • Introduced the handleMultiframe4D function and supporting types to encapsulate the splitting logic and result structure.
  • Updated the main splitImageIdsBy4DTags function to use the new multiframe splitting logic before falling back to previous grouping methods.

ImageVolume class improvements:

  • Refactored the deprecated numTimePoints property in ImageVolume to a getter that dynamically returns the number of dimension groups (time points), defaulting to 1 if not available.
  • Improved the isDynamicVolume method in ImageVolume to use the new numTimePoints getter, providing more robust detection of 4D (dynamic) volumes.

Copilot AI review requested due to automatic review settings December 17, 2025 22:42
@sedghi sedghi changed the title 4d issues fix: 4d for timeslot vector Dec 17, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request addresses issues related to 4D (dynamic) volume handling in Cornerstone3D. It refactors the deprecated numTimePoints property in ImageVolume to use a getter that accesses numDimensionGroups from StreamingDynamicImageVolume, and adds support for multiframe 4D image splitting using DICOM Nuclear Medicine tags (TimeSlotVector and SliceVector).

Key changes:

  • Refactored numTimePoints from a nullable property to a getter that provides backward compatibility
  • Updated isDynamicVolume() logic to properly handle the getter-based numTimePoints
  • Added new handleMultiframe4D() function to split multiframe images by TimeSlotVector (0054,0070) and SliceVector (0054,0080) tags for NM gated SPECT/PET images

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
packages/core/src/cache/classes/ImageVolume.ts Converts deprecated numTimePoints from a nullable field to a getter that accesses numDimensionGroups for backward compatibility, and updates isDynamicVolume() to handle the new getter
packages/core/src/utilities/splitImageIdsBy4DTags.ts Adds multiframe 4D splitting support via new handleMultiframe4D() and generateFrameImageId() functions that process TimeSlotVector and SliceVector DICOM tags for Nuclear Medicine images

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@wayfarer3130 wayfarer3130 left a comment

Choose a reason for hiding this comment

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

Can you add testing notes as to which study to try loading to test this? Even if it has to link with OHIF to do it, I'd like to be able to run this. I can upload a new dataset if required.
Can you address the copilot issues - for the frame numbers, I would suggest adding an endpoint to the metadata which returns all imageIds for the given sop class, and then just use the index. Otherwise you could pass the imageIds list into this function instead of trying to parse/generate image ids.

@sedghi
Copy link
Member Author

sedghi commented Dec 19, 2025

Can you add testing notes as to which study to try loading to test this? Even if it has to link with OHIF to do it, I'd like to be able to run this. I can upload a new dataset if required. Can you address the copilot issues - for the frame numbers, I would suggest adding an endpoint to the metadata which returns all imageIds for the given sop class, and then just use the index. Otherwise you could pass the imageIds list into this function instead of trying to parse/generate image ids.

This issue has the data OHIF/Viewers#5554
It requires another PR in OHIF, to also handle the multiframe NM 4D. I suggest we merge this after review, and then in my PR to OHIF you test

Update: here is the OHIF PR OHIF/Viewers#5666

…ameImageId functions; add tests for multiframe 4D functionality
…ageId and add validation for SliceVector in handleMultiframe4D
… logging in handleMultiframe4D for SliceVector validation
@wayfarer3130
Copy link
Collaborator

@sedghi - I'm not sure what is going on with the docusaurus build

@wayfarer3130 wayfarer3130 merged commit 0ac04dc into main Dec 19, 2025
10 checks passed
@wayfarer3130 wayfarer3130 deleted the 4d-issues branch December 19, 2025 19:39
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.

4 participants