Thread Subject: dicomlookup problem

Subject: dicomlookup problem

From: Ingunn

Date: 12 Sep, 2007 11:51:44

Message: 1 of 4

I use dicomlookup to extract only certain tags from images
in a dicomdir.
My problem is when a tag is not present in the dicom
header, in that case dicomlookup stops the routine and I
get an error message:

??? Reference to non-existent field 'ScanOptions'.

Error in ==> Rdcm>hListboxDirCallback at 244
dcminfo.ScanMode = gdata.metadata.(dicomlookup
('0018','0022')); can mode

Is there an easy way to work around the problem?
I'd like to avoid dicominfo because I'm only interested in
a few tags (to use in the routine, and for display on the
GUI)

Thanks
Ingunn

Subject: dicomlookup problem

From: Jeff Mather

Date: 12 Sep, 2007 15:43:44

Message: 2 of 4

Ingunn wrote:
> I use dicomlookup to extract only certain tags from images
> in a dicomdir.
> My problem is when a tag is not present in the dicom
> header, in that case dicomlookup stops the routine and I
> get an error message:
>
> ??? Reference to non-existent field 'ScanOptions'.
>
> Error in ==> Rdcm>hListboxDirCallback at 244
> dcminfo.ScanMode = gdata.metadata.(dicomlookup
> ('0018','0022')); can mode
>
> Is there an easy way to work around the problem?
> I'd like to avoid dicominfo because I'm only interested in
> a few tags (to use in the routine, and for display on the
> GUI)
>
> Thanks
> Ingunn


Hi Ingunn,

The DICOMLOOKUP function only gives you the name that corresponds to a
(group,element) pair, and vice versa. It doesn't actually communicate
with any files or parse any data. You will still need to use DICOMINFO
to parse the file.

If you have more time than I do to devote to this task, you can actually
hack up a pretty good solution that parses the whole file but doesn't do
the slower post-parsing step that turns *all* of the raw data into what
you would see with DICOMINFO. It's not hard to make this solution, but
there's just too much going on here to actually put a robust, more
usable solution like it into the toolbox. So, good luck...

The DICOM parser in toolbox/images/medformats/private is quite easy to
call and produces a well-contained output:

     attrs = dicomparse(fileDetails.name, ...
                        fileDetails.bytes, ...
                        getMachineEndian, ...
                        false, ...
                        dicomdict('get_current'));

Be sure to call it with the correct arguments or you can get a
segmentation violation, which is bad. Replace "fileDetails.name" and
"fileDetails.bytes" with the filename and the number of bytes in the
file. Replace getMachineEndian with either 'L' or 'B' depending on
whether you're running on a little-endian machine (Windows, Linux, Intel
Mac) or big-endian machine (other kinds of UNIX hardware). The "false"
value performs some optimizations; I would recommend leaving it as is.

The result is a structure array with these fields:

* Group - A double containing the attribute's group number
* Element - A double containing the attribute's element number
* VR - A two-letter code giving the DICOM datatype (or empty)
* Name - More or less the result of dicomlookup(Group,Element)
* IsLittleEndian - 1 if the attribute contains little-endian data
* Data - Either the raw bytes of the attribute's data or another
structure of attributes containing sequence data

If you go this route, your task is to search "attrs" for the group and
element you're looking for, which is rather easy using something like this:

   idx = find(([attrs.Group] == myGroup) & ([attrs.Element] == myElement));

What you do with the values in "attrs(idx).Data" is your business and
will probably depend on what you want to do with the data. Because Data
will contain UINT8 values, you will likely need to transform them into
other MATLAB datatypes that correspond to the actual data intent. Look
to the functions CHAR, TYPECAST, and SWAPBYTES for help. The
translation rules require a fair bit of knowledge about DICOM, but you
can likely find the information you need for simple types in the
convertRawAttr() function in DICOMINFO.

Good luck!

Jeff Mather
Image Processing Group
The MathWorks, Inc.

Subject: dicomlookup problem

From: Paul Biegel

Date: 16 Aug, 2010 15:57:09

Message: 3 of 4

Jeff,

I have tried to implement the workaround but it is not possible to call the dicomparse
function. I need to add the path of the directory where this file is stored, but it is not allowed to add paths that are in a 'private' directory. Is there another possibility to call this function? Thanks in advance.

Jeroen

Jeff Mather <jeff.mather@mathworks.com> wrote in message <46E80930.1040905@mathworks.com>...
> Ingunn wrote:
> > I use dicomlookup to extract only certain tags from images
> > in a dicomdir.
> > My problem is when a tag is not present in the dicom
> > header, in that case dicomlookup stops the routine and I
> > get an error message:
> >
> > ??? Reference to non-existent field 'ScanOptions'.
> >
> > Error in ==> Rdcm>hListboxDirCallback at 244
> > dcminfo.ScanMode = gdata.metadata.(dicomlookup
> > ('0018','0022')); can mode
> >
> > Is there an easy way to work around the problem?
> > I'd like to avoid dicominfo because I'm only interested in
> > a few tags (to use in the routine, and for display on the
> > GUI)
> >
> > Thanks
> > Ingunn
>
>
> Hi Ingunn,
>
> The DICOMLOOKUP function only gives you the name that corresponds to a
> (group,element) pair, and vice versa. It doesn't actually communicate
> with any files or parse any data. You will still need to use DICOMINFO
> to parse the file.
>
> If you have more time than I do to devote to this task, you can actually
> hack up a pretty good solution that parses the whole file but doesn't do
> the slower post-parsing step that turns *all* of the raw data into what
> you would see with DICOMINFO. It's not hard to make this solution, but
> there's just too much going on here to actually put a robust, more
> usable solution like it into the toolbox. So, good luck...
>
> The DICOM parser in toolbox/images/medformats/private is quite easy to
> call and produces a well-contained output:
>
> attrs = dicomparse(fileDetails.name, ...
> fileDetails.bytes, ...
> getMachineEndian, ...
> false, ...
> dicomdict('get_current'));
>
> Be sure to call it with the correct arguments or you can get a
> segmentation violation, which is bad. Replace "fileDetails.name" and
> "fileDetails.bytes" with the filename and the number of bytes in the
> file. Replace getMachineEndian with either 'L' or 'B' depending on
> whether you're running on a little-endian machine (Windows, Linux, Intel
> Mac) or big-endian machine (other kinds of UNIX hardware). The "false"
> value performs some optimizations; I would recommend leaving it as is.
>
> The result is a structure array with these fields:
>
> * Group - A double containing the attribute's group number
> * Element - A double containing the attribute's element number
> * VR - A two-letter code giving the DICOM datatype (or empty)
> * Name - More or less the result of dicomlookup(Group,Element)
> * IsLittleEndian - 1 if the attribute contains little-endian data
> * Data - Either the raw bytes of the attribute's data or another
> structure of attributes containing sequence data
>
> If you go this route, your task is to search "attrs" for the group and
> element you're looking for, which is rather easy using something like this:
>
> idx = find(([attrs.Group] == myGroup) & ([attrs.Element] == myElement));
>
> What you do with the values in "attrs(idx).Data" is your business and
> will probably depend on what you want to do with the data. Because Data
> will contain UINT8 values, you will likely need to transform them into
> other MATLAB datatypes that correspond to the actual data intent. Look
> to the functions CHAR, TYPECAST, and SWAPBYTES for help. The
> translation rules require a fair bit of knowledge about DICOM, but you
> can likely find the information you need for simple types in the
> convertRawAttr() function in DICOMINFO.
>
> Good luck!
>
> Jeff Mather
> Image Processing Group
> The MathWorks, Inc.

Subject: dicomlookup problem

From: Jeff Mather

Date: 18 Aug, 2010 14:12:10

Message: 4 of 4

"Paul Biegel" <hammermanneke@hotmail.com> wrote in message <i4bn4l$qlv$1@fred.mathworks.com>...
> Jeff,
>
> I have tried to implement the workaround but it is not possible to call the dicomparse
> function. I need to add the path of the directory where this file is stored, but it is not allowed to add paths that are in a 'private' directory. Is there another possibility to call this function? Thanks in advance.

I believe you should be able to copy the dicomparse MEX-file to another directory and add that to your path. The MEX-file is fairly self-contained; you just need to pass in the names of the DICOM file and the data dictionary.

Good luck!

Jeff Mather
Image Processing Group
MathWorks

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
dicom Sestina 12 Sep, 2007 07:55:21
rssFeed for this Thread

Contact us at files@mathworks.com