フィルターのクリア

Using pydicom in MatLab

14 ビュー (過去 30 日間)
Lars Tolbod
Lars Tolbod 2020 年 11 月 4 日
コメント済み: Rik 2020 年 11 月 4 日
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 件のコメント
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 件)

カテゴリ

Help Center および File ExchangeDICOM Format についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by