cornerstonejs / dicomParser

JavaScript parser for DICOM Part 10 data
MIT License
713 stars 228 forks source link

Read Dataset without FMI #206

Closed christianhahnsft22 closed 2 years ago

christianhahnsft22 commented 2 years ago

When I try to read a dataset without the FMI information I get the following error: Status: Error - dicomParser.readFixedString: attempt to read past end of buffer (file of size 0 KB )

I'm using dcm4che library to compose a sample dataset which can contain only some attributes (f.e. a dataset without SOPInstanceUID/SOPClassUID) which I want to parse then with dicomParser.

sample dcm4che code:

import org.dcm4che3.data.Attributes;
import org.dcm4che3.data.Tag;
import org.dcm4che3.data.UID;
import org.dcm4che3.data.VR;
import org.dcm4che3.io.DicomOutputStream;

import java.io.File;
import java.io.IOException;

public class Test {
    public static void main(String args[]) throws IOException {
        Attributes attributes = new Attributes();
        attributes.setString(Tag.PatientID, VR.LO.LO,"1234");
        attributes.setString(Tag.IssuerOfPatientID,VR.LO,"Issuer");

        File file2 = new File("c:/tmp/test2.dcm");
        try (DicomOutputStream dos = new DicomOutputStream(file2)) {
            dos.writeDataset(null, attributes);
        }
    }
}
christianhahnsft22 commented 2 years ago

test2.dcm.zip

yagni commented 2 years ago

If you don't have any file metainformation, the library isn't going to read it out of the box as it's nonstandard DICOM. However, if you know the transfer syntax you can call the appropriate parse method (parseDicomDataSetExplicit or parseDicomDataSetImplicit) directly. You'll have to do something like what the readDicom method does.