can't read custom field

12 views
Skip to first unread message

Luc Gillibert

unread,
May 24, 2018, 8:34:52 AM5/24/18
to ruby-dicom
Hello,

I want to read some custom data in a DICOM. The DICOM tag is "0009,1107" and if I look at the file with DICOM viewer, the tag is present (and is its type is 'OB' for "Other byte string").

But when I read it with dcm.value("0009,1107") I get a nil object.
I want a byte string.

dcm = DObject.read("H45.ceph")
puts dcm.patients_name.value #WORKS
puts dcm.value("0009,1107").size #DONT WORKS

Please, can anybody help?

H45.ceph

Christoffer Lervåg

unread,
May 24, 2018, 8:46:21 AM5/24/18
to ruby-dicom
Hello Luc

Thank you for trying out the ruby-dicom library!

DICOM tags of type OB and OW are somewhat special, since they are byte strings (binary strings). Because of that, they are not interpreted by ruby-dicom and converted to a "value" (e.g. string or integer).

However, you can still access the binary string and process it yourself.

What you are looking for in this case is to extract it like this:
str = dcm["0009,0017"].bin
length = dcm["0009,0017"].length

Hope that helps!

Best regards,
Christoffer
Reply all
Reply to author
Forward
0 new messages