This project has moved. For the latest updates, please go here.
1

Closed

VTS_MATLAB MC_demo Error

description

Hello VP

I'm currently using the VTS_MATLAB_v1.0.13 with .NET Framework 4.5 installed and I can't get MC_demo to run, which is odd because it has worked for me in the past. It spits out the following:
Running simulation...
Simulation complete! Run time: 2.9883 seconds
  MException
  Properties:
    identifier: 'MATLAB:UndefinedFunction'
       message: 'No method '()' with matching signature found for class 'Vts.MonteCarlo.MultiLayerTissueInput'.'
         cause: {}
         stack: [4x1 struct]
  Methods
    file: 'C:\Users\MI\Desktop\VTS_MATLAB_v1.0.13Beta\vts\structures\MonteCarlo\SimulationInput.m'
    name: 'SimulationInput.FromInputNET'
    line: 24
    file: 'C:\Users\MI\Desktop\VTS_MATLAB_v1.0.13Beta\vts\structures\MonteCarlo\SimulationOutput.m'
    name: 'SimulationOutput.FromOutputNET'
    line: 12
    file: 'C:\Users\MI\Desktop\VTS_MATLAB_v1.0.13Beta\vts\VtsMonteCarlo.m'
    name: 'VtsMonteCarlo.RunSimulation'
    line: 55
    file: 'C:\Users\MI\Desktop\VTS_MATLAB_v1.0.13Beta\vts_mc_demo.m'
    name: 'vts_mc_demo'
    line: 23
Error in VtsMonteCarlo>VtsMonteCarlo.RunSimulation (line 23)
            if nargin < 2
Error using VtsMonteCarlo.RunSimulation
Output argument "output" (and maybe others) not assigned during call to
"C:\Users\MI\Desktop\VTS_MATLAB_v1.0.13Beta\vts\VtsMonteCarlo.m>VtsMonteCarlo.RunSimulation".
Error in vts_mc_demo (line 23)
output = VtsMonteCarlo.RunSimulation(si);
Thanks in advance!
Closed May 4 at 12:17 AM by hayakawa
Fixed in code by DC.

comments

dcuccia wrote Jul 18, 2013 at 8:36 PM

Hi John,

Thanks for posting this, and sorry you're having trouble.

I just downloaded v1.0.13 here, and ran vts_mc_demo.m from the root folder (I'm currently running Matlab R2013a on Windows 8 x64).

I actually ran into the following error at line 285, due to my lack of the optimization toolbox (Carole - can we change to fminsearch?):

Image

But, you can see that my calls to VtsMonteCarlo.RunSimulation (such as yours at line 23) were completing successfully. Commenting out lines 284-382 allow the script to complete successfully for me.

Can you verify that you can open Matlab, change directory to a fresh un-zipped copy of "VTS_MATLAB_v1.0.13Beta", run vts_mc_demo.m and reproduce this issue? If so, can you reproduce the error if you remove all stored custom folders from the PATH? If so, can you reproduce on a different computer? These will help the team track down the issue you may be having.

(Not a big deal, but in the future, it would be helpful if you can start these inquiries in the Discussions section, so we can first figure out what issues may need to be posted here.)

Yours,
David

hayakawa wrote Jul 18, 2013 at 8:57 PM

Thanks David for catching the use of lsqcurvefit. I downloaded a fresh copy of "VTS_MATLAB_v1.0.13Beta" and ran fine because I have the Optimization Toolbox installed, so was perplexed about the problem. Sure, I can modify the code to use fminsearch instead.
Carole

hayakawa wrote Jul 19, 2013 at 2:05 AM

I'm sorry for the trouble I caused by using a method not readily available to all that have matlab installed.

I have modified the vts_mc_demo to check if lsqcurvefit is available and if so use it to perform the optimization, otherwise use fminsearch. I created this option because lsqcurvefit was originally used because you can provide it derivative information and I do this using differential Monte Carlo (dMC). I
wanted to show how this could be done in the example. fminsearch is a non-gradient, non-constrained method and so does not take advantage of the information from dMC.

BTW, I also made this type of modification to vts_solver_demo example that performs inverse solution on R(lambda).

I pushed these updates to Bitbucket and they will be in the future VTS_MATLAB push to Codeplex.

Carole

dcuccia wrote Jul 19, 2013 at 4:04 AM

Thanks Carole - and no worries, I think most academics have access to many of the toolboxes including Optimization. If you wanted to highlight DMC, there is probably a check you can do at runtime to see if a toolbox is supported.

I don't think this was the problem John was having, though (his is crashing at line 23). So John, please do let us know if you can reproduce your issue with my suggested tests above.

nguyenjq wrote Jul 19, 2013 at 10:08 PM

Hi David,

I commented out the lines you suggested but I'm still running into the same problems on line 23 (the problem probably lies within VtsMonteCarlo.RunSimulation). The problem is indeed reproducible on the other computers in the lab and my laptop.

Best,
John

dcuccia wrote Jul 19, 2013 at 10:44 PM

Thanks John. Can you reproduce the error if you remove all stored custom folders from the PATH?

nguyenjq wrote Jul 20, 2013 at 12:04 AM

Yep. Default path + the VP folder.

dcuccia wrote Jul 20, 2013 at 12:58 AM

You should not need to add the VP folder. Can you help me debug and try w/o adding? Just run from the root VP folder with the script.

nguyenjq wrote Jul 20, 2013 at 1:12 AM

Still doesn't work. Same error.

hayakawa wrote Jul 20, 2013 at 8:15 PM

What version of matlab are you running?

nguyenjq wrote Jul 20, 2013 at 8:46 PM

2012b

hayakawa wrote Jul 20, 2013 at 10:45 PM

Thats the version I have. Since you tried all that David suggested, I'm sorry I'm currently out of suggestions.

ponticorvo wrote Jul 21, 2013 at 6:40 PM

Hi all,

After talking with John, I became interested in trying to utilize the latest Matlab utilities for the virtual photonics website. Unfortunately, I am also experiencing the same error. This is running Matlab 2012b, .NET Framework 4.5, but I get the same errors using older combinations of Matlab, .NET Framework, and the Matlab utilities.

I tried to debug it a little more, and it seems like even though the simulation appears to finish running, there is a problem in the structure of the output variable. For some reason, the variable below is essentially missing some information.

outputNET.Input.TissueInput.Regions


At some point the MultiLayerTissueInput class tries to access outputNET.Input.TissueInput.Regions and it crashes with the error that John posted earlier.

Does that gives anyone any additional ideas as to what the problem could be?

dcuccia wrote Jul 21, 2013 at 8:32 PM

Not sure. Sometimes Matlab has a hard time doing nested field access for .NET objects. If you can isolate the problem, you can wrap it with some error handling code like this:

try
% your code here...
catch e
e.message;
if(isa(e, 'NET.NetException'))
eObj = e.ExceptionObject
end
end

...which will print out the entire .NET exception stack, which might give us some clues. Can you narrow down to the exact line (is it either line 22 or line 23 of MultiRegionTissueInput.m)?

Also - are you around BLI today? I can come take a look on your machine...

ponticorvo wrote Jul 21, 2013 at 10:54 PM

I'm not around BLI today, but I can make time during the week to show you the error. I'll try and insert the catch statement so I can print out the exception and post the results later.

The exact line that fails is line 25 of MultiRegionTissueInput.m when it tries to access this variable inputNET.Regions(i).ZRange.Start. I am not too familiar with accessing these .NET objects, but it seems like whatever is supposed to be there is empty. Most of the other fields in that object seem fine.

dcuccia wrote Jul 21, 2013 at 11:23 PM

Thanks for clarifying - that's strange. Ok, I'm generally around next week and happy to help.

In the meantime, try the following to debug - inside the "for" loop, create a local reference, and then use that instead:
            regionNET = inputNET.Regions(i);
            regions(i).ZRange = [...
                regionNET.ZRange.Start, ...
                regionNET.ZRange.Stop ...
                ];
            regions(i).RegionOP = [ ...
                regionNET.RegionOP.Mua, ...
                regionNET.RegionOP.Musp, ...
                regionNET.RegionOP.G, ...
                regionNET.RegionOP.N ...
                ];

ponticorvo wrote Jul 22, 2013 at 1:27 AM

That's interesting. That seems like it fixes the problem. It still crashes later on, but it looks like the next crash is a variation of that same problem. The common theme at first glance seems to be, whenever it has to access an indexed field of an object, it crashes unless you create a local variable.

dcuccia wrote Jul 22, 2013 at 5:21 AM

Great, thanks Adrien. Could you do us a big favor? Since we can't replicate the error on our side, can you make edits to the appropriate files, and send them (just the edited ones) my way in a .zip file?

dcuccia wrote Jul 24, 2013 at 10:25 PM

Adrien - thanks for the emailed file changes. I've just pushed a version of those changes up to our private source tree, and they should make it out in the next release.

Carole - thanks for the changes to add fminsearch. One other change I needed was to set "options = [];" for the case of fminsearch - LargeScale and Diagnostics are not optimset options w/o the optimization toolbox.

hayakawa wrote Jul 24, 2013 at 11:25 PM

Thanks Adrien and David!