DICOM CRC check sums

1,054 views
Skip to first unread message

martin.g...@gmail.com

unread,
Apr 4, 2009, 6:38:20 AM4/4/09
to pydicom
Hi Group,

I am a novice at both DICOM and python but recently have had cause to
try to learn a bit about both and how to modify tags in DICOM files. I
have recently stumbled upon pydicom and it seems like just what I
need. Great work thanks.

I am aware some (all?) DICOM files contain a CRC checksum to ensure
file integrity.

If I use pydicom to edit the contents of a DICOM file does pydicom
take care of recalculating any CRC checksums in the background? Or do
I have to find some way to explicitly calculate and write the CRC
correctly if I modify a DICOM file?

Sorry if this is a naive question but I have been unable to find any
reference to this in the pydicom reference material.

Thankyou in advance for your comments and assistance.

Martin C

Darcy Mason

unread,
Apr 4, 2009, 11:40:39 PM4/4/09
to pydicom

On Apr 4, 6:38 am, "martin.g.caro...@gmail.com"
<martin.g.caro...@gmail.com> wrote:
> ...
> I am aware some (all?) DICOM files contain a CRC checksum to ensure
> file integrity.
>
> If I use pydicom to edit the contents of a DICOM file does pydicom
> take care of recalculating any CRC checksums in the background? Or do
> I have to find some way to explicitly calculate and write the CRC
> correctly if I modify a DICOM file?
>

I haven't heard of checksums in DICOM files. Certainly pydicom doesn't
use any when reading or writing files, and other DICOM readers do
accept the modified files.
It's possible some companies could add a checksum in the preamble or
as a private tag in their files, but I've never seen that myself. As
far as I know, file checksums are not mentioned in the DICOM standards
documents.

-Darcy

Nano.

unread,
Apr 5, 2009, 2:20:50 AM4/5/09
to pydicom
Hi Martin,

As far as I know, DICOM utilizes Digital Signatures to ensure files'
integrity. You can find more information about that on Parts 3 and 15
of the DICOM standard.

ftp://medical.nema.org/medical/dicom/2008/08_15pu.pdf (pdf version)
ftp://medical.nema.org/medical/dicom/2008/08_03pu.pdf (pdf version)

Thanks,

Nano.

Martin Carolan

unread,
Apr 8, 2009, 1:48:13 AM4/8/09
to pyd...@googlegroups.com
Nano,
 
thanks I will look at those standards. I have got some clarification from my colleagues at work I think what they were referring to as checksums were actually the GROUP LENGTH fields in the DICOM files. I will study the DICOM standards documents themselves wrt group lengths and I think this will probably answer my question.
 
Thankyou
 
Martin C

 

Darcy Mason

unread,
Apr 8, 2009, 8:41:06 AM4/8/09
to pydicom

On Apr 8, 1:48 am, Martin Carolan <martin.g.caro...@gmail.com> wrote:
> Nano,
>
> thanks I will look at those standards. I have got some clarification from my
> colleagues at work I think what they were referring to as checksums were
> actually the GROUP LENGTH fields in the DICOM files.

In that case, you should see this item on the issue list:
http://code.google.com/p/pydicom/issues/detail?id=30.
pydicom writes group length for the file meta information (group 2)
where it is required (filewriter.py function _write_file_meta_info),
but not for other groups. I did a search in the standards documents
and most use of this has been retired, and in fact it is recommended
that they be removed. Section 7.2 of DICOM standard PS3.5-2008:

...All implementations shall be able to parse Group Length elements,
and may discard and not insert or reinsert
them; if present they shall be consistent with the encoding of the
dataset even if the transfer syntax
is changed resulting in a change in the actual length of a group of
elements. No implementation shall
require the presence of Group Length elements.
Notes: 1. Elements in groups 0, 2, 4 and 6 are not Standard Data
Elements. Mandatory requirements for Group
Length for groups 0 and 2 are specified elsewhere in the standard.
2. It is recommended that Group Length elements be removed during
storage or transfer in order to
avoid the risk of inconsistencies arising during coercion of data
element values and changes in transfer
syntax.

The other mandatory one, group 0, seems to be only used for direct
DICOM communications, not in files.
I've updated the issue to include the possibility of removing the
group length items. Meanwhile you could delete them in your own code
if desired using del dataset[group, 0].
-Darcy

Martin Carolan

unread,
Apr 16, 2009, 7:55:39 PM4/16/09
to pyd...@googlegroups.com
Darcy,
 
thanks. I've been off the air for a while. I'll do some experiments with the actual systems we are using an see what happens. The application is for manipulation of radiotherapy plan datasets. (Philips Pinnacle planning system and Varian Aria R&V system.)
 
Thankyou for your help.
 
Martin C

Adit Panchal

unread,
Feb 17, 2013, 11:20:00 PM2/17/13
to pyd...@googlegroups.com
Hi Alex,

Unfortunately, the RTP format is a text format and is not the same as DICOM and thus probably cannot be read by pydicom. The format is documented and was created by Impac (now Elekta) for Mosaiq.

I believe there isn't a Python library to read these files, but Christoffer Lervåg has developed a nice library [1] to read these files in Ruby. Since it is written in pure Ruby, it could also be ported to Python as well.

However, if you are able to export from Pinnacle in the DICOM format, you can definitely try using pydicom to read those files.

Hope that helps,

Adit



On Sun, Feb 17, 2013 at 5:53 PM, Alex Nguyen <pira...@gmail.com> wrote:
I am a newbie so please accept my apology for possibly asking a naive question.  Our Pinnacle TPS exports radiation treatment plan in "RTP" format to Mosaiq which we use for treatment record and verify system.  I want to write up some python code to verify the integrity of beam data information on the day of 1st treatment fraction (since it could have been changed) as compared to the originally exported plan.  Basically, I want to compare: plan from Pinnacle versus plan from Mosaiq.  (BTW, someone out there must have done this already!)   I have naively assumed that they "talk" to each other in DICOM but apparently not.   I have tried to read_file the .RTP format file into pydicom but it returned error: " File is missing 'DICM' marker.   Thanks in advance for your input!
 
 

--
You received this message because you are subscribed to the Google Groups "pydicom" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pydicom+u...@googlegroups.com.
To post to this group, send email to pyd...@googlegroups.com.
Visit this group at http://groups.google.com/group/pydicom?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Darcy Mason

unread,
Feb 17, 2013, 11:44:33 PM2/17/13
to pyd...@googlegroups.com
Hi Alex,

Aditya's post came in as I was writing my own, so I'll add a couple of comments:

On Sunday, February 17, 2013 11:20:00 PM UTC-5, Aditya Panchal wrote:

Hi Alex,

Unfortunately, the RTP format is a text format and is not the same as DICOM and thus probably cannot be read by pydicom. The format is documented and was created by Impac (now Elekta) for Mosaiq.

I've seen the specification document for 'rtpconnect', and just looked for it online. It is here:

 

I believe there isn't a Python library to read these files, but Christoffer Lervåg has developed a nice library [1] to read these files in Ruby. Since it is written in pure Ruby, it could also be ported to Python as well.


I am also interested in checking rtp files back to a treatment planning system (CMS). I actually started coding something to read them (very early, just put some of the record/keyword names together) in python. If I ever get it functional, I'd be happy to share the code.  

Darcy
 

Alex Nguyen

unread,
Feb 18, 2013, 8:59:46 AM2/18/13
to pyd...@googlegroups.com
Adit & Darcy,

Thanks so much for your quick & informative responses!  While Ruby looks to be a great looking language, I am afraid I do not have time to learn it along with Python (which I barely started on!).  20 years ago I sat through a mind blowing demo of Smalltalk and was thoroughly impressed (I was a C programmer then).  I am not a young chicken anymore unfortunately.  My job now is physics not programing.  I would appreciate if you share the "secret source" whenever you completes it.

With that said, I may still go to the Ruby RTP library link so see what I can get done in 1-2 days.

Thanks again guys,
Alex

Darcy Mason

unread,
Feb 24, 2013, 2:48:21 PM2/24/13
to pyd...@googlegroups.com

On Sunday, February 17, 2013 11:44:33 PM UTC-5, Darcy Mason wrote:

I am also interested in checking rtp files back to a treatment planning system (CMS). I actually started coding something to read them (very early, just put some of the record/keyword names together) in python. If I ever get it functional, I'd be happy to share the code.  

It turns out I will soon need the RTPConnect file reading, so I went ahead and updated the code I had. I added the remaining record definitions and some basic reading routines. It's on bitbucket: https://bitbucket.org/darcymason/rtpconn

Darcy


Reply all
Reply to author
Forward
0 new messages