Giter Club home page Giter Club logo

Comments (4)

jacobalberty avatar jacobalberty commented on May 11, 2024 1

I believe the order of tags does matter, at least according to dcmdump from dcmtk
This code snippet works

        newVals := []*element.Element{
                element.MustNewElement(dicomtag.TransferSyntaxUID, dicomuid.ExplicitVRLittleEndian),
                element.MustNewElement(dicomtag.MediaStorageSOPClassUID, "1.2.840.10008.5.1.4.31"),
                element.MustNewElement(dicomtag.MediaStorageSOPInstanceUID, "1.2.276.0.7230010.3.1.4.2831176407.11154.1448031138.805061"),
                element.MustNewElement(dicomtag.SpecificCharacterSet, "ISO_IR 192"),
                element.MustNewElement(dicomtag.AccessionNumber, "00000"),
                element.MustNewElement(dicomtag.PatientName, fmt.Sprintf("%s^%s", c.LName, p.Name.String)),
                element.MustNewElement(dicomtag.PatientID, strconv.Itoa(wl.PID)),
                element.MustNewElement(dicomtag.IssuerOfPatientID, wl.IDPrefix),
                element.MustNewElement(dicomtag.PatientBirthDate, p.DOB.Time.Format("2006-01-02")),
                element.MustNewElement(dicomtag.PatientSex, p.Sex.String),
                element.MustNewElement(dicomtag.MedicalAlerts, p.Alert.String),
                element.MustNewElement(dicomtag.RequestingPhysician, "VETNAME"),
                element.MustNewElement(dicomtag.ScheduledProcedureStepSequence,
                        element.MustNewElement(dicomtag.Item,
                                element.MustNewElement(dicomtag.Modality, "MR"),
                                element.MustNewElement(dicomtag.RequestedProcedureDescription, wl.Procedure),
                                element.MustNewElement(dicomtag.ScheduledProcedureStepStartDate, wl.ScheduledProcedureStartDate),
                        )),
        }

But if I move the start date above the description as follows:

        newVals := []*element.Element{
                element.MustNewElement(dicomtag.TransferSyntaxUID, dicomuid.ExplicitVRLittleEndian),
                element.MustNewElement(dicomtag.MediaStorageSOPClassUID, "1.2.840.10008.5.1.4.31"),
                element.MustNewElement(dicomtag.MediaStorageSOPInstanceUID, "1.2.276.0.7230010.3.1.4.2831176407.11154.1448031138.805061"),
                element.MustNewElement(dicomtag.SpecificCharacterSet, "ISO_IR 192"),
                element.MustNewElement(dicomtag.AccessionNumber, "00000"),
                element.MustNewElement(dicomtag.PatientName, fmt.Sprintf("%s^%s", c.LName, p.Name.String)),
                element.MustNewElement(dicomtag.PatientID, strconv.Itoa(wl.PID)),
                element.MustNewElement(dicomtag.IssuerOfPatientID, wl.IDPrefix),
                element.MustNewElement(dicomtag.PatientBirthDate, p.DOB.Time.Format("2006-01-02")),
                element.MustNewElement(dicomtag.PatientSex, p.Sex.String),
                element.MustNewElement(dicomtag.MedicalAlerts, p.Alert.String),
                element.MustNewElement(dicomtag.RequestingPhysician, "VETNAME"),
                element.MustNewElement(dicomtag.ScheduledProcedureStepSequence,
                        element.MustNewElement(dicomtag.Item,
                                element.MustNewElement(dicomtag.Modality, "MR"),
                                element.MustNewElement(dicomtag.ScheduledProcedureStepStartDate, wl.ScheduledProcedureStartDate),
                                element.MustNewElement(dicomtag.RequestedProcedureDescription, wl.Procedure),
                        )),
        }

Then dcmdump gives me W: DcmItem: Dataset not in ascending tag order, at element (0032,1060)

I have not tested this with my actual x-ray software yet but orthanc gives me a similar error in the console when I test with findscu

from dicom.

suyashkumar avatar suyashkumar commented on May 11, 2024

Does the order of the tags in the original dicom matter?

from dicom.

suyashkumar avatar suyashkumar commented on May 11, 2024

@jacobalberty thank you for the information, it's definitely useful to know that when writing the tags they should be in order! It may be useful to still represent the DataSet as a map of tag -> element (or pointer to element) so that it's easy to fetch elements by tag in large DataSets, without too much memory overhead. Thoughts?

from dicom.

luxsa avatar luxsa commented on May 11, 2024

Migrating DataSet to use map also will make it easier to convert a DataSet to DICOM JSON model and the tag key will be sorted.

https://golang.org/pkg/encoding/json/
`Map values encode as JSON objects. The map's key type must either be a string, an integer type, or implement encoding.TextMarshaler. The map keys are sorted and used as JSON object keys by applying the following rules, subject to the UTF-8 coercion described for string values above:

  • keys of any string type are used directly
  • encoding.TextMarshalers are marshaled
  • integer keys are converted to strings`

When writing the Dataset to a DCM file, sort the keys first, and range map through the ordered keys, then write each element to the file.

from dicom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.