Borrar filtros
Borrar filtros

Can I read a single field using DICOMINFO?

10 visualizaciones (últimos 30 días)
Jim O'Doherty
Jim O'Doherty el 7 de Jun. de 2013
Comentada: radha soni el 20 de Mayo de 2021
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

Respuesta aceptada

Jim O'Doherty
Jim O'Doherty el 12 de Ag. de 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 comentarios
mohd akmal masud
mohd akmal masud el 19 de Feb. de 2018
Editada: Walter Roberson el 19 de Feb. de 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 el 19 de Feb. de 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.

Iniciar sesión para comentar.

Más respuestas (2)

ILÁN FRANCISCO CARRETERO JUCHNOWICZ
ILÁN FRANCISCO CARRETERO JUCHNOWICZ el 17 de Jun. de 2020
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 comentarios
thatguy14
thatguy14 el 4 de Mzo. de 2021
This worked really well!
radha soni
radha soni el 20 de Mayo de 2021
great solution thank you

Iniciar sesión para comentar.


drummer
drummer el 22 de Abr. de 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 comentario
Walter Roberson
Walter Roberson el 22 de Abr. de 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.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by