フィルターのクリア

Help with listbox in DICOM

3 ビュー (過去 30 日間)
Adam
Adam 2012 年 2 月 9 日
編集済み: Image Analyst 2013 年 10 月 7 日
Hi, I have more questions? When you load paintings (DICOM) in the list box will display the first list, but when I select another from the listbox does not appear. Thanks a lot in advance.
h1=figure;
handles.ListBox=uicontrol('Units','Normalized','Position',[0.01 0.1 0.1 0.15],...
'Style','List');
P=fileparts(mfilename('fullpath'));
nfolder=uigetdir(P,'cokoliv');
handles.dfolder=nfolder;
dfiles=dir(handles.dfolder);
dfiles=dfiles(3:end);
nfiles=length(dfiles);
if nfiles<1
disp('no files availabel.')
return;
end
set(handles.ListBox,'String',char(dfiles.name),'value',1);
s = [num2str(nfiles) ' files in: ' handles.dfolder];
fname=get(handles.ListBox,'String');
fname=fname(get(handles.ListBox,'value'),:);
info=dicominfo([handles.dfolder '\' fname]);
Y1=dicomread(info);
imshow(Y1)
clims = [10 1800];

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 2 月 9 日
Your part from 'fname=' onward should be in a separate routine that you have set as being the Callback for the uicontrol. This will probably require that you wrap your original code inside a function
function dilist
h1 = figure;
handles.ListBox=uicontrol('Units','Normalized','Position',[0.01 0.1 0.1 0.15],...
'Style','List', 'Callback', @dilist_callback);
P=<etc>
[...]
s = [num2str(nfiles) ' files in: ' handles.dfolder];
end
function dilist_callback(src, evt)
fname=get(handles.ListBox,'String');
fname=fname(get(handles.ListBox,'value'),:);
info=dicominfo([handles.dfolder '\' fname]);
Y1=dicomread(info);
imshow(Y1)
clims = [10 1800];
end
  1 件のコメント
Adam
Adam 2012 年 2 月 9 日
I followed your instructions. But after launching matlab I reported the error:
??? Undefined variable "handles" or class "handles.ListBox".
Error in ==> dilist> dilist_callback at 23
fname = get (handles.ListBox, 'String');
??? Evaluating Error while uicontrol Callback
function dilist
h1 = figure;
handles.ListBox = uicontrol ('Units', 'Normalized', 'Position', [0.01 0.1 0.1 0.15], ...
'Style', 'List', 'Callback', @ dilist_callback);
P = fileparts (mfilename ('fullpath'));
nfolder uigetdir = (P, 'whatever');
handles.dfolder = nfolder;
dfiles = dir (handles.dfolder);
dfiles dfiles = (3: end);
nfiles = length (dfiles);
nfiles if <1
disp ('no files availabel.')
return;
end
set (handles.ListBox, 'String', char (dfiles.name), 'value', 1);
s = [num2str (nfiles) 'files in:' handles.dfolder];
end
dilist_callback function (src, evt)
fname = get (handles.ListBox, 'String');
fname = fname (get (handles.ListBox, 'value'), :);
dicominfo info = ([handles.dfolder '\' fname]);
Y1 = dicomread (info);
imshow (Y1)
clims = [10 1800];
end
do not know where I made a mistake? Thank you very much.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by