Boundary conditions for Infinite medium

184 views
Skip to first unread message

Vamshi Krishna

unread,
Feb 13, 2022, 9:05:25 AM2/13/22
to mcx-users
Dear All,

I am a beginner in MCX, so please excuse me if this doubt sounds very trivial. 

I am trying to model an infinite medium (experimentally, we had done this using a liquid phantom in a large volume and with the fibers placed about 5cm into the volume of the liquid). However, I have already read that in MCX we cannot place a detector in middle of the volume. Hence, I am trying to differentiate between INF and SEMI INF medium using the boundary conditions. I have a cube of 150mx150mm x150mm with detector at (75,75,0).
1) I tried putting the plane of the detector [-z = Cyclic], but it gives me 0 detected photons
2) Hence, I used following boundary conditions and got the corresponding number of detected photons - 
     INF:  [-z = Absorbing]: 216000 detected photons (approx avg for many seed values)
    SEMI INF: [-z = Fresnel reflecting]: 133000 detected photons (avg)

Intuitively, I was expecting the volume with the detector on a reflecting boundary to give us more detected photons. But I am unable to explain this. I have tried varying the BC for all the other boundaries (x,y and +z), but it doesnt make so much of a difference. Could anyone explain why this occurs, or am I doing something wrong? Thank you.

Yours sincerely,
Vamshi

Qianqian Fang

unread,
Feb 13, 2022, 12:21:55 PM2/13/22
to mcx-...@googlegroups.com, Vamshi Krishna
On 2/9/22 11:35, Vamshi Krishna wrote:
Dear All,

I am a beginner in MCX, so please excuse me if this doubt sounds very trivial. 

I am trying to model an infinite medium (experimentally, we had done this using a liquid phantom in a large volume and with the fibers placed about 5cm into the volume of the liquid). However, I have already read that in MCX we cannot place a detector in middle of the volume. Hence, I am trying to differentiate between INF and SEMI INF medium using the boundary conditions. I have a cube of 150mx150mm x150mm with detector at (75,75,0).


hi Vamshi

I want to make three comments:

1. you don't have to use detected photons to quantify light intensity inside a volume. you can use the volumetric fluence/fluence-rate output (first output of mcxlab) directly. each voxel in the fluence output represents the light intensity inside each voxel location. your fiber measurement is simply a mean for you to physically probe such quantity (with compromises, such as inserting the fiber into a volume and disturb the distribution), but mcx, as a simulator, can directly provide such information conveniently in a volume without compromise.


2. if you have to, you CAN effectively place a detector "inside" the medium, as long as you set a 1-voxel layer of zero-valued pixels next to it, for example

cfg.vol=uint8(ones(60,60,60));
[xi,yi]=meshgrid(1:60,1:60);
dist2=(xi-30).*(xi-30)+(yi-30).*(yi-30);
dist2=(dist2>25);
cfg.vol(:,:,30)=uint8(dist2);
cfg.detpos=[30,30,29.5,5];
mcxplotvol(cfg.vol)    % plot to see the volume

note this flat detector captures photons arriving on both top/bottom sides. if you want to only capture the bottom side, like a fiber, you can extrude the zero-voxel patch all the way to the top, like adding a hollow cylinder matching the diameter of the fiber.

this is an approximated solution because the zero-voxels have a shape mismatch those from the circular detector aperture, such as shown in this diagram

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


3. applying a cyclic bc not only effectively mirror the domain to an infinite slab, but also mirrors the source in the same direction. therefore, this approach gives you valid solution when you are trying to simulate an infinite plane source with an infinite layered medium, like in this example

https://github.com/fangq/mcx/blob/master/mcxlab/examples/demo_infinite_slab_cyclic_bc.m

but if you apply such bc for a pencil beam, the output solution is effectively a result from an infinite 2D grid of the pencil beams over an infinite slab.

if your goal is to simply expand the slab but not to duplicate your source in x/y, then cyclic bc is not a solution. In this case, my only suggestion is to simply increase the size of your domain - when your boundary is sufficiently far away from the source, then it should give you a good solution.

if you only care about detected photons (or total diffuse reflectance such as our recently added polarized photon modeling), then you can set cfg.unitinmm to a big number to simulate a large physical size to attenuate the boundary effect further.


1) I tried putting the plane of the detector [-z = Cyclic], but it gives me 0 detected photons
2) Hence, I used following boundary conditions and got the corresponding number of detected photons - 
     INF:  [-z = Absorbing]: 216000 detected photons (approx avg for many seed values)
    SEMI INF: [-z = Fresnel reflecting]: 133000 detected photons (avg)

Intuitively, I was expecting the volume with the detector on a reflecting boundary to give us more detected photons.


generally speaking, strongly reflection on the boundary results in higher fluence inside the domain, but lower number of detected photons. a total reflection bc will not allow you to detect any photon because all photons are bounced back and won't come out from the surface.


But I am unable to explain this. I have tried varying the BC for all the other boundaries (x,y and +z), but it doesnt make so much of a difference. Could anyone explain why this occurs, or am I doing something wrong? Thank you.


I don't know exactly which dimensions you want to extend your domain, but try increasing the gird size in those directions, at some point, the result will not change as you further increase the domain size. for diffusive media, a few cm from the boundary should be sufficient.

Qianqian



Yours sincerely,
Vamshi
--
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/d2dca8c2-599a-4dec-bc5f-5f4bbf300813n%40googlegroups.com.

Vamshi Krishna

unread,
Mar 17, 2022, 12:02:01 PM3/17/22
to mcx-users
Respected Dr. Fang,

Firstly, I would like to apologise for this late reply to your response. I had for some reason not received your reply directly in my mail, and hence, I was trying to figure it out on my own. However, I should have checked more thoroughly and I realise this was unprofessional on my part and I apologise for this. 

I had tried out on my own various combinations and having read other threads figured out how to 'mimic' an infinite medium (large volume), and  with a fiber placed inside (using a zero voxel volume around the detector). Consequently, I tried to 'recover' the Mua values and we were able to get satisfactory results, but not as good as I would normally expect from a simulation (ideal case). As you had suggested, for an INF medium, I realised  the best way is to use the Fluence output and I have done it using MATLAB. However, I was wondering if there is documentation available to read/load the nii files into PYTHON rather than MATLAB? Thank you for your time.

Yours sincerely,
Vamshi

Qianqian Fang

unread,
Mar 17, 2022, 12:59:39 PM3/17/22
to mcx-...@googlegroups.com, Vamshi Krishna

to read mcx output in Python, the simplest way is to add -F jnii to save the data in the JSON/JNIfTI format, more instructions can be found here

https://github.com/fangq/mcx#jnii-files

you can also use -F bnii to export in binary JSON format, and please check out this thread for how to read it using the latest version of jdata/bjdata module

https://groups.google.com/g/mcx-users/c/c9mPMjd0RQw/m/N2vrKEzDAwAJ

Qianqian

Vamshi Krishna

unread,
Mar 18, 2022, 7:07:33 AM3/18/22
to mcx-users
Respected Dr. Fang,

Thank you for your quick response. I will try out the methods suggested by you.

Yours sincerely,
Vamshi

Reply all
Reply to author
Forward
0 new messages