App designer - file data store error, read function does not exist.

Hello,
I am trying to create a GUI with App Designer, which loads a file to UIAxes. With scrolling Mousewheel or a Slider I want to scroll through multiple files.
I used the FileDatastore approach where I create a dataarray, which includes the files. This works fine in the normal Matlab Editor, but in the App designer it shows an error, that the customreader function does not exist.
defined private function:
function data = customreader(~,filename)
dcm = org.dcm4che2.data.BasicDicomObject;
din = org.dcm4che2.io.DicomInputStream(...
java.io.BufferedInputStream(java.io.FileInputStream(filename)));
din.readDicomObject(dcm, -1);
rows = dcm.getInt(org.dcm4che2.data.Tag.Rows);
cols = dcm.getInt(org.dcm4che2.data.Tag.Columns);
pixeldata = dcm.getInts(org.dcm4che2.data.Tag.PixelData);
data = reshape(pixeldata, rows,cols);
end
function LoadTBButtonPushed(app, event)
%load file
folder = uigetdir();
if isequal(folder,0)
app.FileEditField.Value = 'no file selected';
else
location = folder;
fds = fileDatastore(location, 'ReadFcn', @customread, 'FileExtensions','.ima');
dataarray = readall(fds);
i = 1;
% Remove title, axis labels, and tick labels
title(app.UIAxes, []);
xlabel(app.UIAxes, []);
ylabel(app.UIAxes, []);
app.UIAxes.XAxis.TickLabels = {};
app.UIAxes.YAxis.TickLabels = {};
%show image
I = imshow(dataarray{1,1},'Parent', app.UIAxes, ...
'XData', [1 app.UIAxes.Position(3)], ...
'YData', [1 app.UIAxes.Position(4)], ...
'DisplayRange', []);
% Set limits of axes
app.UIAxes.XLim = [0 I.XData(2)];
app.UIAxes.YLim = [0 I.YData(2)];
end
Error using fileDatastore (line 102). Function customread does not exist.
is shown in Line: fds = fileDatastore(location, 'ReadFcn', @customread, 'FileExtensions','.ima');
I tried to get the letters app in there, but if I write @app.customreader, the next line sends an error.
Error using matlab.io.datastore.FileDatastore/readall (line 28)
Error using ReadFcn @(varargin)app.customread(varargin{:}) function handle for file
....\Desktop\GUI\NON_DICOM_ANONYM_FILES\1_1.CT.IMA.
No appropriate method, property, or field 'customread' for class 'prototyp_menu'.
Error in @(varargin)app.customread(varargin{:})', 'Documents\MATLAB\GUI_KM\Prototyp\prototyp_menu.mlapp', 240)" style="font-weight:bold">prototyp_menu>@(varargin)app.customread(varargin{:}) (line 240)
fds = fileDatastore(location, 'ReadFcn', @app.customread, 'FileExtensions','.ima');
Thanks for Your help!

4 件のコメント

Guillaume
Guillaume 2019 年 2 月 13 日
It sounds like your customread is not on the path when your GUI is running.
  • where is customread.m located?
  • where is the GUI code located?
  • Is there any cd call inside the GUI that could affect the current path?
Michael Werthmann
Michael Werthmann 2019 年 2 月 13 日
Hello, thanks for the answer.
customread is a function I added by using the "+" function in the codebrowser.
It is a helper function.
I have another Helper function which works well:
Definition:
function [curveInfo] = dynEvalParseFunc(~,path)
Call:
dynEvalParseFunc(app, fullFileName);
All functions are in one file, so pathing should not be a problem.
Edit: I changed the @customread to @customreader, didnt change anything
Michael Werthmann
Michael Werthmann 2019 年 2 月 13 日
@app.customreader worked!,
Thank you for your help and sorry for the dumb question...
Cheers
Stephane
Stephane 2024 年 2 月 23 日
thanks for the solution

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeEnvironment and Settings についてさらに検索

製品

リリース

R2018a

質問済み:

2019 年 2 月 13 日

コメント済み:

2024 年 2 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by