Modifying the StudyInstanceUID Tag

114 views
Skip to first unread message

Howard

unread,
Nov 23, 2015, 1:59:37 AM11/23/15
to DicomBrowser users
Hi,

I'm a radiologist with a Teaching File of several thousand cases created with OsiriX. Each case contains multiple Series— so several to thousands of images (.dcm files) per case. 

My knowledge of DICOM is rudimentary.

In order to keep all the component Series of a Case "merged" in one Study I put the Case Number in the StudyInstanceUID Tag (0020, 000d) of every file for a particular case using Osirix's Anonymizer. For example, 00234, for Case 234.

Of course, this violates the DICOM standard for this Tag.

I have now acquired my own root: 1.2.826.0.1.3680043.9.5830

Is there any way to use DicomBrowser with a script (or just a command line-initiated script)  that will go through every case in my Teaching File to incrementally modify this Tag?  That is, to modify the tag for Case 1 to 1.2.826.0.1.3680043.9.5830.1, Case 2 to 1.2.826.0.1.3680043.9.5830.2, and so on ? 

Thanks for any advice.

Howard




Herrick, Rick

unread,
Nov 23, 2015, 9:53:47 AM11/23/15
to dicombrow...@googlegroups.com
Hi Howard,

You could use DicomRemap to do this pretty easily, although exactly HOW you do it could vary.

Basically you want to set your tag to a particular value. If you have your sessions divided into folders—that is, you know that all of the files in folder X should have StudyInstanceUID 1.2.826.0.1.3680043.9.5830.1, you can create a script, maybe by folder name, so X.das: 

(0020,000D) := "1.2.826.0.1.3680043.9.5830.1"

Then run this against files from study X:

DicomRemap -d X.das -o Xresult X/*

This will copy all of the files from X into Xresult, applying the script from X.das. Repeat for Y and Z. Since you have thousands of cases, you’ll want to automate this with a bash script or something similar, but it’s basically just a matter of mapping the correct UID to the correct source study and writing that out to the appropriate destination for each of those thousands of cases.

You can also write a single script that uses conditionals to set the appropriate value. So, for example, to go from 00234 to 1.2.826.0.1.3680043.9.5830.234, your script would look like this:

(0020,000D) = "00234" : (0020,000D) := "1.2.826.0.1.3680043.9.5830.234"

You could then build a script that contains all of the mappings you need in one script file. That would probably be less performant overall, since changing one value would require running through an entire script on each execution, but it may not be too bad and might be useful if it’s more difficult to map out the folders.

HTH.

-- 

Rick Herrick

Sr. Programmer/Analyst

Neuroinformatics Research Group

Washington University School of Medicine

(314) 740-5961


--
You received this message because you are subscribed to the Google Groups "DicomBrowser users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dicombrowser-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 


The materials in this message are private and may contain Protected Healthcare Information or other information of a sensitive nature. If you are not the intended recipient, be advised that any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error, please immediately notify the sender via telephone or return mail.

Howard

unread,
Nov 23, 2015, 4:37:07 PM11/23/15
to DicomBrowser users


On Monday, November 23, 2015 at 7:53:47 AM UTC-7, Rick Herrick wrote:

Hi Howard,

(edit)
 

You could then build a script that contains all of the mappings you need in one script file. That would probably be less performant overall, since changing one value would require running through an entire script on each execution, but it may not be too bad and might be useful if it’s more difficult to map out the folders.

.........

Hi Rick,

Thanks so much for your response.

I'm intrigued by your thoughs about a script with conditionals. I'm a radiologist with definitely no coding skills, and would need substantial help with it.

In OsiriX, many cases are present in one folder. One cannot readily determine when one case stops, and another starts.

I would execute the script in OsiriX's (top-level) Database folder.

So, the script would have to code (something like) the following:

1. Perform the following actions in all the subfolders of this folder.
2. For every file you encounter with a .dcm extension...
3. Examine the content of the 0020,000d tag.
4. For content that matches the form "0000x" change it to "1.2.826.0.1.3680043.9.5830.x"
5. For content that matches the form "000xx" change it to "1.2.826.0.1.3680043.9.5830.xx"
6. For content that matches the form "00xxx" change it to "1.2.826.0.1.3680043.9.5830.xxx"
7. For content that matches the form "0xxxx" change it to "1.2.826.0.1.3680043.9.5830.xxxx"

(As I now know, no leading zeros are permitted in the string.)

I have previously used the Command Line for basic operations. I'll need reminding how to make a bash script executable, etc.

I would have to use this on my (backed-up) Database once only as I'll do this properly going forward as I add new cases. (I do have colleagues that would appreciate this too.)

Would you (or anyone else in this Forum) perhaps be able to create the script, and tell me how to use it ?  I could test it on a separate OsiriX Database I have.

Best regards,

Howard

Howard

unread,
Feb 10, 2016, 3:17:35 PM2/10/16
to DicomBrowser users


On Monday, November 23, 2015 at 7:53:47 AM UTC-7, Rick Herrick wrote:
Hi Howard,

You could use DicomRemap to do this pretty easily, although exactly HOW you do it could vary.

Basically you want to set your tag to a particular value. If you have your sessions divided into folders—that is, you know that all of the files in folder X should have StudyInstanceUID 1.2.826.0.1.3680043.9.5830.1, you can create a script, maybe by folder name, so X.das: 

(0020,000D) := "1.2.826.0.1.3680043.9.5830.1"

Then run this against files from study X:

DicomRemap -d X.das -o Xresult X/*

This will copy all of the files from X into Xresult, applying the script from X.das. Repeat for Y and Z. Since you have thousands of cases, you’ll want to automate this with a bash script or something similar, but it’s basically just a matter of mapping the correct UID to the correct source study and writing that out to the appropriate destination for each of those thousands of cases.

You can also write a single script that uses conditionals to set the appropriate value. So, for example, to go from 00234 to 1.2.826.0.1.3680043.9.5830.234, your script would look like this:

(0020,000D) = "00234" : (0020,000D) := "1.2.826.0.1.3680043.9.5830.234"

You could then build a script that contains all of the mappings you need in one script file. That would probably be less performant overall, since changing one value would require running through an entire script on each execution, but it may not be too bad and might be useful if it’s more difficult to map out the folders.

HTH.

-- 

Rick Herrick

....


Hi,

A colleague suggested the use of a Regular Expression:   (this,"^0*(.*)","$1")  to accomplish this renaming.

Now, I don't know anything about the use/applicability of such Expressions in general. 

Would that perhaps work in some way with this app ?

Thanks,


Howard 
Reply all
Reply to author
Forward
0 new messages