- Registering Decoders : I register the necessary decoders (DJDecoderRegistration and DcmRLEDecoderRegistration) for handling compressed DICOM images.
- Loading the DICOM File: I use DcmFileFormat to load the multi-frame DICOM file.
- Creating an Output Directory: I ensure that the output directory is clean by removing any existing files and then creating a fresh directory.
- Checking Dataset Validity: I retrieve the dataset from the loaded file and ensure it is valid.
- Decompressing if Required: If the dataset is compressed, I attempt to decompress it using chooseRepresentation(EXS_LittleEndianExplicit, nullptr).
- Extracting Number of Frames:
- I first try findAndGetUint16(DCM_NumberOfFrames, numFrames).
- If that fails, I attempt to get the frame count from DCM_PerFrameFunctionalGroupsSequence.
- If both fail, I return an error.
- Extracting Pixel Data:
- I retrieve the DCM_PixelData element.
- I determine the uncompressed frame size.
- I allocate memory for each frame.
- Saving Individual Frames:
- I iterate over each frame, create a new DcmFileFormat object, and copy the dataset.
- I remove multi-frame attributes like DCM_NumberOfFrames, DCM_SharedFunctionalGroupsSequence, and DCM_PerFrameFunctionalGroupsSequence.
- I generate a new SOPInstanceUID for each frame.
- I set the DCM_InstanceNumber sequentially.
- I extract the frame data using getUncompressedFrame() and store it in the new dataset.
- I save the new single-frame DICOM file in the specified directory.
- Final Cleanup: I unregister the decoders to free resources.
- Issue Faced:
- The extracted single-frame DICOM slices are correctly saved and can be opened individually.
- However, when trying to view them in RadiAnt DICOM Viewer, the MPR (Multi-Planar Reconstruction) functionality does not work.
I would like to resolve this problem. Any insights or suggestions would be greatly appreciated.