DicomEdit & substring

27 views
Skip to first unread message

Mick Fox

unread,
Jan 23, 2023, 10:19:44 AM1/23/23
to xnat_discussion
We want to anonymize some dates by removing the day to leave only Month & Year.  I tried this:
// truncate these dates to YYYYMM
(0008,0012) := substring[ (0008,0012), 0, 6]

It worked great on most data.  Once there were some images with an unexpectedly shorter date, it threw and Exception and stopped anonymization.  Is there something comparable to "if length > 6"?  Perhaps a Regex pattern for this?

Thanks,
-Mick

Charlie Moore

unread,
Jan 24, 2023, 5:25:26 PM1/24/23
to xnat_discussion
Hi Mick,

[Assuming you're using DicomEdit 6], how about this?
(0008,0012) ~ "\\d{7,}" ? (0008,0012) := substring[(0008,0012), 0, 6]

In English, assuming I haven't made a mistake: "if Instance Creation Date is exactly 7 or more digit characters, assign it to only the first 6 of those characters". This won't work for elements with a VR of DT (datetime), since the period and other allowed characters (+, -) will throw it off. If you need to handle that (or unexpected non-digit characters), you'd probably need something more permissive than "\\d". Give that a try and let us know how it goes.

Thanks,
Charlie Moore
Reply all
Reply to author
Forward
0 new messages