Comments (4)
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.
Does the order of the tags in the original dicom matter?
from dicom.
@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.
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)
- Investigate and triage Fuzz based issues.
- Add option to not hold entire dataset in memory at once HOT 2
- If the passed in Reader is _also_ an io.Seeker, consider trying to use Seek() on Skip
- Consider a Read - Modify some Elements - Write Pipeline API
- Consider updating type system to use Go generics HOT 1
- Value representation "Application Entity" is not correclly serialized
- fatal exit without defer HOT 2
- Explore Lint based or reflection based tests for struct equality changes
- Add additional struct `Equals` test cases
- What's the right import statement to use this? HOT 2
- Write() fails for encapsulated pixel data unless ValueLength explicitly set to tag.VLUndefinedLength HOT 1
- Question: Is it possible to get to individual Pixels in dicom image? HOT 3
- Use this project in C# HOT 1
- Memory usage (sometimes 15x from the size of dicom file) HOT 1
- Check for Signed Integers in Native Pixel Data HOT 1
- Support Negative Integers in Native Pixel Data
- dicom.Write: The Pixel data only supports OW type
- File with dicom seg throws an error - writing dicom file: unsupported BitsPerSample value
- Converting DICOM to Image results into "blacked" image HOT 3
- using dicom.Parse function ,unexpected EOF HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dicom.