How to use dcmjs - 10 common examples

To help you get started, we’ve selected a few dcmjs 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 / extensions / vtk / src / handleSegmentationStorage.js View on Github external
// from google cloud
  const wadoRoot = displaySet.images[0].getData().wadoRoot;

  const StudyInstanceUID = displaySet.images[0].getStudyInstanceUID();
  const SeriesInstanceUID = displaySet.images[0].getSeriesInstanceUID();
  const SOPInstanceUID = displaySet.images[0].getSOPInstanceUID();

  const arrayBuffer = await retrieveDicomData(
    StudyInstanceUID,
    SeriesInstanceUID,
    SOPInstanceUID,
    wadoRoot
  );

  const dicomData = dcmjs.data.DicomMessage.readFile(arrayBuffer);
  const dataset = dcmjs.data.DicomMetaDictionary.naturalizeDataset(
    dicomData.dict
  );

  const segments = dcmjs.adapters.VTKjs.Segmentation.generateSegments(dataset);

  dataset._meta = dcmjs.data.DicomMetaDictionary.namifyDataset(dicomData.meta);

  const seriesInstanceUid = dataset.ReferencedSeriesSequence.SeriesInstanceUID;
  const displaySets = getDisplaySetsBySeries(
    studies,
    studyInstanceUid,
    seriesInstanceUid
  );

  if (displaySets.length > 1) {
    console.warn(
github OHIF / Viewers / platform / core / src / DICOMSR / parseDicomStructuredReport.js View on Github external
const parseDicomStructuredReport = (part10SRArrayBuffer, displaySets) => {
  // Get the dicom data as an Object
  const dicomData = dcmjs.data.DicomMessage.readFile(part10SRArrayBuffer);
  const dataset = dcmjs.data.DicomMetaDictionary.naturalizeDataset(
    dicomData.dict
  );

  const { MeasurementReport } = dcmjs.adapters.Cornerstone;
  const storedMeasurementByToolType = MeasurementReport.generateToolState(
    dataset
  );
  const measurementData = {};
  let measurementNumber = 0;

  Object.keys(storedMeasurementByToolType).forEach(toolName => {
    const measurements = storedMeasurementByToolType[toolName];
    measurementData[toolName] = [];

    measurements.forEach(measurement => {
github OHIF / Viewers / extensions / vtk / src / handleSegmentationStorage.js View on Github external
// TODO: This is terrible but we need to use WADO-RS or we can't retrieve the SEG
  // from google cloud
  const wadoRoot = displaySet.images[0].getData().wadoRoot;

  const StudyInstanceUID = displaySet.images[0].getStudyInstanceUID();
  const SeriesInstanceUID = displaySet.images[0].getSeriesInstanceUID();
  const SOPInstanceUID = displaySet.images[0].getSOPInstanceUID();

  const arrayBuffer = await retrieveDicomData(
    StudyInstanceUID,
    SeriesInstanceUID,
    SOPInstanceUID,
    wadoRoot
  );

  const dicomData = dcmjs.data.DicomMessage.readFile(arrayBuffer);
  const dataset = dcmjs.data.DicomMetaDictionary.naturalizeDataset(
    dicomData.dict
  );

  const segments = dcmjs.adapters.VTKjs.Segmentation.generateSegments(dataset);

  dataset._meta = dcmjs.data.DicomMetaDictionary.namifyDataset(dicomData.meta);

  const seriesInstanceUid = dataset.ReferencedSeriesSequence.SeriesInstanceUID;
  const displaySets = getDisplaySetsBySeries(
    studies,
    studyInstanceUid,
    seriesInstanceUid
  );

  if (displaySets.length > 1) {
github OHIF / Viewers / platform / core / src / DICOMSR / parseDicomStructuredReport.js View on Github external
const parseDicomStructuredReport = (part10SRArrayBuffer, displaySets) => {
  // Get the dicom data as an Object
  const dicomData = dcmjs.data.DicomMessage.readFile(part10SRArrayBuffer);
  const dataset = dcmjs.data.DicomMetaDictionary.naturalizeDataset(
    dicomData.dict
  );

  const { MeasurementReport } = dcmjs.adapters.Cornerstone;
  const storedMeasurementByToolType = MeasurementReport.generateToolState(
    dataset
  );
  const measurementData = {};
  let measurementNumber = 0;

  Object.keys(storedMeasurementByToolType).forEach(toolName => {
    const measurements = storedMeasurementByToolType[toolName];
    measurementData[toolName] = [];

    measurements.forEach(measurement => {
      const instanceMetadata = findInstanceMetadataBySopInstanceUid(
github OHIF / Viewers / platform / core / src / DICOMSR / parseDicomStructuredReport.js View on Github external
const parseDicomStructuredReport = (part10SRArrayBuffer, displaySets) => {
  // Get the dicom data as an Object
  const dicomData = dcmjs.data.DicomMessage.readFile(part10SRArrayBuffer);
  const dataset = dcmjs.data.DicomMetaDictionary.naturalizeDataset(
    dicomData.dict
  );

  const { MeasurementReport } = dcmjs.adapters.Cornerstone;
  const storedMeasurementByToolType = MeasurementReport.generateToolState(
    dataset
  );
  const measurementData = {};
  let measurementNumber = 0;

  Object.keys(storedMeasurementByToolType).forEach(toolName => {
    const measurements = storedMeasurementByToolType[toolName];
    measurementData[toolName] = [];

    measurements.forEach(measurement => {
      const instanceMetadata = findInstanceMetadataBySopInstanceUid(
        displaySets,
        measurement.sopInstanceUid
      );
      const { _study: study, _series: series } = instanceMetadata;
github OHIF / Viewers / extensions / cornerstone / src / handleSegmentationStorage.js View on Github external
const displaySet = getDisplaySet(
    studies,
    studyInstanceUid,
    displaySetInstanceUid
  );

  const arrayBuffer = await DicomLoaderService.findDicomDataPromise(
    displaySet,
    studies
  );
  const dicomData = dcmjs.data.DicomMessage.readFile(arrayBuffer);
  const dataset = dcmjs.data.DicomMetaDictionary.naturalizeDataset(
    dicomData.dict
  );

  dataset._meta = dcmjs.data.DicomMetaDictionary.namifyDataset(dicomData.meta);

  const seriesInstanceUid = dataset.ReferencedSeriesSequence.SeriesInstanceUID;
  const displaySets = getDisplaySetsBySeries(
    studies,
    studyInstanceUid,
    seriesInstanceUid
  );

  if (displaySets.length > 1) {
    console.warn(
      'More than one display set with the same seriesInstanceUid. This is not supported yet...'
    );
  }

  const referenceDisplaySet = displaySets[0];
  const imageIds = referenceDisplaySet.images.map(image => image.getImageId());
github OHIF / Viewers / extensions / cornerstone / src / handleSegmentationStorage.js View on Github external
displaySetInstanceUid
) {
  const study = studies.find(
    study => study.studyInstanceUid === studyInstanceUid
  );
  const displaySet = getDisplaySet(
    studies,
    studyInstanceUid,
    displaySetInstanceUid
  );

  const arrayBuffer = await DicomLoaderService.findDicomDataPromise(
    displaySet,
    studies
  );
  const dicomData = dcmjs.data.DicomMessage.readFile(arrayBuffer);
  const dataset = dcmjs.data.DicomMetaDictionary.naturalizeDataset(
    dicomData.dict
  );

  dataset._meta = dcmjs.data.DicomMetaDictionary.namifyDataset(dicomData.meta);

  const seriesInstanceUid = dataset.ReferencedSeriesSequence.SeriesInstanceUID;
  const displaySets = getDisplaySetsBySeries(
    studies,
    studyInstanceUid,
    seriesInstanceUid
  );

  if (displaySets.length > 1) {
    console.warn(
      'More than one display set with the same seriesInstanceUid. This is not supported yet...'
github OHIF / Viewers / extensions / vtk / src / handleSegmentationStorage.js View on Github external
const SeriesInstanceUID = displaySet.images[0].getSeriesInstanceUID();
  const SOPInstanceUID = displaySet.images[0].getSOPInstanceUID();

  const arrayBuffer = await retrieveDicomData(
    StudyInstanceUID,
    SeriesInstanceUID,
    SOPInstanceUID,
    wadoRoot
  );

  const dicomData = dcmjs.data.DicomMessage.readFile(arrayBuffer);
  const dataset = dcmjs.data.DicomMetaDictionary.naturalizeDataset(
    dicomData.dict
  );

  const segments = dcmjs.adapters.VTKjs.Segmentation.generateSegments(dataset);

  dataset._meta = dcmjs.data.DicomMetaDictionary.namifyDataset(dicomData.meta);

  const seriesInstanceUid = dataset.ReferencedSeriesSequence.SeriesInstanceUID;
  const displaySets = getDisplaySetsBySeries(
    studies,
    studyInstanceUid,
    seriesInstanceUid
  );

  if (displaySets.length > 1) {
    console.warn(
      "More than one display set with the same seriesInstanceUid. This is not supported yet..."
    );
  }
github OHIF / Viewers / platform / viewer / src / lib / DICOMSR / handleStructuredReport.js View on Github external
const stowSRFromMeasurements = async (measurements, serverUrl) => {
  const { dataset } = parseMeasurementsData(
    measurements
  );
  const { DicomMetaDictionary, DicomDict } = dcmjs.data;
  const meta = {
    FileMetaInformationVersion:
      dataset._meta.FileMetaInformationVersion.Value,
    MediaStorageSOPClassUID: dataset.SOPClassUID,
    MediaStorageSOPInstanceUID: dataset.SOPInstanceUID,
    TransferSyntaxUID: TRANSFER_SYNTAX_UID,
    ImplementationClassUID: DicomMetaDictionary.uid(),
    ImplementationVersionName: VERSION_NAME,
  };

  const denaturalized = DicomMetaDictionary.denaturalizeDataset(meta);
  const dicomDict = new DicomDict(denaturalized);

  dicomDict.dict = DicomMetaDictionary.denaturalizeDataset(dataset);

  const part10Buffer = dicomDict.write();
github OHIF / Viewers / extensions / dicom-html / src / DicomHtmlViewport.js View on Github external
if (data.ValueType) {
    if (data.ValueType === 'CONTAINER') {
      const header = data.ConceptNameCodeSequence.CodeMeaning;

      return constructContentSequence(data, header);
    }

    return constructPlainValue(data);
  }

  if (data.ContentSequence) {
    return constructContentSequence(data);
  }
}

const { DicomMetaDictionary, DicomMessage } = dcmjs.data;

function getMainData(data) {
  const root = [];

  const patientValue = `${data.PatientName} (${data.PatientSex}, #${data.PatientID})`;
  root.push(getMainDataItem('Patient', patientValue));

  const studyValue = data.StudyDescription;
  root.push(getMainDataItem('Study', studyValue));

  const seriesValue = `${data.SeriesDescription} (#${data.SeriesNumber})`;
  root.push(getMainDataItem('Series', seriesValue));

  const manufacturerValue = `${data.Manufacturer} (${data.ManufacturerModelName}, #${data.DeviceSerialNumber})`;

  root.push(getMainDataItem('Manufacturer', manufacturerValue));

dcmjs

Javascript implementation of DICOM manipulation

MIT
Latest version published 23 days ago

Package Health Score

84 / 100
Full package analysis

Popular dcmjs functions