rexcardan / Evil-DICOM

A C# DICOM Library
168 stars 98 forks source link

Adding element Image Plane Pixel Spacing (30020011) #54

Closed ke-senthilkumar closed 6 years ago

ke-senthilkumar commented 6 years ago

I am a newbie for both programming and dicom. I cannot find method to add an element to an existing dicom file. I went through this https://github.com/rexcardan/Evil-DICOM/issues/27 article and tried the code like this:

Dim dcm = New DICOMObject Dim fs = New FloatingPointDouble(New Tag("30020011"), 0.252) dcm.Add(fs) dcm.Write("d:\dcmeditor\new.dcm")

The output is written but missing the new Element. Is there a better way of doing this. Actually the Plane Pixel values are like 0.25, 0.25.

Kindly help.

Senthil

ke-senthilkumar commented 6 years ago

Sorry, there seems to be some kind of mistake. What I found is that the -- Only this element is added but the value is 'Tã¥›Ä Ð?' and sometimes empty data.

I have to add 2 values for the element, like 0.252, 0.252.

Also from https://github.com/rexcardan/Evil-DICOM/issues/27, the code line

dcm.Write("test.dcm", New EvilDICOM.Core.IO.Writing.DICOMWriteSettings() With {.TransferSyntax = EvilDICOM.Core.Enums.TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN})

is not working. A simple 'dcm.Write("test.dcm")' writes the file but the next set of code gives a warning. I have imported the Evildicom.Core.IO but still the error wont go away.

ke-senthilkumar commented 6 years ago

Issue solved..

Dim ps = New DecimalString(New Tag("30020011"), 0.2) dcm.Add(ps)

    Dim sel = dcm.GetSelector()

    Dim dbls As New List(Of Double)

    dbls.Add(txtPix1.Text)
    dbls.Add(txtPix2.Text)
    sel.ImagePlanePixelSpacing.Data_ = dbls

Using this code and a slight change, I was able to add the desired Element & tags.

Thanks for EvilDICOM dll