Using pydicom in MatLab
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm experimenting with using pydicom functions inside MatLab as an alternative to dicominfo to speed up reading of dicoms.
I import the module and read the dicom header of the file dcmFile using dcmread:
py.importlib.import_module('pydicom');
ds=py.pydicom.dcmread([dcmFile],false,true);
It works really well, but how do I efficiently extract single tags from the ds object?
As an example, in python, I would use ds[0008,103e] or ds.SeriesDescription to get the Series Description tag. But this doesn't work in Matlab for the Python FileDataset object.
The following works, but is rather cumbersome:
tmp=ds.data_element('SeriesDescription'); seriesDescription=char(tmp.value);
Is there a better way to extract tags?
Thanks,
Lars
3 Kommentare
Rik
am 4 Nov. 2020
I assumed he would be using his same code everywhere, apparently not. This submission doesn't use the builtin tools. You might want to use the code below to create the dictionary.
%%replace this
% Load Dicom Tag Library
functionname='ReadDicomElementList.m';
functiondir=which(functionname);
functiondir=functiondir(1:end-length(functionname));
load([functiondir 'Dictonary/DicomTagDictionary.mat']);
%%with this
dict_base=ingest_dict;
dcmdic.group=zeros(size(dict_base,1),1);
dcmdic.element=zeros(size(dict_base,1),1);
for n=1:size(dict_base,1)
dcmdic.group(n)=hex2dec(dict_base{n,1});
dcmdic.element(n)=hex2dec(dict_base{n,2});
end
dcmdic.type=dict_base(:,3);
dcmdic.name=dict_base(:,4);
Antworten (0)
Siehe auch
Kategorien
Mehr zu DICOM Format finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!