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

feat(voi): add linear exact voi lut function #1717

Merged
merged 4 commits into from
Dec 20, 2024
Merged

Conversation

sedghi
Copy link
Member

@sedghi sedghi commented Dec 18, 2024

related OHIF/Viewers#4298
related OHIF/Viewers#4538

This pull request includes an important update to the toLowHighRange function in the packages/core/src/utilities/windowLevel.ts file. The change adds a conditional check to handle cases where windowWidth or windowCenter are less than 1, providing a fallback calculation for the lower and upper values.

Key change:

  • packages/core/src/utilities/windowLevel.ts: Added a conditional check in the toLowHighRange function to handle cases where windowWidth or windowCenter are less than 1, and provided a fallback calculation for lower and upper values.

Copy link

stackblitz bot commented Dec 18, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

netlify bot commented Dec 18, 2024

Deploy Preview for cornerstone-3d-docs failed. Why did it fail? →

Name Link
🔨 Latest commit 9b3836d
🔍 Latest deploy log https://app.netlify.com/sites/cornerstone-3d-docs/deploys/67648ca466ad1600086da1a6

const lower = windowCenter - 0.5 - (windowWidth - 1) / 2;
const upper = windowCenter - 0.5 + (windowWidth - 1) / 2;
if (windowWidth < 1 || windowCenter < 1) {
// use fallback
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add a console.warn('Non DICOM standard compliant width/center", windowWidth, windowCenter)

@@ -41,10 +41,18 @@ function toLowHighRange(
lower: number;
upper: number;
} {
const lower = windowCenter - 0.5 - (windowWidth - 1) / 2;
const upper = windowCenter - 0.5 + (windowWidth - 1) / 2;
if (windowWidth < 1 || windowCenter < 1) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Only check windowWidth, the windowCenter should be allowed to be bigger.


return { lower, upper };
return {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add a comment:
// This definition is from the DICOM standard PS3.3

…ring and metadata processes

- Added voiLUTFunction to viewport VOI settings in StackViewport and related utilities.
- Updated window level calculations to consider voiLUTFunction for accurate range determination.
- Enhanced metadata extraction to include voiLUTFunction from DICOM data.
- Introduced new logit utility for improved sigmoid function handling in window level transformations.
- Updated relevant types and interfaces to accommodate voiLUTFunction.

This change improves the flexibility and accuracy of volume rendering based on user-defined LUT functions.
@sedghi sedghi changed the title fix: fallback for small window levels feat(voi): add linear exact voi lut function Dec 19, 2024
@sedghi sedghi merged commit faf3b9d into main Dec 20, 2024
22 of 26 checks passed
const imageIdIndex = Math.floor(imageIds.length / 2);
const imageId = imageIds[imageIdIndex];
const voiLutModule = metaData.get('voiLutModule', imageId);
if (voiLutModule?.windowWidth && voiLutModule.windowCenter) {
if (voiLutModule && voiLutModule.windowWidth && voiLutModule.windowCenter) {
voi.voiLUTFunction = voiLutModule.voiLUTFunction;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is not always defined, it's crashing tests in OHIF

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.

3 participants