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

Update getUIDsFromImageID to work with json data source + update getDisplaySetImageUIDs to work with mixed sop class json #4322

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

igoroctaviano
Copy link
Contributor

@igoroctaviano igoroctaviano commented Jul 31, 2024

Context

  • MetadataProvider's getUIDsFromImageID should look first for previously added image id's UIDs.
  • getDiplaySetImageIds should work for JSON files that have mixed sop class series.

Example: The DICOM JSON data source already calls addImageIdToUIDs when loading the JSON data during initialization so when using JSON, we might not be able to get UIDs from the image IDs. Also, if the image ID was generated from the URL attribute of the JSON file and the URL does not have any UIDs as part of the URL (e.g. proprietary URLs) then it still works since the JSON already provided all those UIDs during initialization.

Testing

Using any multiframe json (multiple instances with URL attributes and wadors loader to retrieve frames/pixeldata)

{
  "studies": [
    {
      "StudyInstanceUID": "1.2.300.0.7230010.3.1.2.2137700.1796.3",
      "StudyDescription": "Test",
      "StudyDate": "20240613",
      "StudyTime": "181423.930000",
      "PatientName": [
        {
          "Alphabetic": "Test^Test"
        }
      ],
      "PatientID": "Test",
      "AccessionNumber": "Test",
      "PatientAge": "Test",
      "PatientSex": "F",
      "series": [
        {
          "SeriesInstanceUID": "1.2.300.0.7230010.3.1.3.321.7700.1718304996.2",
          "SeriesDescription": "Test Series",
          "SeriesNumber": 7,
          "SeriesTime": "111813.948",
          "Modality": "XA",
          "instances": [
            {
              "metadata": {
                ...
                "ImageType": [
                  "ORIGINAL",
                  "PRIMARY",
                  "SINGLE PLANE",
                  "SINGLE A"
                ],
                "Modality": "XA",
                "SOPInstanceUID": "1.2.300.0.7230010.3.1.4.123.7700.1718304996.1.1",
                "SeriesInstanceUID": "1.2.300.0.7230010.3.1.3.4123831.7700.1718304996.2",
                "StudyInstanceUID": "1.2.300.0.7230010.3.1.2.4331.7700.211718304996.3",
                "WindowCenter": 127.75,
                "WindowWidth": 255.75,
                "SeriesDate": "20201104",
                "AcquisitionDate": "20170116",
                "AcquisitionTime": "111813.948",
                "NumberOfFrames": 48,
                "FrameTime": 66.667
              },
              "url": "wadors:http://localhost:3001?frame=1"
            },

Use this node service that returns frames from a dicom file from file system

const express = require("express");
const fs = require("fs");
const dicomParser = require("dicom-parser");
const cors = require("cors");

const app = express();
const PORT = process.env.PORT || 3001;

app.use(cors());

function getDicomFrame(filePath, frameNumber) {
  const dicomFile = fs.readFileSync(filePath);
  const dataSet = dicomParser.parseDicom(dicomFile);

  const numberOfFrames = dataSet.intString("x00280008");
  const pixelDataElement = dataSet.elements.x7fe00010;
  const frameSize = pixelDataElement.length / numberOfFrames;
  const frameOffset = (frameNumber - 1) * frameSize;

  return dicomFile.slice(
    pixelDataElement.dataOffset + frameOffset,
    pixelDataElement.dataOffset + frameOffset + frameSize
  );
}

app.get("/", (req, res) => {
  const frameNumber = parseInt(req.query.frame);
  console.debug('Retrieving frame number:', frameNumber);

  try {
    const dicomFilePath = "./multiframe.dcm";
    const frame = getDicomFrame(dicomFilePath, frameNumber);
    res.setHeader("Content-Type", "application/octet-stream");
    res.send(frame);
  } catch (error) {
    res.status(400).send({ error: error.message });
  }
});

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

Checklist

PR

  • [] My Pull Request title is descriptive, accurate and follows the
    semantic-release format and guidelines.

Code

  • [] My code has been well-documented (function documentation, inline comments,
    etc.)

Public Documentation Updates

  • [] The documentation page has been updated as necessary for any public API
    additions or removals.

Tested Environment

  • [] OS:
  • [] Node version:
  • [] Browser:

Copy link

netlify bot commented Jul 31, 2024

Deploy Preview for ohif-platform-docs ready!

Name Link
🔨 Latest commit 555407e
🔍 Latest deploy log https://app.netlify.com/sites/ohif-platform-docs/deploys/66e445117758120008ca9491
😎 Deploy Preview https://deploy-preview-4322--ohif-platform-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jul 31, 2024

Deploy Preview for ohif-dev ready!

Name Link
🔨 Latest commit 555407e
🔍 Latest deploy log https://app.netlify.com/sites/ohif-dev/deploys/66e44511208dec000805ad10
😎 Deploy Preview https://deploy-preview-4322--ohif-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

cypress bot commented Jul 31, 2024

Viewers    Run #4264

Run Properties:  status check passed Passed #4264  •  git commit 555407edac: Merge branch 'master' into fix/dicom-json-multiframe
Project Viewers
Branch Review fix/dicom-json-multiframe
Run status status check passed Passed #4264
Run duration 02m 46s
Commit git commit 555407edac: Merge branch 'master' into fix/dicom-json-multiframe
Committer Igor Octaviano
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 2
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 44
View all changes introduced in this branch ↗︎

@igoroctaviano igoroctaviano changed the title Update getUIDsFromImageID to work with dicom json Update getUIDsFromImageID to work with dicom json + update getDisplaySetImageUIDs to work with mixed sop class json Aug 13, 2024
@igoroctaviano igoroctaviano changed the title Update getUIDsFromImageID to work with dicom json + update getDisplaySetImageUIDs to work with mixed sop class json Update getUIDsFromImageID to work with json data source + update getDisplaySetImageUIDs to work with mixed sop class json Aug 13, 2024
@igoroctaviano igoroctaviano requested review from wayfarer3130 and removed request for sedghi September 2, 2024 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants