Importing a list of specific tags in one call to Import
is not possible right now, but we will try to add support for this in the next release. Currently, MetaInformation
can only handle one subelement which must be a string. In the simplest case this will be a name of a DICOM tag, e.g. "PixelData", but it is possible to pass a simple pattern to import a bunch of related tags at once, for instance:
In[94]:= Import["ExampleData/head.dcm.gz", {"MetaInformation", "PatientName"}]
Out[94]= "Male 1958 Anonymous"
In[95]:= Import["ExampleData/head.dcm.gz", {"MetaInformation", "Patient*"}]
Out[95]= <|"PatientName" -> "Male 1958 Anonymous",
"PatientID" -> "GH-WISE:68736", "PatientSex" -> "M",
"PatientBirthName" -> "anonymous",
"PatientMotherBirthName" -> "anonymous",
"PatientTelephoneNumbers" -> "anonymous",
"PatientReligiousPreference" -> "anonymous",
"PatientComments" -> "anonymous", "PatientPosition" -> "HFS"|>
That being said, you can still read a list of tags without calling Import
multiple times if you are willing to use DICOMTools paclet directly (Import
uses this paclet under the hood). Paclet functions are not documented and we don't guarantee backwards compatibility for them, but they often offer more flexibility then Import
interface:
In[97]:= Needs["DICOMTools`"]
In[98]:= file = First @ ExtractArchive @ FindFile @ "ExampleData/head.dcm.gz";
In[99]:= DICOMTools`ReadMetadata[file, {"PatientName", "RescaleSlope", "RescaleIntercept"}]
Out[99]= <|"PatientName" -> "Anonymous^Male 1958", "RescaleSlope" -> "1.53968253968253", "RescaleIntercept" -> "0.0"|>
Two things to notice: paclet only works with full paths and does not handle compressed DICOMs, so we need an extra step to uncompress the sample file and secondly, values are imported as they are stored in the file, without post-processing or formatting (so for instance, numbers are imported as strings and dates will not be automatically converted to WolframLanguage DateObject
s).
If you wish to format the returned data, another step is needed:
In[113]:= rawMeta = DICOMTools`ReadMetadata[file, {"PatientName", "RescaleSlope", "RescaleIntercept"}]
Out[113]= <|"PatientName" -> "Anonymous^Male 1958", "RescaleSlope" -> "1.53968253968253", "RescaleIntercept" -> "0.0"|>
In[114]:= DICOMTools`ConvertMetadata[file][rawMeta]
Out[114]= <|"PatientName" -> "Male 1958 Anonymous", "RescaleSlope" -> 1.5396825, "RescaleIntercept" -> 0.|>
To answer your second question - Import
only supports tag keywords, but the paclet can read tags using (group, elem) values. They can be specified in the form: {"GGGG", "EEEE"}
(leading 0s can be omitted). For example:
In[105]:= DICOMTools`ReadMetadata[file, {{"0028", "1053"}, {"10", "40"}}]
Out[105]= <|"RescaleSlope" -> "1.53968253968253", "PatientSex" -> "M"|>
In the returned Association tag names are used as keys anyway, but if you prefer, you can always replace any tag name with its group-elem id using the following function:
In[107]:= DICOMTools`GetGroupElemNumbers["PixelData"]
Out[107]= {"7FE0", "10"}
In[108]:= DICOMTools`GetGroupElemNumbers["PatientAge"]
Out[108]= {"10", "1010"}
There is also a reverse function:
In[109]:= DICOMTools`GetKeyword[{"7FE0", "0010"}]
Out[109]= "PixelData"
In[110]:= DICOMTools`GetKeyword[{"10", "1010"}]
Out[110]= "PatientAge"
Notice that it only works with standard DICOM tags. I guess that 2005_100e
that you use in your example is vendor-specific and so the paclet will not know its name:
In[111]:= DICOMTools`GetKeyword[{"2005", "100e"}]
Out[111]= "Unknown Tag & Data"