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

Rik
Rik 2020년 11월 4일
You could consider using parts of the Dicom Toolbox that Dirk-Jan Kroon published on the FEX. I am also working on that, but my code is not yet in a shape where I'm comfortable publishing it on the FEX myself. The code by Dirk-Jan is less robust, but it often at least an order of magnitude faster than dicomread and dicominfo.
Lars Tolbod
Lars Tolbod 2020년 11월 4일
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 2020년 11월 4일
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);

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 DICOM Format에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

2020년 11월 4일

댓글:

Rik
2020년 11월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by