Standalone compiled with Matlab compiler doesn't work
16 views (last 30 days)
Show older comments
I have compiled a .exe file of MRiLab (https://se.mathworks.com/matlabcentral/fileexchange/45456-mrilab-v1-2-1) using Matlab compiler.
The program is an excellent MRI-Simulator with which you can, for example, load different phantoms and image them with different MRI sequences and imaging parameters.However, the compiled exe from MRiLab does not work as it does in Matlab. Standalone application of program starts but does not work fully. For example, when I select an MRI sequence the program gives an error message (when the exe is started in Matlab):
Error using DoParseXML (line 60)
Failed to read XML file C:\Users\sylisiur\AppData\Local\Temp\sylisiur\mcrCache9.9\MRiLab1\MRiLab\PSD\3D\FastSpinEcho\PSD_FSE3D\PSD_FSE3D.xml.
Error in SeqList>Seq_listbox_Callback (line 272)
Error in gui_mainfcn (line 95)
Error in SeqList (line 94)
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)SeqList('Seq_listbox_Callback',hObject,eventdata,guidata(hObject))
Error using waitforallfiguresclosed (line 16)
Error while evaluating UIControl Callback.
Sometimes the program lets you select some of a sequences, but when I then press the scan button it gives a new error message:
To correct the error, I have tried e.g. change the MCR_CACHE_ROOT to another path that also did not help or delete the mcrcache9.9 folder and run the program again. The versions of Matlab (R2020b) and Runtime (v9.9) also match. Apparently the problem, I think, is with the DoParseXML function (code below)?
I have been trying for a long time to solve the problem and I would be very grateful if someone could help?
BR: S.Y
function theStruct = DoParseXML(dnode)
%DoParseXML(XML_filename)
%convert XML file to a MATLAB structure.
try
tree = xmlread(dnode);
catch me
error('Failed to read XML file %s.',dnode);
end
% Recurse over child nodes. This could run into problems
% with very deeply nested trees.
theStruct = parseChildNodes(tree);
theStruct.current=1;
% ----- Subfunction PARSECHILDNODES -----
function children = parseChildNodes(theNode)
% Recurse over node children.
children = [];
if theNode.hasChildNodes
childNodes = theNode.getChildNodes;
numChildNodes = childNodes.getLength;
allocCell = cell(1, numChildNodes);
children = struct('Name', allocCell,...
'Attributes', allocCell,...
'Data', allocCell,...
'Children', allocCell,...
'current', allocCell);
i=0;
for count = 1:numChildNodes
theChild = childNodes.item(count-1);
c = makeStructFromNode(theChild);
if isempty(c)
i=i+1;
else
children(count-i) = c;
end
end
if i>0
children(numChildNodes-i+1:numChildNodes)=[];
end
end
% ----- Subfunction MAKESTRUCTFROMNODE -----
function nodeStruct = makeStructFromNode(theNode)
% Create structure of node info.
PC=parseChildNodes(theNode);
nodeStruct = struct('Name', char(theNode.getNodeName),...
'Attributes', parseAttributes(theNode),...
'Data', '',...
'Children', PC,...
'current',0);
if any(strcmp(methods(theNode), 'getData'))
nodeStruct.Data = char(theNode.getData);
else
nodeStruct.Data = '';
end
if strcmp(nodeStruct.Name,'#text')
nodeStruct=[];
end
% ----- Subfunction PARSEATTRIBUTES -----
function attributes = parseAttributes(theNode)
% Create attributes structure.
attributes = [];
if theNode.hasAttributes
theAttributes = theNode.getAttributes;
numAttributes = theAttributes.getLength;
allocCell = cell(1, numAttributes);
attributes = struct('Name', allocCell,...
'Value', allocCell);
for count = 1:numAttributes
attrib = theAttributes.item(count-1);
attributes(count).Name = char(attrib.getName);
attributes(count).Value = char(attrib.getValue);
end
end
0 Comments
Accepted Answer
Bruno Luong
on 30 Apr 2022
Have you include PSD_FSE3D.xml in the packaging?
Do you take into account the path of the file is different when you run in standalone mode?
0 Comments
More Answers (3)
See Also
Categories
Find more on Dialog Boxes in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!