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

Threshold preview tool #534

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kunjesh1
Copy link

Threshold preview tool

  • Shows the preview of threshold for a given HU range

Screenshot 2023-03-30 at 1 44 33 PM

@netlify
Copy link

netlify bot commented Mar 30, 2023

Deploy Preview for cornerstone-3d-docs ready!

Name Link
🔨 Latest commit 937d46f
🔍 Latest deploy log https://app.netlify.com/sites/cornerstone-3d-docs/deploys/6425b8da0c871f000810b486
😎 Deploy Preview https://deploy-preview-534--cornerstone-3d-docs.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 settings.

@kunjesh1
Copy link
Author

screen-recording-2023-03-30-at-14552-pm_ws91ep70.mp4

Comment on lines 41 to 57
const callback = ({ value, index, pointIJK }) => {
if (segmentsLocked.includes(value)) {
return;
}

const {
THRESHOLD_INSIDE_CUBE: { threshold },
} = strategySpecificConfiguration;

const voxelValue = imageVolume.scalarData[index];

if (threshold[0] <= voxelValue && voxelValue <= threshold[1]) {
scalarData[index] = segmentIndex;
} else {
scalarData[index] = 0;
}
};
Copy link
Member

Choose a reason for hiding this comment

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

This callback is getting run more than a million times, it should be as simple as possible and avoid destructuring as much as possible. For instance

    const {
      THRESHOLD_INSIDE_CUBE: { threshold },
    } = strategySpecificConfiguration;

can be moved outside

Copy link
Author

@kunjesh1 kunjesh1 Mar 30, 2023

Choose a reason for hiding this comment

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

Yup , it is checking for every voxel value , any suggestion for optimising this . I am thinking can i declare a callback in a variable and when their is threshold will return the callback else not ?

const actors = viewport.getActors();

const firstVolumeActorUID = actors[0].uid;
const imageVolume = cache.getVolume(firstVolumeActorUID);
Copy link
Member

Choose a reason for hiding this comment

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

can you please look at packages/core/src/utilities/getTargetVolumeAndSpacingInNormalDir.ts to see how we find the primary volume? maybe refactor that code inside a util in core

const intervalTime = 16;
const numberOfFrames = Math.ceil(animationLength / intervalTime);

clearInterval(this.highlightIntervalId);
Copy link
Member

Choose a reason for hiding this comment

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

we have all the logic above inside packages/tools/src/tools/displayTools/Labelmap/labelmapDisplay.ts in render almost, and we hit that also on each segmentation updated, so I'm thinking maybe we augment that render to be able to handle animations like below. My thought would be to add something like animationType Enums, and for now we have easeInOutBell and then there if that is presented inside the segmentationRepresentation as key, we add animation. What do you think?

Copy link
Author

Choose a reason for hiding this comment

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

Nice idea , will implement that

Copy link
Member

@sedghi sedghi left a comment

Choose a reason for hiding this comment

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

Cool tool, see my comments please

…roup, moved easeInOut to the animation helper
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.

2 participants