How to use the cornerstone-core.metaData function in cornerstone-core

To help you get started, we’ve selected a few cornerstone-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OHIF / Viewers / OHIFViewer-react / src / connectedComponents / OHIFCornerstoneViewportPlugin / OHIFCornerstoneViewportPlugin.js View on Github external
import OHIF from 'ohif-core';
import ConnectedCornerstoneViewport from './ConnectedCornerstoneViewport';
import OHIFComponentPlugin from '../OHIFComponentPlugin.js';
import cornerstoneTools from "cornerstone-tools";
import cornerstone from "cornerstone-core";
import './config';

const { StackManager } = OHIF.utils;

// Create the synchronizer used to update reference lines
OHIF.viewer.updateImageSynchronizer = new cornerstoneTools.Synchronizer('cornerstonenewimage', cornerstoneTools.updateImageSynchronizer);

// Metadata configuration
const metadataProvider = new OHIF.cornerstone.MetadataProvider();

cornerstone.metaData.addProvider(metadataProvider.provider.bind(metadataProvider));

StackManager.setMetadataProvider(metadataProvider);

class OHIFCornerstoneViewportPlugin extends Component {
  static propTypes = {
    studies: PropTypes.object,
    displaySet: PropTypes.object,
    viewportIndex: PropTypes.number,
  };

  static id = 'CornerstoneViewportPlugin';

  static init() {
    console.log('CornerstoneViewportPlugin init()');
  }
github OHIF / Viewers / extensions / cornerstone / src / OHIFCornerstoneViewport.js View on Github external
import React, { Component } from 'react';

import ConnectedCornerstoneViewport from './ConnectedCornerstoneViewport';
import OHIF from '@ohif/core';
import PropTypes from 'prop-types';
import cornerstone from 'cornerstone-core';
import handleSegmentationStorage from './handleSegmentationStorage.js';

const { StackManager } = OHIF.utils;

// Metadata configuration
const metadataProvider = new OHIF.cornerstone.MetadataProvider();

cornerstone.metaData.addProvider(
  metadataProvider.provider.bind(metadataProvider)
);

StackManager.setMetadataProvider(metadataProvider);

const SOP_CLASSES = {
  SEGMENTATION_STORAGE: '1.2.840.10008.5.1.4.1.1.66.4',
};

const specialCaseHandlers = {};
specialCaseHandlers[
  SOP_CLASSES.SEGMENTATION_STORAGE
] = handleSegmentationStorage;

class OHIFCornerstoneViewport extends Component {
  state = {
github OHIF / ohif-core / src / measurements / lib / getImageAttributes.js View on Github external
export default function(element) {
  // Get the Cornerstone imageId
  const enabledElement = cornerstone.getEnabledElement(element);
  const imageId = enabledElement.image.imageId;

  // Get studyInstanceUid & patientId
  const study = cornerstone.metaData.get('study', imageId);
  const studyInstanceUid = study.studyInstanceUid;
  const patientId = study.patientId;

  // Get seriesInstanceUid
  const series = cornerstone.metaData.get('series', imageId);
  const seriesInstanceUid = series.seriesInstanceUid;

  // Get sopInstanceUid
  const sopInstance = cornerstone.metaData.get('instance', imageId);
  const sopInstanceUid = sopInstance.sopInstanceUid;
  const frameIndex = sopInstance.frame || 0;

  const imagePath = [
    studyInstanceUid,
    seriesInstanceUid,
    sopInstanceUid,
github OHIF / ohif-core / src / measurements / lib / getImageAttributes.js View on Github external
export default function(element) {
  // Get the Cornerstone imageId
  const enabledElement = cornerstone.getEnabledElement(element);
  const imageId = enabledElement.image.imageId;

  // Get studyInstanceUid & patientId
  const study = cornerstone.metaData.get('study', imageId);
  const studyInstanceUid = study.studyInstanceUid;
  const patientId = study.patientId;

  // Get seriesInstanceUid
  const series = cornerstone.metaData.get('series', imageId);
  const seriesInstanceUid = series.seriesInstanceUid;

  // Get sopInstanceUid
  const sopInstance = cornerstone.metaData.get('instance', imageId);
  const sopInstanceUid = sopInstance.sopInstanceUid;
  const frameIndex = sopInstance.frame || 0;

  const imagePath = [
    studyInstanceUid,
    seriesInstanceUid,
    sopInstanceUid,
    frameIndex,
  ].join('_');

  return {
    patientId,
github OHIF / Viewers / extensions / cornerstone / src / init.js View on Github external
function fallbackMetaDataProvider(type, imageId) {
  if (!imageId.includes('wado?requestType=WADO')) {
    return;
  }

  // If you call for an WADO-URI imageId and get no
  // metadata, try reformatting to WADO-RS imageId
  const qs = queryString.parse(imageId);
  const wadoRoot = window.store.getState().servers.servers[0].wadoRoot;
  const wadoRsImageId = `wadors:${wadoRoot}/studies/${qs.studyUID}/series/${
    qs.seriesUID
  }/instances/${qs.objectUID}/frames/${qs.frame || 1}`;

  return cornerstone.metaData.get(type, wadoRsImageId);
}
github OHIF / Viewers / extensions / vtk / src / OHIFVTKViewport.js View on Github external
import LoadingIndicator from './LoadingIndicator.js';
import OHIF from '@ohif/core';
import PropTypes from 'prop-types';
import cornerstone from 'cornerstone-core';
import handleSegmentationStorage from './handleSegmentationStorage.js';
import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray';
import vtkImageData from 'vtk.js/Sources/Common/DataModel/ImageData';
import vtkVolume from 'vtk.js/Sources/Rendering/Core/Volume';
import vtkVolumeMapper from 'vtk.js/Sources/Rendering/Core/VolumeMapper';

const { StackManager } = OHIF.utils;

// Metadata configuration
const metadataProvider = new OHIF.cornerstone.MetadataProvider();

cornerstone.metaData.addProvider(
  metadataProvider.provider.bind(metadataProvider)
);

StackManager.setMetadataProvider(metadataProvider);

const SOP_CLASSES = {
  SEGMENTATION_STORAGE: '1.2.840.10008.5.1.4.1.1.66.4',
};

const specialCaseHandlers = {};
specialCaseHandlers[
  SOP_CLASSES.SEGMENTATION_STORAGE
] = handleSegmentationStorage;

// TODO: Figure out where we plan to put this long term
const volumeCache = {};
github OHIF / ohif-core / src / classes / StackImagePositionOffsetSynchronizer.js View on Github external
getViewportImageNormal(element) {
    if (!element) {
      return;
    }

    element = $(element).get(0);

    try {
      const enabledElement = cornerstone.getEnabledElement(element);

      if (!enabledElement.image) {
        return;
      }

      const imageId = enabledElement.image.imageId;
      const imagePlane = cornerstone.metaData.get('imagePlane', imageId);

      if (!imagePlane || !imagePlane.rowCosines || !imagePlane.columnCosines) {
        return;
      }

      return imagePlane.rowCosines.clone().cross(imagePlane.columnCosines);
    } catch (error) {
      const errorMessage = error.message || error;
      log.info(
        `StackImagePositionOffsetSynchronizer getViewportImageNormal: ${errorMessage}`
      );
    }
  }
}
github OHIF / Viewers / platform / viewer / src / lib / DICOMSR / parseMeasurementsData.js View on Github external
toolState[imageId][toolType].data.push(annotation);
      } else {
        unsupportedTools.push(toolType);
      }
    });
  });

  if (unsupportedTools.length > 0) {
    log.warn(
      `[DICOMSR] Tooltypes not supported: ${unsupportedTools.join(', ')}`
    );
  }

  const report = MeasurementReport.generateReport(
    toolState,
    cornerstone.metaData
  );

  return {
    dataset: report.dataset,
  };
};
github cornerstonejs / react-cornerstone-viewport / src / metadataProvider.js View on Github external
return {
      frameTime: dataSet.float('x00181063'),
    };
  }

  if (dataSet.elements[type] !== undefined) {
    const element = dataSet.elements[type];
    if (!element.vr) {
      return;
    }

    return dicomParser.explicitElementToString(dataSet, element);
  }
}

cornerstone.metaData.addProvider(wadoUriMetaDataProvider);
github OHIF / Viewers / extensions / cornerstone / src / handleSegmentationStorage.js View on Github external
function parseSeg(arrayBuffer, imageIds) {
  return dcmjs.adapters.Cornerstone.Segmentation.generateToolState(
    imageIds,
    arrayBuffer,
    cornerstone.metaData
  );
}