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

fix(Segmentation): Support only one frame #395

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jlopes90
Copy link

@jlopes90 jlopes90 commented Jun 7, 2024

Copy link

netlify bot commented Jun 7, 2024

Deploy Preview for dcmjs2 ready!

Name Link
🔨 Latest commit c333cbd
🔍 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...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@pieper
Copy link
Collaborator

pieper commented Jun 8, 2024

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.

@jlopes90
Copy link
Author

jlopes90 commented Jun 10, 2024

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];

image
image

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
    ];

image
image
image

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:

image

@jlopes90 jlopes90 changed the title fix(Segmentation): Fix only one frame fix(Segmentation): Support only one frame Jun 10, 2024
@jlopes90
Copy link
Author

jlopes90 commented Jun 20, 2024

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.

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.

How to export and import segmentation in stack?
2 participants