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: 🐛 IDC1346, properly detect binary segmentations declared as fractional #309

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions src/adapters/Cornerstone/Segmentation_4X.js
Original file line number Diff line number Diff line change
Expand Up @@ -1240,21 +1240,25 @@ function unpackPixelData(multiframe) {

const pixelData = new Uint8Array(data);

const max = multiframe.MaximumFractionalValue;
const onlyMaxAndZero =
pixelData.find(element => element !== 0 && element !== max) ===
undefined;

if (!onlyMaxAndZero) {
// This is a fractional segmentation, which is not currently supported.
return;
}
// IDC: we encountered segmentations defined as fractional with a constant pixel values which is not the MaximumFractionalValue.
// Here we add the following check: if the labelmap has a constant value (independently by the value itself), it is considered a binary segmentation
const firstNonZeroIndex = pixelData.findIndex(element => element > 0);
const firstNonZeroValue = pixelData[firstNonZeroIndex];
const onlyOneValueAndZero =
pixelData.find(
element => element !== 0 && element !== firstNonZeroValue
) === undefined;

if (onlyOneValueAndZero) {
log.warn(
"This segmentation object is actually binary... processing as such."
);

log.warn(
"This segmentation object is actually binary... processing as such."
);
return pixelData;
}

return pixelData;
// This is a fractional segmentation, which is not currently supported.
return;
}

/**
Expand Down