CTP Anonymizer command line

864 views
Skip to first unread message

Razvan Bocu

unread,
Feb 28, 2017, 4:33:31 AM2/28/17
to RSNA MIRC CTP/TFS User Group
Hello,

I resurect a fairly old topic, as it may be useful to others as well. What would be the most efficient(quick) way to re-factor the existing anonymizer, so that it becomes useable in a command line fashion. Thus, one may call anonymize.exe or java -jar anonymize.jar <input_dcm_file_tree> <output_dcm_file_tree>.

Any suggestions/help on this are greatly appreciated!

Thank you!

John Perry

unread,
Feb 28, 2017, 12:57:53 PM2/28/17
to rsnas-ctpmir...@googlegroups.com
Okay, okay, I get it.
 
I put a command-line tool on my GitHub site:
 
 
It installs the command-line tool, the necessary libraries, a default anonymizer script, and an empty lookup table properties file.
 
You run it from a command line:
 
java –jar DicomAnonymizerTool.jar ...parameters...
 
If you run it with no parameters, it tells you what the parameters are:
 
Usage: java -jar DicomAnonymizerTool {inputfile} {outputfile} {scriptfile} {lookuptablefile}
where:
{inputfile} is the file to be anonymized
{outputfile} is the file in which to store the anonymized file.
   If {outputfile} is '*', the anonymized file overwrites {inputfile}.
{scriptfile} is the anonymizer script.
   If {scriptfile} is missing, the default script is used.
{lookuptablefile} is the anonymizer lookup table properties file.
   If {lookuptablefile} is missing, the default lookup table is used.
 
I didn't do anything fancy, like allow you to process a whole directory tree with a single command, although that seems like a good idea.
 
JP
--
You received this message because you are subscribed to the Google Groups "RSNA MIRC CTP/TFS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rsnas-ctpmirc-user...@googlegroups.com.
To post to this group, send email to rsnas-ctpmir...@googlegroups.com.
Visit this group at https://groups.google.com/group/rsnas-ctpmirc-user-group.
For more options, visit https://groups.google.com/d/optout.

Razvan Bocu

unread,
Feb 28, 2017, 1:40:40 PM2/28/17
to RSNA MIRC CTP/TFS User Group
Thank you, it is more than I thought. I think that the Anonymizer is complete now. I'll study the code and implement the directory tree walk myself. Thank you!

SP

unread,
Mar 2, 2017, 9:09:57 AM3/2/17
to RSNA MIRC CTP/TFS User Group

I get page not found for the link above. I would like to use tool, if it is an option, under Windows and Linux. Thanks.

John Perry

unread,
Mar 2, 2017, 9:28:41 AM3/2/17
to rsnas-ctpmir...@googlegroups.com
Sorry. I thought you could download the file directly from GitHub.
 
Here is how to get it:
 
 
Click the DicomAnonymizerTool-installer.jar file link on that page.
 
On the next page, click the Download button.
 
JP
 
From: SP
Sent: Thursday, March 02, 2017 8:09 AM

SP

unread,
Mar 2, 2017, 9:43:50 AM3/2/17
to RSNA MIRC CTP/TFS User Group


Ran wget straight first. Now downloaded. Thanks. In retrospect, I should have looked. Sorry.

Razvan Bocu

unread,
Mar 7, 2017, 2:58:03 PM3/7/17
to RSNA MIRC CTP/TFS User Group
Hello,

I have a quick question. It is not directly related to this topic, but I wouldn't open another one just for it. Given a DICOM file, how would you recommend to check that this is a DICOM file, provided that, for example, you don't have a .dcm extension? I know that the problem is not trivial, but is there a library/method, which checks this and returns something like a true/false or similar answer?

Thank you for any hint with anticipation!


On Tuesday, February 28, 2017 at 11:33:31 AM UTC+2, Razvan Bocu wrote:

John Perry

unread,
Mar 7, 2017, 3:25:06 PM3/7/17
to rsnas-ctpmir...@googlegroups.com
In CTP, there are four object types: FileObject, DicomObject, XmlObject, and ZipObject.
 
FileObject is the parent class of the other three.
 
The FileObject class has a static method:
 
    public static FileObject getInstance(File file)
 
The method tries to instantiate the object that best fits the file. Once you have that, you can test what you got:
 
    FileObject fob = FileObject.getInstance(file);
    if (fob instanceof DicomObject) {
        //It's DICOM
    }
 
If I just have a file and want to look at it manually, I use DicomEditor (http://mirc.rsna.org/download/DicomEditor-installer.jar).
 
Sometimes I run across a file that is sort of DICOM but doesn't parse. In that case, I use BinaryDump (http://mirc.rsna.org/download/BiinaryDump.jar). BinaryDump has a more forgiving DICOM parser that allows you to look around in the object to see what's funky.
 
JP
 
Sent: Tuesday, March 07, 2017 1:58 PM
--

Razvan Bocu

unread,
Mar 7, 2017, 3:35:16 PM3/7/17
to RSNA MIRC CTP/TFS User Group
It seems like a very nice suggestion, I'll give it a try.


On Tuesday, February 28, 2017 at 11:33:31 AM UTC+2, Razvan Bocu wrote:

Razvan Bocu

unread,
Mar 8, 2017, 8:05:27 AM3/8/17
to RSNA MIRC CTP/TFS User Group
Another quick question, what version of dcm4che does the CTP engine use, 2 or 3?


On Tuesday, February 28, 2017 at 11:33:31 AM UTC+2, Razvan Bocu wrote:

John Perry

unread,
Mar 8, 2017, 9:06:51 AM3/8/17
to rsnas-ctpmir...@googlegroups.com
CTP uses dcm4che-1.4 (updated with all the new elements defined by DICOM through 2015).
 
JP
 
Sent: Wednesday, March 08, 2017 7:05 AM
Subject: [MIRC CTP/TFS User Group] Re: CTP Anonymizer command line
 
--

Razvan Bocu

unread,
Mar 21, 2017, 6:14:47 AM3/21/17
to RSNA MIRC CTP/TFS User Group
Hello,

I would like to ask a punctual question. Is there a way, using the actual CTP code or else, to check whether a DICOM file is anonymized or not? Thank you for any suggestion with anticipation.


On Tuesday, February 28, 2017 at 11:33:31 AM UTC+2, Razvan Bocu wrote:

John Perry

unread,
Mar 21, 2017, 9:14:05 AM3/21/17
to rsnas-ctpmir...@googlegroups.com
In principle, you can look at element (0012,0062) PatientIdentityRemoved to see if a file has been anonymized.
 
If the value is YES, then the PHI is supposed to have been removed by some previous agent.
 
Elements (0012,0063) DeIdentificationMethod and (0012,0064) DeIdentificationMethodCodeSeq, if present, may provide additional information on what information was removed or modified.
 
The default DicomAnonymizer script for these elements looks like this:
 
<e en="T" t="00120062" n="PatientIdentityRemoved">@always()YES</e>
<e en="T" t="00120063" n="DeIdentificationMethod">@always()@append(){CTP Default:  based on DICOM PS3.15 AnnexE. Details in 0012,0064}</e>
<e en="T" t="00120064" n="DeIdentificationMethodCodeSeq">113100/113105/113107/113108/113109</e>
 
You can look in the referenced part of the standard to see what the method codes mean.
 
If you change the script to keep certain PHI, you must alter those three elements to make them correctly describe the anonymized object.
 
JP
 
Sent: Tuesday, March 21, 2017 5:14 AM
Subject: [MIRC CTP/TFS User Group] Re: CTP Anonymizer command line
 
--

John Perry

unread,
Mar 21, 2017, 9:21:37 AM3/21/17
to rsnas-ctpmir...@googlegroups.com
One more thing:
 
In the anonymized script, you can avoid anonymizing an object twice if you set the PatientIdentityRemoved script to:
 
   @always()@if(this,equals,"YES"){@skip()}{YES}
 
That might or might not be a good idea depending on what you are trying to do, but it's an option.
 
JP
 
Sent: Tuesday, March 21, 2017 5:14 AM
Subject: [MIRC CTP/TFS User Group] Re: CTP Anonymizer command line
 
--

Jason Hostetter

unread,
Aug 4, 2017, 10:16:26 AM8/4/17
to RSNA MIRC CTP/TFS User Group
This tool is great!

In order to integrate this into a custom anonymization pipeline, it would be nice to be able to dynamically override default values set in the anonymizer-script file on a per-job basis (like patient name or accession). Is there a way to do this i.e. with command line flags?

Thanks,

Jason


On Tuesday, March 21, 2017 at 9:21:37 AM UTC-4, John Perry wrote:
One more thing:
 
In the anonymized script, you can avoid anonymizing an object twice if you set the PatientIdentityRemoved script to:
 
   @always()@if(this,equals,"YES"){@skip()}{YES}
 
That might or might not be a good idea depending on what you are trying to do, but it's an option.
 
JP
 
Sent: Tuesday, March 21, 2017 5:14 AM
Subject: [MIRC CTP/TFS User Group] Re: CTP Anonymizer command line
 
Hello,
 
I would like to ask a punctual question. Is there a way, using the actual CTP code or else, to check whether a DICOM file is anonymized or not? Thank you for any suggestion with anticipation.

On Tuesday, February 28, 2017 at 11:33:31 AM UTC+2, Razvan Bocu wrote:
Hello,
 
I resurect a fairly old topic, as it may be useful to others as well. What would be the most efficient(quick) way to re-factor the existing anonymizer, so that it becomes useable in a command line fashion. Thus, one may call anonymize.exe or java -jar anonymize.jar <input_dcm_file_tree> <output_dcm_file_tree>.
 
Any suggestions/help on this are greatly appreciated!
 
Thank you!
--
You received this message because you are subscribed to the Google Groups "RSNA MIRC CTP/TFS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rsnas-ctpmirc-user-group+unsub...@googlegroups.com.
To post to this group, send email to rsnas-ctpmirc-user-group@googlegroups.com.

John Perry

unread,
Aug 4, 2017, 10:55:29 AM8/4/17
to rsnas-ctpmir...@googlegroups.com
Jason:
 
Are you talking about CTP or the DicomAnonymizerTool?
 
Neither has command line parameters for modifying the DicomAnonymizer script, but it would at least be possible to implement in the DicomAnonymizerTool.
 
If you are talking about CTP, the best you can do is to use the built-in script editor to tweak the script before submitting your images.
 
If you are talking about the DicomAnonymizerTool, you can us the –da {scriptfilepath} parameter to specify your own script. Run the program with no parameters to see all the parameters it supports.
 
JP
To unsubscribe from this group and stop receiving emails from it, send an email to rsnas-ctpmirc-user...@googlegroups.com.
To post to this group, send email to rsnas-ctpmir...@googlegroups.com.

Jason Hostetter

unread,
Aug 7, 2017, 10:08:47 AM8/7/17
to rsnas-ctpmir...@googlegroups.com
Hi John,

I'm referring to the DicomAnonymizerTool. My use case would be for instance generating a certain accession number in a script which then calls the DAT. I could programmatically write the script file xml each time, but thought it would be easier and less error prone to just pass some override values via flags.

Perhaps there are some node.js libraries that make rewriting XML straightforward, i.e. replacing a specific value, in which case it might not be too difficult to rewrite that file from a base anonymizer script each time.

To unsubscribe from this group and stop receiving emails from it, send an email to rsnas-ctpmirc-user-group+unsubscr...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "RSNA MIRC CTP/TFS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rsnas-ctpmirc-user-group+unsub...@googlegroups.com.
To post to this group, send email to rsnas-ctpmirc-user-group@googlegroups.com.
Visit this group at https://groups.google.com/group/rsnas-ctpmirc-user-group.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "RSNA MIRC CTP/TFS User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rsnas-ctpmirc-user-group/g5j75i0nKpQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rsnas-ctpmirc-user-group+unsub...@googlegroups.com.

John Perry

unread,
Aug 9, 2017, 9:43:23 AM8/9/17
to rsnas-ctpmir...@googlegroups.com
I put a new DicomAnonymizerTool on the RSNA site at http://mirc.rsna.org/download/DicomAnonymizerTool-installer.jar.
 
The version has two new parameters that let you modify the script on the command line:
 
    -e{element} lets you specify a script for the specified element.
    -p{param} lets you specify a value for the specified parameter.
 
Running the program with no parameters lists all the options:
 
java -jar dat.jar
Usage: java -jar DAT {parameters}
where:
  -in {input} specifies the file or directory to be anonymized
       If {input} is a directory, all files in it and its subdirectories are processed.
  -out {output} specifies the file or directory in which to store the anonymized file or files.
       If -out is missing and -in specifies a file, the anonymized file is named {input}-an.
       If -out is missing and -in specifies a directory, an output directory named {input}-an is created.
       If {output} is missing and -in specifies a file, the anonymized file overwrites {input}
       If {output} is present and -in specifies a file, the anonymized file is named {output}
       If {output} is present and -in specifies a directory, an output directory named {output} is created.
  -f {scriptfile} specifies the filter script.
       If -f is missing, all files are accepted.
       If {scriptfile} is missing, the default script is used.
  -da {scriptfile} specifies the anonymizer script.
       If -da is missing, element anonymization is not performed.
       If {scriptfile} is missing, the default script is used.
  -p{param} "{value}" specifies a value for the specified parameter.
       {value} must be encapsulated in quotes.
  -e{element} "{script}" specifies a script for the specified element.
       {element} may be specified as a DICOM keyword, e.g. -ePatientName.
       {element} may be specified as (group,element), e.g. -e(0010,0010).
       {element} may be specified as [group,element], e.g. -e[0010,0010].
       {element} may be specified as groupelement, e.g. -e00100010.
       {script} must be encapsulated in quotes.
  -lut {lookuptablefile} specifies the anonymizer lookup table properties file.
       If -lut is missing, the default lookup table is used.
  -dpa {pixelscriptfile} specifies the pixel anonymizer script file.
       If -dpa is missing, pixel anonymization is not performed.
       If {pixelscriptfile} is missing, the default pixel script is used.
  -dec specifies that the image is to be decompressed if the pixel anonymizer requires it.
  -rec specifies that the image is to be recompressed after pixel anonymization if it was decompressed.
  -test specifies that the pixel anonymizer is to blank regions in mid-gray.
  -check {frame} specifies that the anonymized image is to be tested to ensure that the images load.
       If -check is missing, no frame checking is done.
       If {frame} is missing, only the last frame is checked.
       If {frame} is specified as first, only the first frame is checked.
       If {frame} is specified as last, only the last frame is checked.
       If {frame} is specified as all, all frames are checked.
  -n {threads} specifies the number of parallel threads used for processing.
  -v specifies verbose output
 
You can specify as many element scripts and parameters as you want.
 
The modifications to the script do not modify the script file itself; they only apply to the current execution of the program.
 
As an example, this command will change the PatientName and PatientID elements in all the DICOM files in the CTstudy directory, writing the modified files to the CTstudy-an directory:
 
    java –jar dat.jar –in CTstudy –da –ePatientName "Bugs Bunny" –e[0010,0020] "12345"
 
JP
To unsubscribe from this group and stop receiving emails from it, send an email to rsnas-ctpmirc-user...@googlegroups.com.
To post to this group, send email to rsnas-ctpmir...@googlegroups.com.

Jason Hostetter

unread,
Aug 10, 2017, 9:03:34 AM8/10/17
to rsnas-ctpmir...@googlegroups.com
This is great, and exactly what I was hoping for. Thanks for implementing that so quickly.

Jason

To unsubscribe from this group and stop receiving emails from it, send an email to rsnas-ctpmirc-user-group+unsubscr...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "RSNA MIRC CTP/TFS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rsnas-ctpmirc-user-group+unsub...@googlegroups.com.
To post to this group, send email to rsnas-ctpmirc-user-group@googlegroups.com.
Visit this group at https://groups.google.com/group/rsnas-ctpmirc-user-group.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "RSNA MIRC CTP/TFS User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rsnas-ctpmirc-user-group/g5j75i0nKpQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rsnas-ctpmirc-user-group+unsub...@googlegroups.com.

Rahul Deo

unread,
Jan 14, 2018, 3:40:18 PM1/14/18
to RSNA MIRC CTP/TFS User Group
I've been using the DicomAnonymizerTool for echocardiograms - i.e. cardiac ultrasounds.  I'm working both on a Linux cluster (with the command line tool) and on a Mac (with either the command line tool or the CTP Launcher).  These studies typically have a mixture of videos and stills. I'm working both on a Linux cluster (with the command line tool) and on a Mac (with either the command line tool or the CTP Launcher).  I've noticed that although the videos can be successfully anonymized at the pixel level, the stills are being skipped with the error ("The DICOMPixelAnonymizer returned SKIP.  Aborting the processing of this file").  When I run the study through a CTP pipeline on my Mac, nothing is "skipped" but only the videos are deidentified and the corresponding pixels on the still images remain unmodified.

Is there any obvious reason for this anyone can think about?  I've downloaded the source code but haven't gotten a chance to poke around to get a more informative error.

Thanks!

Rahul
Reply all
Reply to author
Forward
0 new messages