Re: [mcx-users] error pop out when run mmc in Matlab

23 views
Skip to first unread message

Qianqian Fang

unread,
Jun 27, 2024, 10:11:16 PM6/27/24
to Q W, mcx-...@googlegroups.com, mmc-...@googlegroups.com

I am not exactly sure what you wanted - usually you need a .json file when running mmc binary in a terminal instead of in matlab. if you use matlab, you just define the cfg structure, as shown by all the examples you saw, you do not need the json file.

I guess my question is: why you want to run mmc binary inside matlab? why can't you run it in a terminal window?

On 6/27/24 20:23, Q W wrote:
Hello Dr. Fang,

Many thanks for your reply. I checked the examples one by one but did not find any related to using .json file as input in MMC.

All the examples are like the following screenshot, [xx, xx]=mmclab(cfgs)
image.png

Do you have any other suggestions? Highly appreciated.

Best wishes,
Sunny

Qianqian Fang <q.f...@neu.edu> 于2024年6月25日周二 04:55写道:

hi Sunny,

you can't use the mmc command line in matlab. it doesn't work that way.


to use mmclab, you should run

help mmclab

in matlab and read the input/output format of the mmclab command. you should also try the sample code at the end of the help info, or open and read each of the sample scripts under

https://github.com/fangq/mmc/tree/master/mmclab/example


Qianqian


On 6/24/24 19:47, Q W wrote:
Dear Qianqian,

I hope this email finds you well!
I have a .json file as input for MMC, I wonder why when I use the command:

>> mmc -f example.json -D P --momentum 1 -b 1 -d 1

My Matlab always crashes?
My purpose is to get diffuse reflectance and photon history file .mch.

image.png

Many thanks for your help.
Best regards,
Sunny
--
You received this message because you are subscribed to the Google Groups "mcx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mcx-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mcx-users/CAOvA73SYVa%3DJ5_PKK4_w%3DjKsEoT29EWnKuq8mRViZCEMVuhMGg%40mail.gmail.com.

Qianqian Fang

unread,
Jun 28, 2024, 11:18:19 PM6/28/24
to Q W, mcx-...@googlegroups.com, mmc-...@googlegroups.com

hi Sunny,

mmc binary and mmclab can both handle layered medium or irragular/complex domains.

mmclab cfg data structure and a MMC JSON based files can also define both types of domains. There is no connection between JSON and irregular geometry.


when you say a .json file, do you mean an mmc input JSON file for the mmc command-line? like this one: https://github.com/fangq/mmc/blob/master/examples/skinvessel/dmmc_skinvessel.json

if you already have constructed such input file - then you should run "mmc -f input.json" in a terminal like in this sample script

https://github.com/fangq/mmc/blob/master/examples/skinvessel/run_dmmc.sh


we currently only provide the mmc2json function to convert an mmclab cfg struct to an mmc JSON input file, but not vice versa

https://github.com/fangq/mmc/blob/master/mmclab/mmc2json.m

hope you can clarify this a bit more

Qianqian


On 6/28/24 18:26, Q W wrote:
Thanks for your reply, Dr. Fang.

The reason why I need a .json file is that my model is irregular geometry, I wrote all of its parameters into the .json file:
image.png

From my understanding,  [xx, xx]=mmclab(cfgs) is only for a slab model, right?  I have run a simulation using [xx, xx]=mmclab(cfgs) which is for 3-layer slabs (a regular geometry!).

Oh, maybe I could run my simulation in a terminal window.

Many thanks.
Sunny

Qianqian Fang <q.f...@neu.edu> 于2024年6月28日周五 03:11写道:

Qianqian Fang

unread,
Jul 18, 2024, 11:14:56 AM7/18/24
to Q W, mcx-...@googlegroups.com, mmc-...@googlegroups.com

hi Sunny,

on windows, if you want to run a bash/sh script (with suffix .sh), you must install and start a terminal program that uses bash as the default shell. you can pick any one of the following choices:


1. install Git for windows (https://gitforwindows.org/) and start a git bash terminal

2. install msys2 (https://www.msys2.org/) and start the msys2 terminal

3. install cygwin64 (https://www.cygwin.com/), and run the cygwin64 terminal

4. install WSL2 (https://www.windowscentral.com/how-install-wsl2-windows-10), install a Linux distribution, and start a terminal from the installed Linux


as a matter of fact, the .sh script is just a text file, if you open it with a text editor (such as notepad/pspad), you can see there is just one simple command starting with mmc. running that command does not necessarily require bash. you can directly copy paste this command in a DOS terminal (cmd) or power-shell terminal (PowerShell), cd to the directory where you want to run it, and run the command in DOS or powershell. if either mmc or the input file is not found, please make sure you type the correct full path for both.


again, as someone presumably just start using mmc, unfortunately you picked the most difficult path by trying to run 1) mmc in the command line and 2) run a bash script on windows. I still do not understand why you can not use mmclab with matlab, which is a lot more beginner-friendly.


Qianqian


On 7/17/24 18:16, Q W wrote:
Hello Dr Fang,

I hope you are doing well!

I was trying to run a .sh file for my simulations, and tried the following three ways:

#1. In the Matlab, I used this command: --- failed 
image.png

#2. In the example folder, right-click on the run_test.sh-->Git for Windows, and the pop-out window crashes (shows up and disappears fast as the attached video shows). ---failed
image.png

In the previous email, you mentioned terminal, do you mean the Window PowerShell?
could you please advise?
Many thanks for your help.

Best,
Sunny

Qianqian Fang <q.f...@neu.edu> 于2024年6月29日周六 04:18写道:

Qianqian Fang

unread,
Jul 18, 2024, 11:18:31 AM7/18/24
to Q W, mcx-...@googlegroups.com, mmc-...@googlegroups.com

just a kind reminder: please do not send large attachment files, such as the video recording you attached previously, to either mcx-users or mmc-users mailing list.

there are around 400 subscribers to these mailing lists, sending large attachments creates burdens to many of the subscribers. Please place anything larger than 1-2 MB to a cloud storage, such as dropbox or google drive, and only share the link with the email.

Qianqian Fang

unread,
Jul 28, 2024, 9:05:55 PM7/28/24
to Q W, mcx-...@googlegroups.com, mmc-...@googlegroups.com

why you used mcxlab example in the screenshot if you were referring to mmclab?

have you checked out the examples folder in mmclab?

https://github.com/fangq/mmc/tree/master/mmclab/example


On 7/28/24 19:29, Q W wrote:
Thank you for your kind reminder, Dr Fang. I apologize for the inconvenience caused.

In your previous email you mentioned that mmclab cfg data structure can define the layered medium or irragular/complex domains.

I have checked all the examples you attached and published, it seems they are layered mediums:
image.png

what if my medium is irregular as shown in Figure (b) then how can I set the Vol in cfg?
image.png

Specifically, for example:
image.png


Many thanks!
Sunny


Qianqian Fang <q.f...@neu.edu> 于2024年7月18日周四 16:18写道:

Qianqian Fang

unread,
Jul 30, 2024, 11:32:56 PM7/30/24
to Q W, mcx-...@googlegroups.com, mmc-...@googlegroups.com
On 7/29/24 18:26, Q W wrote:
Dear Dr Fang,

Thank you for your time and patience!

I realized that I had been using mcxlab for layered medium in my previous study. You remind me that there is mmclab, I have checked the published examples, some use mcxlab and some use mmclab. Gently ask what is the difference between them?


please read our papers. they have all the answers

https://mcx.space/#publication



Currently, I am trying to build a cfg structure for my simulation on the irregular medium.  
To ensure that the source is in mesh, I have written code like this:
%%% ensure source is in mesh %%%%%%%%%%%
cfg.increment = 0.01;
cfg.stretch = 0;
cfg.srcpos = source;
cfg.srcdir = source_unit_vec;
cfg.eid = tsearchn(cfg.node(:,1:3),cfg.elem(:,1:4),1:4));
while isnan(cfg.eid)
cfg.stretch = cfg.stretch + cfg.increment;
cfg.eid = tsearchn(cfg.node(:,1:3),cfg.elem(:,1:4),cfg.srcpos+cfg.stretch*cfg.srcdir);
end
cfg.srcpos = cfg.srcpos + cfg.stretch*cfg.srcdir;
I wonder how can I call the MATLAB function tsearchn in the cfg structure?


please follow our examples. you do not need to define cfg.eid, it will be computed automatically inside mmclab



Many thanks for your support!

Best regards,
Sunny


Qianqian Fang <q.f...@neu.edu> 于2024年7月29日周一 02:05写道:
Reply all
Reply to author
Forward
0 new messages