Issue on running MCX

11 views
Skip to first unread message

Q W

unread,
Apr 14, 2026, 12:15:36 PM (10 days ago) Apr 14
to mcx-...@googlegroups.com
Dear Professor Fang,

I hope you are doing well.
 I am currently working on diffuse correlation spectroscopy (DCS)and running simulations using MMC. I have adjusted the MATLAB script several times, but it still fails. For example, 

%% **************************** Quan Adding**************
% MMC executable full path
mmc_exe = fullfile(mmc_path, 'bin', 'mmc.exe');
% JSON file full path (the one just written)
json_file = [scatterBrains_path filesep 'Subject' subject_num filesep 'example.json'];
% Check that mmc.exe exists
if ~exist(mmc_exe, 'file')
error('MMC executable not found: %s', mmc_exe);
end
% Check that example.json exists
if ~exist(json_file, 'file')
error('JSON file not found: %s', json_file);
end
% Build command (use double quotes for paths with spaces)
cmd = sprintf('"%s" -f "%s" -n 1e8 -D P -b 1 -d 1 --saveref 1 --momentum 1', mmc_exe, json_file);
fprintf('Running MMC:\n%s\n', cmd);
% Execute MMC
[status, result] = system(cmd);
if status ~= 0
error('MMC failed with status %d:\n%s', status, result);
else
fprintf('MMC completed successfully.\n');
disp(result);
End

It always gives me a Error:

Error using example
MMC failed with status 1:
Mesh error: can not open node file in unit mmc_mesh.c line#447

Do you have any suggestions for this?
Looking forward to your reply.

Best,
Quan



Qianqian Fang

unread,
Apr 14, 2026, 2:49:48 PM (10 days ago) Apr 14
to mcx-...@googlegroups.com, Q W

hi Quan, the error message is quite clear - it could not find the mesh files. you must create those mesh files and pass on the filename stub (the ??? part of node_???.dat and elem_???.dat) to the input json file.

if you go to mmc/examples, all provided examples include externally stored node/elem data files. you should follow those examples if you have to use mmc.

however, since you use matlab, I strongly encourage you using mmclab instead of mmc - mmclab directly passes on matlab arrays/structs to mmc and saves all the overheads of reading/writing data files - file IO is the slowest part of modern computers.

--
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 visit https://groups.google.com/d/msgid/mcx-users/CAOvA73QZ%2BVxcAtzF%2BAS2Zz87XYYCciK0CZXHOQpQa_5HJQh2mA%40mail.gmail.com.

Q W

unread,
Apr 15, 2026, 12:20:40 PM (9 days ago) Apr 15
to Qianqian Fang, mcx-...@googlegroups.com
Thanks, Professor Fang,

I found an example that loads Colin27. In my application, I will be loading my own target head model. So, do I just need to load the Subject03_volume.mat file then ignore the XXmesh.mat and XXXloc.mat? 

image.png

Another question: in the following example, I am curious about how you can define the srcpos so precisely, e.g., 67.38, 167.5?

Also, for the detpos, what does the '3' mean?

In my application, for example, I only know that the source-detector separations are 10, 25, and 30 mm. I cannot just do simple math calculation for the detector position like in the layered head model.

%%
cfg.tstart = 0;
cfg.tend = 5e-09;
cfg.tstep = 2e-10;
cfg.srcpos = [75 67.38 167.5];
cfg.srcdir = [0.1636 0.4569 -0.8743];
cfg.srcdir = cfg.srcdir / norm(cfg.srcdir);
cfg.detpos = [75.0000 77.1900 170.3000 3.0000
75.0000 89.0000 171.6000 3.0000
75.0000 97.6700 172.4000 3.0000
75.0000 102.4000 172.0000 3.0000];



Best,
Looking forward to your reply

Quan

Qianqian Fang <q.f...@neu.edu> 于2026年4月15日周三 02:49写道:
Reply all
Reply to author
Forward
0 new messages