buffer error in MCXLABCL

104 views
Skip to first unread message

Alex Antrobus

unread,
Mar 30, 2021, 12:09:20 PM3/30/21
to mcx-users
Dear Dr Fang & The community

I'm new to MCX(cl) and am learning a lot!

I am trying to run a version of the below code in MCXLABCL. The initial simulation runs fine, but I have an error when I try to run the replay. I assume it's because I'm not detecting any photons (?!)
But then why is that?!

I'm running on my inbuilt Intel(R) Iris(R) Plus GPU, so nothing fancy.
Thanks in advance :-)

- Alex

------------ CODE USED--------------------
clear all;
clear cfg;

%% Define simulation parameters
% set seed to make the simulation repeatible
cfg.seed=hex2dec('623F9A9E'); 
% Volume model being used.
VOLUME='brain';

cfg.nphoton=1e8;

load colin27_v3.mat
cfg.vol=colin27;
cfg.prop=[  0         0         1.0000    1.0000 % background/air
        0.0190    7.8182    0.8900    1.3700 % scalp
        0.0190    7.8182    0.8900    1.3700 % skull
        0.0040    0.0090    0.8900    1.3700 % csf
        0.0200    9.0000    0.8900    1.3700 % gray matters
        0.0800   40.9000    0.8400    1.3700 % white matters
             0         0    1.0000    1.0000]; % air pockets
cfg.srcpos=[75 14 73]; %Source position
cfg.detpos=[75 18 92 5]; %Detector Position

% time-domain simulation parameters
cfg.tstart=0;% Start
cfg.tend=5e-9;% Stop
cfg.tstep=2e-10;% timestep

cfg.srcdir=[0.0 1.0 0.0, 5.0];% define the source DIRECTION
cfg.issrcfrom0 = 0; % Defines the location of the origin: 0 or 1 (0 here).
cfg.isreflect=1; % enable reflection at exterior boundary
cfg.isrefint=1;  % enable reflection at interior boundary too

%% Define OUTPUT settings 
cfg.issavedet=1; % Record partial pathlength of detected photons
cfg.ismomentum=1; % Save photon momentums
cfg.issaveref=1; % Save diffuse reflectance at air voxels.
cfg.issaveexit=1; % Save photon exit postitions & directions.
cfg.replaydet=-1; % Replay photons from all detectors.
cfg.issaveseed=1;

%% GPU thread configuration
cfg.autopilot=1;% Let MCX decide how many threads are important
cfg.gpuid=1;% 

%% Run Simulation
fprintf('running simulation ...\n');
tic;
%[f2,det2]=mcxlabcl(cfg);
[fluence,detphoton,vol,seed,trajectory] = mcxlabcl(cfg);
toc;

% Everything above here runs fine. The next section throws the "Invalid
% Buffer" error

%% Replay detected photons

newcfg=cfg;
newcfg.seed=seed.data;
newcfg.outputtype='jacobian';
newcfg.detphotons=detphoton.data;
newcfg.replaydet=1;
[flux2, detp2, vol2, seeds2, traj2]=mcxlabcl(newcfg);
jac=sum(flux2.data,4); 

-------------- ERROR MESSAGE --------------------

MCXCL ERROR(61):Invalid buffer size in unit mcx_host.cpp:497
MCXLAB ERROR 61 in unit mcx_host.cpp:497: Invalid buffer size
Error from thread (0): Invalid buffer size
Error using mcxcl
MCXLAB Terminated due to an exception!

Error in mcxlabcl (line 391)
    [varargout{1:max(1,nargout)}]=mcxcl(varargin{1});

Error in colin27_mwe (line 66)
[flux2, detp2, vol2, seeds2, traj2]=mcxlabcl(newcfg);

Qianqian Fang

unread,
Apr 6, 2021, 3:18:42 PM4/6/21
to mcx-...@googlegroups.com, Alex Antrobus
On 3/30/21 11:41 AM, Alex Antrobus wrote:
Dear Dr Fang & The community

I'm new to MCX(cl) and am learning a lot!

I am trying to run a version of the below code in MCXLABCL. The initial simulation runs fine, but I have an error when I try to run the replay. I assume it's because I'm not detecting any photons (?!)
But then why is that?!


hi Alex,

I ran your below script, the issue that you got the invalid buffer error was because your initial (i.e. baseline) simulation returns 0 detected photon, therefore, nothing to be replayed.

the reason that you did not get any detected photon was because your detector-sphere has no intersection with the outer boundary of the non-zero voxels - the only place where photon detection happens. please see my mcxpreview(cfg) screenshot attached. notice the detector sphere (green, at the occipital region) is fully buried under the skin.

for more information about how mcx detector works, please check out the below links

https://github.com/fangq/mcx/issues/102

http://mcx.space/wiki/index.cgi?Doc/FAQ#My_simulation_created_an_empty_history_file_why_is_that

http://groups.google.com/group/mcx-users/browse_thread/thread/e5e0140d7e73e4bf?hl=en


Qianqian


--
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/3a05e6eb-a4b9-4721-8d4b-3229ac733704n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages