@cornerstonejs/adapters 5.11.7 → 5.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,10 @@
1
1
  import { utilities as utilities$1, normalizers, derivations, log } from 'dcmjs';
2
2
  import ndarray from 'ndarray';
3
3
  import getDatasetsFromImages from '../helpers/getDatasetsFromImages.js';
4
+ import { getValidOrientations, alignPixelDataWithSourceData } from './Segmentation_4X.js';
4
5
  import { utilities } from '@cornerstonejs/core';
5
6
 
6
7
  const cs3dLogger = utilities.logger.adaptersLog.getLogger('Cornerstone.Segmentation_3X');
7
- const _utilities$orientatio = utilities$1.orientation,
8
- rotateDirectionCosinesInPlane = _utilities$orientatio.rotateDirectionCosinesInPlane,
9
- flipIOP = _utilities$orientatio.flipImageOrientationPatient,
10
- flipMatrix2D = _utilities$orientatio.flipMatrix2D,
11
- rotateMatrix902D = _utilities$orientatio.rotateMatrix902D;
12
8
  const datasetToBlob = utilities$1.datasetToBlob,
13
9
  BitArray = utilities$1.BitArray,
14
10
  DicomMessage = utilities$1.DicomMessage,
@@ -316,80 +312,6 @@ function getImageIdOfReferencedFrame(sopInstanceUid, frameNumber, imageIds, meta
316
312
  });
317
313
  return imageId;
318
314
  }
319
-
320
- /**
321
- * getValidOrientations - returns an array of valid orientations.
322
- *
323
- * @param iop - The row (0..2) an column (3..5) direction cosines.
324
- * @return An array of valid orientations.
325
- */
326
- function getValidOrientations(iop) {
327
- const orientations = [];
328
-
329
- // [0, 1, 2]: 0, 0hf, 0vf
330
- // [3, 4, 5]: 90, 90hf, 90vf
331
- // [6, 7]: 180, 270
332
-
333
- orientations[0] = iop;
334
- orientations[1] = flipIOP.h(iop);
335
- orientations[2] = flipIOP.v(iop);
336
- const iop90 = rotateDirectionCosinesInPlane(iop, Math.PI / 2);
337
- orientations[3] = iop90;
338
- orientations[4] = flipIOP.h(iop90);
339
- orientations[5] = flipIOP.v(iop90);
340
- orientations[6] = rotateDirectionCosinesInPlane(iop, Math.PI);
341
- orientations[7] = rotateDirectionCosinesInPlane(iop, 1.5 * Math.PI);
342
- return orientations;
343
- }
344
-
345
- /**
346
- * alignPixelDataWithSourceData -
347
- *
348
- * @param pixelData2D - The data to align.
349
- * @param iop - The orientation of the image slice.
350
- * @param orientations - An array of valid imageOrientationPatient values.
351
- * @return The aligned pixelData.
352
- */
353
- function alignPixelDataWithSourceData(pixelData2D, iop, orientations) {
354
- if (compareIOP(iop, orientations[0])) {
355
- //Same orientation.
356
- return pixelData2D;
357
- } else if (compareIOP(iop, orientations[1])) {
358
- //Flipped vertically.
359
- return flipMatrix2D.v(pixelData2D);
360
- } else if (compareIOP(iop, orientations[2])) {
361
- //Flipped horizontally.
362
- return flipMatrix2D.h(pixelData2D);
363
- } else if (compareIOP(iop, orientations[3])) {
364
- //Rotated 90 degrees.
365
- return rotateMatrix902D(pixelData2D);
366
- } else if (compareIOP(iop, orientations[4])) {
367
- //Rotated 90 degrees and fliped horizontally.
368
- return flipMatrix2D.h(rotateMatrix902D(pixelData2D));
369
- } else if (compareIOP(iop, orientations[5])) {
370
- //Rotated 90 degrees and fliped vertically.
371
- return flipMatrix2D.v(rotateMatrix902D(pixelData2D));
372
- } else if (compareIOP(iop, orientations[6])) {
373
- //Rotated 180 degrees. // TODO -> Do this more effeciently, there is a 1:1 mapping like 90 degree rotation.
374
- return rotateMatrix902D(rotateMatrix902D(pixelData2D));
375
- } else if (compareIOP(iop, orientations[7])) {
376
- //Rotated 270 degrees. // TODO -> Do this more effeciently, there is a 1:1 mapping like 90 degree rotation.
377
- return rotateMatrix902D(rotateMatrix902D(rotateMatrix902D(pixelData2D)));
378
- }
379
- }
380
- const dx = 1e-5;
381
-
382
- /**
383
- * compareIOP - Returns true if iop1 and iop2 are equal
384
- * within a tollerance, dx.
385
- *
386
- * @param iop1 - An ImageOrientationPatient array.
387
- * @param iop2 - An ImageOrientationPatient array.
388
- * @return True if iop1 and iop2 are equal.
389
- */
390
- function compareIOP(iop1, iop2) {
391
- return Math.abs(iop1[0] - iop2[0]) < dx && Math.abs(iop1[1] - iop2[1]) < dx && Math.abs(iop1[2] - iop2[2]) < dx && Math.abs(iop1[3] - iop2[3]) < dx && Math.abs(iop1[4] - iop2[4]) < dx && Math.abs(iop1[5] - iop2[5]) < dx;
392
- }
393
315
  function getSegmentMetadata(multiframe) {
394
316
  const data = [];
395
317
  const segmentSequence = multiframe.SegmentSequence;
@@ -1,4 +1,5 @@
1
1
  export function generateSegmentation(images: object[], inputLabelmaps3D: any | any[], userOptions?: any): Blob;
2
+ export function getSegmentIndexForLabel(labelmap3D: any, labelValue: any): any;
2
3
  export function fillSegmentation(segmentation: any, inputLabelmaps3D: any, userOptions?: {}, images?: any[], metadata?: any): object;
3
4
  export function _getLabelmapsFromReferencedFrameIndicies(labelmap3D: any, referencedFrameIndicies: any): any[];
4
5
  export function _createSegFromImages(images: any[], isMultiframe: boolean, options: any): any;
@@ -12,8 +13,8 @@ export function getUnpackedChunks(data: any, maxBytesPerChunk: any): any[];
12
13
  export function getImageIdOfSourceImageBySourceImageSequence(SourceImageSequence: any, sopUIDImageIdIndexMap: any): string;
13
14
  export function getImageIdOfSourceImagebyGeometry(ReferencedSeriesInstanceUID: string, FrameOfReferenceUID: string, PerFrameFunctionalGroup: any, imageIds: string[], metadataProvider: any, tolerance: Float): string;
14
15
  export function getImageIdOfReferencedFrame(sopInstanceUid: string, frameNumber: number, sopUIDImageIdIndexMap: any): string;
15
- export function getValidOrientations(iop: any): any;
16
- export function alignPixelDataWithSourceData(pixelData2D: Ndarray, iop: any, orientations: any, tolerance: any): Ndarray;
16
+ export function getValidOrientations(iop: any | string): any;
17
+ export function alignPixelDataWithSourceData(pixelData2D: Ndarray, iop: any | string, orientations: any, tolerance: number): Ndarray | undefined;
17
18
  export function getSegmentMetadata(multiframe: any, seriesInstanceUid: any): {
18
19
  seriesInstanceUid: any;
19
20
  data: any[];