Some DICOM questions

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Some DICOM questions

Stein Rørvik
From previous examples posted to this list,
we can read DICOM tags in a macro like this:

open("http://imagej.nih.gov/ij/images/ct.dcm.zip");
studyDescription = getInfo("0008,1030");
print("Study Description: "+ studyDescription);

This works fine.
If we select Show Info, the corresponding line is listed like this:
0008,1030  Study Description: TEMP BONE/ST NECK W

My question is:
Is there any easy way to get returned the DICOM tag name (in the above example "Study Description")
as a string if I only know the DICOM tag number?

What I want to do is something similar to this:
DicomTag = "0008,1030";
tagValue = getDicomTagValue(DicomTag);
tagName = getDicomTagName(DicomTag);
print("DICOM Tag Name: "+ tagName);
print("DICOM Tag Value: "+ tagValue);

Another question, for those who work with medical data:

If I have a DICOM three node of various scans done at the same MRI investigation,
do any of the DICOM tags describe where the scans are located in the patient?
That is, some kind of patient coordinate system that is the same for all scan?
(assuming that the patient was not moved, of course)

What I want to do is to select a certain point of interest in the patient,
and create X Y Z orthoviews of the same location in all scans.
Since I have no expertise in radiology, locating the same structure visually is not so
easy as the scans are done with different contrast methods and aligned at different angles.

If there is some kind of patient coordinate system in the DICOM tags,
I could calculate the corresponding pixel in each stack and do a reslice along each axis through that point.

Stein

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Some DICOM questions

Michael Schmid-3
Hi Stein,

concerning your first question only:

The DICOM dictionary (translation between tag names and numbers) is in
ij.plugin.DICOM.  If there is an ImageJ/DICOM_Dictionary.txt file,
ImageJ uses that file instead (if I understood it correctly).
As far as I can see, currently there is no public method to retrieve it
in Java, so also no way to access it via a macro.


Michael
________________________________________________________________
On 31/08/2018 16:12, Stein Rørvik wrote:

>  From previous examples posted to this list,
> we can read DICOM tags in a macro like this:
>
> open("http://imagej.nih.gov/ij/images/ct.dcm.zip");
> studyDescription = getInfo("0008,1030");
> print("Study Description: "+ studyDescription);
>
> This works fine.
> If we select Show Info, the corresponding line is listed like this:
> 0008,1030  Study Description: TEMP BONE/ST NECK W
>
> My question is:
> Is there any easy way to get returned the DICOM tag name (in the above example "Study Description")
> as a string if I only know the DICOM tag number?
>
> What I want to do is something similar to this:
> DicomTag = "0008,1030";
> tagValue = getDicomTagValue(DicomTag);
> tagName = getDicomTagName(DicomTag);
> print("DICOM Tag Name: "+ tagName);
> print("DICOM Tag Value: "+ tagValue);
>
> Another question, for those who work with medical data:
>
> If I have a DICOM three node of various scans done at the same MRI investigation,
> do any of the DICOM tags describe where the scans are located in the patient?
> That is, some kind of patient coordinate system that is the same for all scan?
> (assuming that the patient was not moved, of course)
>
> What I want to do is to select a certain point of interest in the patient,
> and create X Y Z orthoviews of the same location in all scans.
> Since I have no expertise in radiology, locating the same structure visually is not so
> easy as the scans are done with different contrast methods and aligned at different angles.
>
> If there is some kind of patient coordinate system in the DICOM tags,
> I could calculate the corresponding pixel in each stack and do a reslice along each axis through that point.
>
> Stein
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Some DICOM questions

Curtis Rueden
In reply to this post by Stein Rørvik
Hi Stein,

> Is there any easy way to get returned the DICOM tag name
> as a string if I only know the DICOM tag number?

SCIFIO's implementation of DICOM has the ability to retrieve a tag name
from its ID.  Here is an example Groovy script:

  dict = new io.scif.formats.dicom.DICOMDictionary()
  studyDescName = dict.name(0x00081030)
  println(studyDescName)

Which prints:

  Study Description

To use this from the macro language would require clever usage of eval or
call.

As an aside: the wiki page https://imagej.net/DICOM is intended to house
DICOM tips, tricks and FAQs all in one place -- please add your knowledge
there.

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Did you know ImageJ has a forum? https://forum.image.sc/



On Fri, Aug 31, 2018 at 9:14 AM Stein Rørvik <[hidden email]> wrote:

> From previous examples posted to this list,
> we can read DICOM tags in a macro like this:
>
> open("http://imagej.nih.gov/ij/images/ct.dcm.zip");
> studyDescription = getInfo("0008,1030");
> print("Study Description: "+ studyDescription);
>
> This works fine.
> If we select Show Info, the corresponding line is listed like this:
> 0008,1030  Study Description: TEMP BONE/ST NECK W
>
> My question is:
> Is there any easy way to get returned the DICOM tag name (in the above
> example "Study Description")
> as a string if I only know the DICOM tag number?
>
> What I want to do is something similar to this:
> DicomTag = "0008,1030";
> tagValue = getDicomTagValue(DicomTag);
> tagName = getDicomTagName(DicomTag);
> print("DICOM Tag Name: "+ tagName);
> print("DICOM Tag Value: "+ tagValue);
>
> Another question, for those who work with medical data:
>
> If I have a DICOM three node of various scans done at the same MRI
> investigation,
> do any of the DICOM tags describe where the scans are located in the
> patient?
> That is, some kind of patient coordinate system that is the same for all
> scan?
> (assuming that the patient was not moved, of course)
>
> What I want to do is to select a certain point of interest in the patient,
> and create X Y Z orthoviews of the same location in all scans.
> Since I have no expertise in radiology, locating the same structure
> visually is not so
> easy as the scans are done with different contrast methods and aligned at
> different angles.
>
> If there is some kind of patient coordinate system in the DICOM tags,
> I could calculate the corresponding pixel in each stack and do a reslice
> along each axis through that point.
>
> Stein
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Some DICOM questions

Wayne Rasband-2
In reply to this post by Stein Rørvik
> On Aug 31, 2018, at 10:12 AM, Stein Rørvik <[hidden email]> wrote:
>
> From previous examples posted to this list,
> we can read DICOM tags in a macro like this:
>
> open("http://imagej.nih.gov/ij/images/ct.dcm.zip");
> studyDescription = getInfo("0008,1030");
> print("Study Description: "+ studyDescription);
>
> This works fine.
> If we select Show Info, the corresponding line is listed like this:
> 0008,1030  Study Description: TEMP BONE/ST NECK W
>
> My question is:
> Is there any easy way to get returned the DICOM tag name (in the above example "Study Description")
> as a string if I only know the DICOM tag number?

The latest ImageJ daily build (1.52f44) adds a DicomTools.getTagName() method that can be called from a macro. For example, this macro

  name = call("ij.util.DicomTools.getTagName", "0008,1030");
  print("Tag name: "+ name);

outputs

  Tag name: Study Description

-wayne


> What I want to do is something similar to this:
> DicomTag = "0008,1030";
> tagValue = getDicomTagValue(DicomTag);
> tagName = getDicomTagName(DicomTag);
> print("DICOM Tag Name: "+ tagName);
> print("DICOM Tag Value: "+ tagValue);
>
> Another question, for those who work with medical data:
>
> If I have a DICOM three node of various scans done at the same MRI investigation,
> do any of the DICOM tags describe where the scans are located in the patient?
> That is, some kind of patient coordinate system that is the same for all scan?
> (assuming that the patient was not moved, of course)
>
> What I want to do is to select a certain point of interest in the patient,
> and create X Y Z orthoviews of the same location in all scans.
> Since I have no expertise in radiology, locating the same structure visually is not so
> easy as the scans are done with different contrast methods and aligned at different angles.
>
> If there is some kind of patient coordinate system in the DICOM tags,
> I could calculate the corresponding pixel in each stack and do a reslice along each axis through that point.
>
> Stein

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Some DICOM questions

Fred Damen
In reply to this post by Stein Rørvik
Greetings,

See inline...

Fred

On Fri, August 31, 2018 9:12 am, Stein Rørvik wrote:
>>From previous examples posted to this list,
> we can read DICOM tags in a macro like this:
>
> open("http://imagej.nih.gov/ij/images/ct.dcm.zip");

This is a radiograph, i.e., planar X-Ray, not a CT.

> studyDescription = getInfo("0008,1030");
> print("Study Description: "+ studyDescription);
>
> This works fine.
> If we select Show Info, the corresponding line is listed like this:
> 0008,1030  Study Description: TEMP BONE/ST NECK W
>
> My question is:
> Is there any easy way to get returned the DICOM tag name (in the above example
> "Study Description")
> as a string if I only know the DICOM tag number?
>
> What I want to do is something similar to this:
> DicomTag = "0008,1030";
> tagValue = getDicomTagValue(DicomTag);
> tagName = getDicomTagName(DicomTag);
> print("DICOM Tag Name: "+ tagName);
> print("DICOM Tag Value: "+ tagValue);

I have included below some Java methods that I use to get the values per a
DICOM tag on a slice bases. These should be easy to convert to macro language
of your choice.  Each DICOM object has a tag/value list.  The DICOMTools,
i.e., builtin methods, only gives the value(s) for the tag in the first slice.
 If you are trying to process MRI diffusion/ASL/fMRI/MRE you are stuck rolling
your own to get the values per slice.  Usually each DICOM object is a slice,
but it does not have to be.

Note that only the public tags, i.e., odd groups, are going to have human
readable names, unless you grab the DICOM Dictionary from the vendor that
produced your DICOM dataset(s).

>
> Another question, for those who work with medical data:
>
> If I have a DICOM three node of various scans done at the same MRI
> investigation,
> do any of the DICOM tags describe where the scans are located in the patient?
> That is, some kind of patient coordinate system that is the same for all scan?
> (assuming that the patient was not moved, of course)

There is no patient coordinae system per se.  There is a coordinate system for
the inside of the bore of the magnet.  The sweet spot is at 0,0,0, i.e., the
most homogeneous static / RF magnetic field in the center of the bore.  There
are tags for the location of the patient with reference to this coordinate
system, i.e., 0020,0032 and 0020,0037.

>
> What I want to do is to select a certain point of interest in the patient,
> and create X Y Z orthoviews of the same location in all scans.
> Since I have no expertise in radiology, locating the same structure visually
> is not so
> easy as the scans are done with different contrast methods and aligned at
> different angles.
Usually the anatomical and other datasets are collected with the same  FOV,
i.e., orientation and integer multiple resolution, specifically due to problem
you are trying to solve; thus your options are going to be limited.  I would
look at 3Dslice or Osirix/Horos for possible options.

>
> If there is some kind of patient coordinate system in the DICOM tags,
> I could calculate the corresponding pixel in each stack and do a reslice along
> each axis through that point.
If you insist on rolling your own, search for the aforementioned tags.

The other datasets with interesting contrast are generally much lower
resolution and under rotational interpolation do not maintain their fidelity
to the underlying anatomical dataset.

Note that the calibrated coordinates that ImageJ displays, at least for MRI
datasets, is wrong, i.e., the aforementioned coordinate system tags are
ignored.

>
> Stein
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>


   public double[]  getArray(ImagePlus imp, int s, String tag) {
      String[] vs = getTag(imp, s, tag).split("\\\\");
      double[] ia = new double[vs.length];
      for(int i=0; i<vs.length; i++)
         ia[i] = Double.parseDouble(vs[i]);
      return ia;
      }
   public double getDouble(ImagePlus imp, int s, String tag) {
      return Double.parseDouble(getTag(imp, s, tag));
      }
   public int getInt(ImagePlus imp, int s, String tag) {
      return Integer.parseInt(getTag(imp, s, tag));
      }
// In hind sight I named the method backwards.
// Change the [1] to [0] and it will return the tag name for humans...
   public String getTag(ImagePlus imp, int s, String tag) {
      for(String line : imp.getStack().getSliceLabel(s).split("\n"))
         if (line.startsWith(tag))
            return line.split(": ",2)[1];
      return null;
      }

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html