read ascii headers in Siemens MRI DICOM files

832 views
Skip to first unread message

Elyne

unread,
Oct 6, 2014, 3:51:00 PM10/6/14
to pyd...@googlegroups.com
Hello,

I've been exploring the pydicom package with the aim of retrieving and storing most of the MRI acquisition parameters in a humanly-readable format.

Unfortunately, some of the key parameters are not retrieved in the dataset returned by the dicom.read_file() method.

It turns out that these parameters are listed in the ascii part of the DICOM file header only.

I don't know how other manufacturer's nor other modality's headers are structured (I've only worked with Siemens MRI data) and maybe the answer is simply that the ascii part of the header is not standard hence not taken into account in pydicom... But I thought it was worth posting the question anyway, in case some of you'd have bumped into this issue in the past... and found a work-around to it :)!

Thanks for your time reading this email at least!

Elyne

Darcy Mason

unread,
Oct 6, 2014, 10:58:58 PM10/6/14
to pyd...@googlegroups.com
Hi Elyne,

I'm not sure what you mean by the ascii part of a dicom header (dicom files are binary, but many of the tag item values are ascii), but there are two things that might be related.  One is that there is a "preamble" in the DICOM standard of 128 bytes that is usually just a series of zero bytes, but perhaps some applications store some information in that preamble.  Secondly, pydicom stores the "file meta" information of the DICOM standard separately from the main dataset. The file meta, however, typically has a limited number of specific tags permitted, which are really just there to give information about the type of file and its representation.

After reading a file like:
dataset = dicom.read_file(...), 
the preamble is in dataset.preamble, and the file meta information is in dataset.file_meta, which is its own dataset instance.

Perhaps the information you are looking for is in one of those objects?

Oh, and I thought of a third possibility.  Most acquisition parameters should be specified in normal dicom tags, but manufacturers have been known to put much more detailed information in private tags. Those are still accessible from pydicom, but only using the (group, element) tag number, not through keywords.

Darcy

Matthew Brett

unread,
Oct 10, 2014, 6:45:47 PM10/10/14
to pyd...@googlegroups.com
Hi,
I think you mean the 'ASCCONV' text file embedded in the Siemens DICOM file.

That in turn is embedded in a binary blob in a Siemens private
element. You can read these with ``nibabel.nicom``:

For example, here's loading that part of the header from an example
file we have in the nibabel code-base:

curl -O -L https://github.com/nipy/nibabel/raw/master/nibabel/nicom/tests/data/siemens_dwi_0.dcm.gz
gunzip siemens_dwi_0.dcm.gz
python
>>> import dicom
>>> dcm_data = dicom.read_file('siemens_dwi_0.dcm')
>>> from nibabel.nicom import csareader as csar
>>> csa = csar.get_csa_header(dcm_data, 'series')
>>> ascii_header = csa['tags']['MrPhoenixProtocol']['items'][0]

``ascii_header`` is a string containing the text, which combines an
XML-like (!) text part and the ASCCONV embeded text file.

Cheers,

Matthew
Reply all
Reply to author
Forward
0 new messages