dcmjs
dcmjs copied to clipboard
fix(Segmentation): Support only one frame
Fix: https://github.com/cornerstonejs/cornerstone3D/issues/1059#issuecomment-2155718355
Deploy Preview for dcmjs2 ready!
| Name | Link |
|---|---|
| Latest commit | c333cbd99ed2f1ad03010d972f58a09453a1e57e |
| Latest deploy log | https://app.netlify.com/sites/dcmjs2/deploys/66639dd4c98f8b00081d7556 |
| Deploy Preview | https://deploy-preview-395--dcmjs2.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Thanks for investigating this and providing the PR with a link to the cornerstone issue. While that link is helpful, please make your contribution here self-contained and describe in your commit message, and in code comments as needed, specifically, please clarify:
- what the issue is you are trying to fix
- what the behavior is without this change
- what the behavior is after this change
- why this change fixes the issue
- why you don't think this will have any side-effects for other code in the future
It would also be great to have a unit test that illustrates this. That is, a test that demonstrates a valid use-case that fails without this change but works with the change.
Also, see the guidelines for commit messages and correct your commit as indicated: https://github.com/dcmjs-org/dcmjs?tab=readme-ov-file#for-maintainers-and-contributors
I don't mean to be super-picky here, but this repo is used by a lot of people and subtle bugs can occur if we aren't careful. I want to be sure someone who sees your contribution in the future fully understands it.
generateSegmentation supports two or more frames and does not support just one frame and gives an error.
When testing just one frame for example:
Cornerstone3D.Segmentation.generateSegmentation([cacheImage], labelmapData, metaData);
and shows the results of errors.
First Error
let distance1 = distanceDatasetPairs[1][0];
So I created a new variable, distance1 is zero, for just one frame. But if NumberOfFrames was two or more get this distanceDatasetPairs[1][0].
// If the frame is one, it is zero
let distance1 = 0;
if (ds.NumberOfFrames > 1) {
distance1 = distanceDatasetPairs[1][0];
}
Second Error
if (ds.NumberOfFrames === 1)
ds.PerFrameFunctionalGroupsSequence = [
ds.PerFrameFunctionalGroupsSequence
];
I removed this code and it works similar to two or more frames. But I don't know what it does, I have little knowledge of segmentation in dicom.
The result:
There is another way without using this pull request or change.
How does just one frame work:
Cornerstone3D.Segmentation.generateSegmentation(
[cacheImage, cacheImage],
labelmapData,
metaData
);
[cacheImage, cacheImage] both "cacheImage" are the same, just ignore it and it works only one frame.