Can I read a single field using DICOMINFO?

16 次查看(过去 30 天)
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

采纳的回答

Jim O'Doherty
Jim O'Doherty 2013-8-12
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 个评论
mohd akmal masud
mohd akmal masud 2018-2-19
编辑:Walter Roberson 2018-2-19
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???

请先登录,再进行评论。

更多回答(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 2019-4-22
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 个评论
Walter Roberson
Walter Roberson 2019-4-22
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.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by