Viewers
Viewers copied to clipboard
Update getUIDsFromImageID to work with json data source + update getDisplaySetImageUIDs to work with mixed sop class json
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: