Skip to content

Commit 4736ff1

Browse files
committed
fix: šŸ› IDC1346, properly detect binary segmentations declared as fractional
1 parent 42a7ca7 commit 4736ff1

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

ā€Žsrc/adapters/Cornerstone/Segmentation_4X.jsā€Ž

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,21 +1240,25 @@ function unpackPixelData(multiframe) {
12401240

12411241
const pixelData = new Uint8Array(data);
12421242

1243-
const max = multiframe.MaximumFractionalValue;
1244-
const onlyMaxAndZero =
1245-
pixelData.find(element => element !== 0 && element !== max) ===
1246-
undefined;
1247-
1248-
if (!onlyMaxAndZero) {
1249-
// This is a fractional segmentation, which is not currently supported.
1250-
return;
1251-
}
1243+
// IDC: we encountered segmentations defined as fractional with a constant pixel values which is not the MaximumFractionalValue.
1244+
// Here we add the following check: if the labelmap has a constant value (independently by the value itself), it is considered a binary segmentation
1245+
const firstNonZeroIndex = pixelData.findIndex(element => element > 0);
1246+
const firstNonZeroValue = pixelData[firstNonZeroIndex];
1247+
const onlyOneValueAndZero =
1248+
pixelData.find(
1249+
element => element !== 0 && element !== firstNonZeroValue
1250+
) === undefined;
1251+
1252+
if (onlyOneValueAndZero) {
1253+
log.warn(
1254+
"This segmentation object is actually binary... processing as such."
1255+
);
12521256

1253-
log.warn(
1254-
"This segmentation object is actually binary... processing as such."
1255-
);
1257+
return pixelData;
1258+
}
12561259

1257-
return pixelData;
1260+
// This is a fractional segmentation, which is not currently supported.
1261+
return;
12581262
}
12591263

12601264
/**

0 commit comments

Comments
Ā (0)