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

adds support for segmentations that has SegmentIdentificationSequence… #164

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
11 changes: 9 additions & 2 deletions src/adapters/Cornerstone/Segmentation_3X.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ function generateToolState(imageIds, arrayBuffer, metadataProvider) {
.ImageOrientationPatient
: undefined;

const sharedReferencedSegmentNumber = SharedFunctionalGroupsSequence.SegmentIdentificationSequence
? SharedFunctionalGroupsSequence.SegmentIdentificationSequence
.ReferencedSegmentNumber - 1
: undefined;

const sliceLength = multiframe.Columns * multiframe.Rows;
const segMetadata = getSegmentMetadata(multiframe);
const pixelData = unpackPixelData(multiframe);
Expand Down Expand Up @@ -309,9 +314,9 @@ function generateToolState(imageIds, arrayBuffer, metadataProvider) {
}

const segmentIndex =
sharedReferencedSegmentNumber ||
PerFrameFunctionalGroups.SegmentIdentificationSequence
.ReferencedSegmentNumber - 1;

let SourceImageSequence;
if (
SharedFunctionalGroupsSequence.DerivationImageSequence &&
Expand All @@ -320,7 +325,9 @@ function generateToolState(imageIds, arrayBuffer, metadataProvider) {
) {
SourceImageSequence =
SharedFunctionalGroupsSequence.DerivationImageSequence
.SourceImageSequence[i];
.SourceImageSequence[i] ||
SharedFunctionalGroupsSequence.DerivationImageSequence
.SourceImageSequence;
} else {
SourceImageSequence =
PerFrameFunctionalGroups.DerivationImageSequence
Expand Down
29 changes: 27 additions & 2 deletions src/adapters/Cornerstone/Segmentation_4X.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,13 +661,23 @@ function checkSEGsOverlapping(
}

const segmentIndex =
sharedReferencedSegmentNumber ||
PerFrameFunctionalGroups.SegmentIdentificationSequence
.ReferencedSegmentNumber;

let SourceImageSequence;

if (multiframe.SourceImageSequence) {
SourceImageSequence = multiframe.SourceImageSequence[i];
} else if (
SharedFunctionalGroupsSequence.DerivationImageSequence &&
SharedFunctionalGroupsSequence.DerivationImageSequence
.SourceImageSequence
) {
SourceImageSequence =
SharedFunctionalGroupsSequence.DerivationImageSequence
.SourceImageSequence[i] ||
SharedFunctionalGroupsSequence.DerivationImageSequence
.SourceImageSequence;
} else {
SourceImageSequence =
PerFrameFunctionalGroups.DerivationImageSequence
Expand Down Expand Up @@ -919,6 +929,11 @@ function insertPixelDataPlanar(
: undefined;
const sliceLength = Columns * Rows;

const sharedReferencedSegmentNumber = SharedFunctionalGroupsSequence.SegmentIdentificationSequence
? SharedFunctionalGroupsSequence.SegmentIdentificationSequence
.ReferencedSegmentNumber
: undefined;

for (
let i = 0, groupsLen = PerFrameFunctionalGroupsSequence.length;
i < groupsLen;
Expand Down Expand Up @@ -952,13 +967,23 @@ function insertPixelDataPlanar(
}

const segmentIndex =
sharedReferencedSegmentNumber ||
PerFrameFunctionalGroups.SegmentIdentificationSequence
.ReferencedSegmentNumber;

let SourceImageSequence;

if (multiframe.SourceImageSequence) {
SourceImageSequence = multiframe.SourceImageSequence[i];
} else if (
SharedFunctionalGroupsSequence.DerivationImageSequence &&
SharedFunctionalGroupsSequence.DerivationImageSequence
.SourceImageSequence
) {
SourceImageSequence =
SharedFunctionalGroupsSequence.DerivationImageSequence
.SourceImageSequence[i] ||
SharedFunctionalGroupsSequence.DerivationImageSequence
.SourceImageSequence;
} else {
SourceImageSequence =
PerFrameFunctionalGroups.DerivationImageSequence
Expand Down