dcmjs
dcmjs copied to clipboard
writing dicom to file results in corrupted pixel data
The end goal is to read in the dicom, modify PHI from the header using strings of equal length as those in the tags, and modify the pixel data to remove PHI from pixels I followed the instructions here https://github.com/dcmjs-org/dcmjs/issues/64
The input test image (contains PHI, so I will not upload it) is 97 frames, 600 rows, 800 columns, and 3 samples per pixel
From pydicom, header information is:
(0028, 0002) Samples per Pixel US: 3
(0028, 0004) Photometric Interpretation CS: 'YBR_FULL_422'
(0028, 0006) Planar Configuration US: 0
(0028, 0008) Number of Frames IS: "97"
(0028, 0009) Frame Increment Pointer AT: (0018, 1063)
(0028, 0010) Rows US: 600
(0028, 0011) Columns US: 800
(0028, 0014) Ultrasound Color Data Present US: 0
(0028, 0100) Bits Allocated US: 8
(0028, 0101) Bits Stored US: 8
(0028, 0102) High Bit US: 7
(0028, 0103) Pixel Representation US: 0
(0028, 0301) Burned In Annotation CS: 'YES'
(0028, 2110) Lossy Image Compression CS: '01'
(0028, 2112) Lossy Image Compression Ratio DS: "0.0"
(7fe0, 0010) Pixel Data OB: Array of 6465010 elements
(0002, 0000) File Meta Information Group Length UL: 208
(0002, 0001) File Meta Information Version OB: b'\x00\x01'
(0002, 0002) Media Storage SOP Class UID UI: Ultrasound Multi-frame Image Storage
(0002, 0003) Media Storage SOP Instance UID UI: 1.2.840.113663.1500.1.313573945.3.2.20190710.111922.593
(0002, 0010) Transfer Syntax UID UI: JPEG Baseline (Process 1)
(0002, 0012) Implementation Class UID UI: 1.2.840.113857.4
(0002, 0013) Implementation Version Name SH: 'IC2_MC3_470'
(0002, 0016) Source Application Entity Title AE: 'SHOWCASE_SCP'
In order to rule out anything wrong in my logic, I wrote the following to simply read and write
const arrayBuffer = fs.readFileSync(filename).buffer;
const DicomDict = dcmjs.data.DicomMessage.readFile(arrayBuffer);
const dataSet = dcmjs.data.DicomMetaDictionary.naturalizeDataset(DicomDict.dict);
DicomDict.dict = dcmjs.data.DicomMetaDictionary.denaturalizeDataset(dataSet);
let new_file_WriterBuffer = DicomDict.dict.write();
const outputFilename = './test.dcm';
fs.writeFileSync(outputFilename, new Buffer(new_file_WriterBuffer));
I noticed the following:
- Viewing the input image in Horos, or even in python results in a corrupt pixel data. In Horos the image is displayed well for the first couple of frames. Afterwards, the image is blank.
- In python, the new header information shows the Pixel Data Array of elements has changed
(7fe0, 0010) Pixel Data OB: Array of 6467338 elements
Any help pointing me in the right direction is much appreciated!!
Miguel
In my limited knowledge, I notice that DicomDict.js assumes a specific transer syntax id (explicit little endian) while my file is JPEG Baseline (Process 1) (1.2.840.10008.1.2.4.50)
Thank you, once again!
Hi @MiguelSotelo2 - I haven't used dcmjs with any jpeg image data myself, but I can easily suppose that there are problems. If you can find some public data that can be used to replicate the issue it would be good to add it to the list for future regression testing (for now we are putting datasets here: https://github.com/dcmjs-org/data).
In the meantime, are there other clues to what has changed in the header? Just reading/writing the dataset shouldn't have changed the pixel data that I can think of.
Any follow-up info? Without replication we'll eventually close the issue.