dcmsnd -set what may cause 'UnsupportedOperationException' ?

165 views
Skip to first unread message

Joey

unread,
Nov 15, 2016, 7:29:18 AM11/15/16
to dcm...@googlegroups.com
See my first 2018 reply on this post. I've come back to this issue after years.
_________________________________________________________________

I am not sure what may cause this.

I am currently using dcmsnd -set to Anonymize files as I sent them to dcm4chee.
For the moment, I follow this list for minimal de-identification ftp://medical.nema.org/medical/dicom/final/sup55_ft.pdf (page 13, table x.1-1).

my application generates a command like this:

dcmsnd DCM4CHEE@127.0.0.1:11112 file.dcm -set 00080014=Anonymized 00080050=Anonymized 00080080=Anonymized 00080081=Anonymized 00080090=Anonymized 00081010=Anonymized 00081030=Anonymized 0008103E=Anonymized 00081048=Anonymized 00081050=Anonymized 00081070=Anonymized 00100010=Anonymized 00101010=Anonymized 00101030=Anonymized 00181000=Anonymized 00181030=Anonymized 00200010=Anonymized 00400275=Anonymized

I noticed that dcmsnd may throw this exception:

Exception in thread "main" java.lang.UnsupportedOperationException

   at org
.dcm4che2.data.VR.toBytes(VR.java:2454)
   at org
.dcm4che2.data.BasicDicomObject.putString(BasicDicomObject.java:473)
   at org
.dcm4che2.tool.dcmsnd.DcmSnd.addCoerceAttr(DcmSnd.java:983)
   at org
.dcm4che2.tool.dcmsnd.DcmSnd.main(DcmSnd.java:767)
   at
ChildProcess.exithandler (child_process.js:202:12)
   at emitTwo
(events.js:106:13)
   at
ChildProcess.emit (events.js:191:7)
   at maybeClose
(internal/child_process.js:852:16)
   at
Socket.<anonymous> (internal/child_process.js:323:11)
   at emitOne
(events.js:96:13)
   at
Socket.emit (events.js:188:7)
   at
Pipe._handle.close [as _onclose] (net.js:492:12)

At first I thought, maybe missing attributes may be the cause.
So, I reduced the list to only Anonymize attributes I was certain of were there (https://rawgit.com/chafey/dicomParser/master/examples/dumpWithDataDictionary/index.html).
But I still got this exception.

Then I removed every Anonymization of UID and Date or Time related attribute from the list as well, because I thought, maybe a data type issue and that 'Anonymized' isn't acceptable.
Still got this exception.

But when I reduced the list to just PatientName and InstituteName, no exceptions were thrown and my application works as intended.

My questions:
  • What may cause this UnsupportedOperationException?
  • How does dcmsnd -set behave if the attribute is missing in the object?

p.p...@synedra.com

unread,
Nov 15, 2016, 9:06:08 AM11/15/16
to dcm...@googlegroups.com
Technical background: The VR base class does not implement any code to serialize fields to bytes. Instead it throws an UnsupportedOperationException by default. It is up to the extending classes (i.e. the actual VR types) to implement this logic per type. Serialization is necessary to send the data over the wire (or write it to the filesystem, etc.).

By investigating the sourcecode I derive a list of VRs which do have an implementation of this specific implementation of toBytes(), namely
AE, AS, CS, DA, DS, DT, IS, TM, UI, AT, FD, FL, SL, UL, SS, US, LO, PN, SH, LT, ST, UT

What does that mean for you? At first I thought I was smart and would have told you, that you may only use VRs from the list above ... which is nonsense, after having a second look at the source.
I suspect the more likely cause of your error is a wrong datatype/VR combination. I think you try to use a String in a field with a VR of OB, OF, OW, SQ, UN, UN_SIEMENS. At least that is what the code tells me.

Hope that helps.

Joey

unread,
Nov 15, 2016, 9:53:27 AM11/15/16
to dcm4che
Thanks this helped enormously.
It turns out "RequestAttributesSequence" Can't be a String.
When I remove that from the list of attributes to change, my application works as intended.

And I found out I can simply drop attributes with dcmsnd -set by giving no value, which is really helpful!
e.g.
dcmsnd AET@localhost:11112 00.dcm -set 00400275=


Thanks! Too bad I can't +1 your post.

Joey

unread,
Sep 28, 2018, 9:38:45 AM9/28/18
to dcm...@googlegroups.com
After years I have to come back to this issue.
I migrated my application to Windows and my anonymization procedure fails.

This is the exact output:

Error: Command failed: c:/Users/server/application/utils/dcm4che-2.0.29/bin/dcmsnd.bat DCM4CHEE@127.0.0.1:11112 d:/webservice/dicom/e5415cc0-53c3-456d-af85-49321bc23696-f3d1096d -set 00100020=P.123.456.78 00080050= 00080080= 00080081= 00080090= 00080092= 00080094= 00081010= 00081030= 0008103E= 00081040= 00081048= 00081050= 00081060= 00081070= 00081080= 00082111= 00100010=Anonymized 00100030= 00100032= 00100040= 00101000= 00101001= 00101010= 00101020= 00101030= 00101090= 00102160= 00102180= 001021B0= 00104000= 00181000= 00181030= 00204000= 00400275= 0040A730= 00100005= 00100050= 00101040= 00101050= 00101040= 00101080= 00101081= 00102152= 00102154= 00324000= 00400006= 00081052= 00401102=



 
Exception in thread "main" java.lang.UnsupportedOperationException
  at org
.dcm4che2.data.VR.toBytes(VR.java:2454)
  at org
.dcm4che2.data.BasicDicomObject.putString(BasicDicomObject.java:473)
  at org
.dcm4che2.tool.dcmsnd.DcmSnd.addCoerceAttr(DcmSnd.java:983)
  at org
.dcm4che2.tool.dcmsnd.DcmSnd.main(DcmSnd.java:767)
  at
ChildProcess.exithandler (child_process.js:202:12)
  at emitTwo
(events.js:106:13)
  at
ChildProcess.emit (events.js:191:7)

  at maybeClose
(internal/child_process.js:850:16)
  at
Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)

e5415cc0-53c3-456d-af85-49321bc23696-f3d1096d is a directory with therein .dcm files.

If all tags (including 00100010) are coerced like so Tag= the result is the same as above.

The application is already in production in a Linux environment where I set several tags in the command to "Anonymized" like so
00080080=Anonymized 00080090=Anonymized 00081050=Anonymized 00100010=Anonymized
That same procedure fails in the Windows environment with a result message like unknown Tag 'Anonymized'.

What makes it so that the command would fail in Windows, but not in Linux? I don't see anything out of the ordinary in the path name or naming.

Thank you for any input.
Reply all
Reply to author
Forward
0 new messages