Can I read a single field using DICOMINFO?

19 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Jim O'Doherty
Jim O'Doherty il 12 Ago 2013
Just to post a follow up - I found a way around this using the dicomtoolkit (just google dcmtk). I'm using a Mac
This gives you access to a host of extra dicom functionality, including the ability to query a dicom file header using a single tag - thereby allowing a route around using "dicominfo". Below is an example I used to find the slice index in a sequence.
images(:,:,count) = dicomread([pathname fname]); %read each file
str=['dcmdump +P "0020,0013" ' ([pathname fname])]; %create the string
[s,result]=system(str); %run command in Unix terminal
pos_index=strfind(result, ']')-1; %search for the second square bracket
n_instance(count) = str2double(result(17:pos_index));
This saved me almost 9 minutes while analysing a sequence of 11,000 files (it now takes 3).
Jim
  4 Commenti
mohd akmal masud
mohd akmal masud il 19 Feb 2018
Modificato: Walter Roberson il 19 Feb 2018
Hi all,
I want to extract the RescaleSlope value from dicominfo for each slice. But i have 135 slice images. This is my code to extract RescaleSlope. But still failed.
P = zeros(256, 256, 135);
for K = 1 : 135
petname = sprintf('PET_I1001_PT%03d.dcm', K);
P(:,:,K) = dicominfo(petname);
end
info=dicominfo(P(:,:,K));
[r,c,slice] = findND (info.RescaleSlope);
Anyone who can help me solve this problem???
Walter Roberson
Walter Roberson il 19 Feb 2018
You posted the same thing as https://www.mathworks.com/matlabcentral/answers/383405-extract-rescale-slope-value . No point in people dividing their attention.

Accedi per commentare.

Più risposte (2)

ILÁN FRANCISCO CARRETERO JUCHNOWICZ
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!

drummer
drummer il 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 Commento
Walter Roberson
Walter Roberson il 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.

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by