Can I read a single field using DICOMINFO?
Show older comments
Hi all,
Ive got a pretty large number of dicom files, and using "dicominfo" for each image is causing my GUI to run extremely slowly. I'd like to read a single field of the header that I am interested in, rather than having to read in the entire thing as I'm not using 99% of it.
Does anyone know how this might be accomplished?
Cheers Jim
Accepted Answer
More Answers (2)
ILÁN FRANCISCO CARRETERO JUCHNOWICZ
on 17 Jun 2020
3 votes
Hi,
I recently contacted MathWorks Support and they have advised me the following solution:
''there is an undocumented way you might be able to extract 'dicominfo' faster. Please see the following example.
>> obj = images.internal.dicom.DICOMFile('CT-MONO2-16-ankle.dcm');
>> info = obj.getAttributeByName('SeriesTime');
This method first creates an object to extract the attributesNames and then use 'getAttributeByName' to read the information of a particular attribute. "
I have tried the commands detailed above and it works really well and faster than the dicominfo function.
I hope it helps you!
2 Comments
thatguy14
on 4 Mar 2021
This worked really well!
radha soni
on 20 May 2021
great solution thank you
drummer
on 22 Apr 2019
Well, some of the meta-data are the same from a set of dicom images you're working on.
There's this Dicom Library I use which is very useful to find the tag I want: https://www.dicomlibrary.com/dicom/dicom-tags/
So, if you want to extract a single header, do the following:
% reading the dicom
[file, path] = uigetfile('*.dcm');
addpath(path);
disp(['User selected ', fullfile(path, file)]);
info = dicominfo(file);
dicom = dicomread(file);
%extracting the header you want, for example:
sliceThickness = info.(dicomlookup('0018', '0050'))
%Then you can use it as a value to whateve calculation you want.
Notice that the dicominfo will work anyway. The diference is that you're using only the header you want.
It will be only necessary if the header value changes along the image. Otherwise, this might solve some problems.
1 Comment
Walter Roberson
on 22 Apr 2019
The original poster had hoped to avoid doing dicominfo() on the files. The issue was not finding the tag: the issue was that dicominfo() spends a bunch of time interpreting all of the tags for the file, and that was slowing the user down a lot because they only needed a small number of specific tags.
Categories
Find more on Read and Write Image Data from Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!