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(tools): Some older annotations were missing normal #528

Merged
merged 1 commit into from
Mar 28, 2023
Merged
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
3 changes: 2 additions & 1 deletion packages/tools/src/utilities/cine/playClip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
StackViewport,
VolumeViewport,
cache,
BaseVolumeViewport,
} from '@cornerstonejs/core';

import { Types } from '@cornerstonejs/core';
Expand Down Expand Up @@ -301,7 +302,7 @@ function _getVolumeFromViewport(viewport): Types.IImageVolume {
const actorEntry = viewport.getDefaultActor();

if (!actorEntry) {
console.warn('No actor found');
// This can happen during setup/teardown of viewports.
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { vec3 } from 'gl-matrix';
import { CONSTANTS } from '@cornerstonejs/core';
import { CONSTANTS, metaData } from '@cornerstonejs/core';
import type { Types } from '@cornerstonejs/core';
import { Annotations, Annotation } from '../../types';
import { debug } from 'console';

const { EPSILON } = CONSTANTS;

Expand Down Expand Up @@ -33,8 +34,33 @@ export default function filterAnnotationsWithinSlice(
// logic down below.
const annotationsWithParallelNormals = annotations.filter(
(td: Annotation) => {
const annotationViewPlaneNormal = td.metadata.viewPlaneNormal;

let annotationViewPlaneNormal = td.metadata.viewPlaneNormal;

if (!annotationViewPlaneNormal) {
// This code is run to set the annotation view plane normal
// for historical data which was saved without the normal.
const { referencedImageId } = td.metadata;
const { imageOrientationPatient } = metaData.get(
'imagePlaneModule',
referencedImageId
);
const rowCosineVec = vec3.fromValues(
imageOrientationPatient[0],
imageOrientationPatient[1],
imageOrientationPatient[2]
);

const colCosineVec = vec3.fromValues(
imageOrientationPatient[3],
imageOrientationPatient[4],
imageOrientationPatient[5]
);

annotationViewPlaneNormal = vec3.create() as Types.Point3;

vec3.cross(annotationViewPlaneNormal, rowCosineVec, colCosineVec);
td.metadata.viewPlaneNormal = annotationViewPlaneNormal;
}
const isParallel =
Math.abs(vec3.dot(viewPlaneNormal, annotationViewPlaneNormal)) >
PARALLEL_THRESHOLD;
Expand Down