Effacer les filtres
Effacer les filtres

Using pydicom in MatLab

14 vues (au cours des 30 derniers jours)
Lars Tolbod
Lars Tolbod le 4 Nov 2020
Commenté : Rik le 4 Nov 2020
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 commentaires
Lars Tolbod
Lars Tolbod le 4 Nov 2020
Thanks, Rik. But I'm not sure I understand why it should be faster. As far as I can tell the Dicom Toolbox is also just using dicominfo from the Image Processing Toolbox?
Rik
Rik le 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);

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur DICOM Format dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by