简体   繁体   中英

Creating Dicom Sequences with fo-dicom

After extracting information out of a radiation therapy plan stored as a DICOM-File, my issue is now a different one.

I know, that I can add or update items in an existing plan with (eg)

file.Dataset.AddOrUpdate(Dicom.DicomTag.PatientAge,23);

Even handling DicomTags in a sequence is not the problem with (eg)

file.Dataset.Get<Dicom.DicomSequence>(Dicom.DicomTag.BeamSequence).Items[1].
            Get<Dicom.DicomSequence>(Dicom.DicomTag.ControlPointSequence).Items[0].
            Get<Dicom.DicomSequence>(Dicom.DicomTag.BeamLimitingDevicePositionSequence).Items[2].
            AddOrUpdate(Dicom.DicomTag.LeafJawPositions, "-30\\30");

But now I am wondering if it is possible to create a complete new sequence and store information in it? I know that wanting this forces me to create not only one item, but much more information arround this item, cause there is no sequence in the plans I looked through which have this.

In the fo-dicom API documentation I found the Dicom.IO.Writer Namespace. I looked through but didn't find what i expected to find. Following my first instinct, I would have written this

string filename = "output.dcm";
DicomWriter file = new DicomWriter(@filename);
... trying to create TagElements

Also the other command line DicomFileWriter file = new DicomFileWriter(...); doesn't work because the constructor only wants to receive options. The other DicomWriter() constructor is similar to this.

I also checked the file.Dataset possibilities for writing new tags, but without succes. So I hope one of you can give me a hint where I did a wrong step.

This is one way of doing it:

string filename = "output.dcm";

DicomDataset ds = new DicomDataset(); //Main dataset
ds.Add(DicomTag.SpecificCharacterSet, "ISO_IR 100"); //Add some items
ds.Add(DicomTag.PatientID, "191212121212");

DicomDataset sqContent = new DicomDataset(); //Content of the sequence
sqContent.Add(DicomTag.Modality, "US");
sqContent.Add(DicomTag.ScheduledProcedureStepStartDate, DateTime.Now.Date);

DicomSequence sq = new DicomSequence(DicomTag.ScheduledProcedureStepSequence, sqContent); // Create sequence, add content
ds.Add(sq); //Add sequence to main dataset

DicomFile file = new DicomFile();
file.Dataset.Add(ds); //Add main dataset to DicomFile
file.FileMetaInfo.TransferSyntax = DicomTransferSyntax.ImplicitVRLittleEndian; //Specify transfer syntax
file.Save(filename); //Save file to disk

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM