pmcx and pattern sources

188 views
Skip to first unread message

V Zoutenbier

unread,
Nov 1, 2023, 12:34:47 PM11/1/23
to mcx-users
Hello!

I am trying to create a sinusoidal illumination pattern on a rectangular volume, but am running into an interesting issue in pmcx.  When I analyze the output photons, it appears that they are from a planar source- although the flux shows that a patterned source was simulated.  

First I show that I can run a simulation and what my outputs look like.  On the left you see the flux from illumination with a gaussian beam.  This simulation has a bc_planes detector along the top (z=0) plane. On the right, you see a binned intensity image of a histogram of photons that were detected from the volume detp.x[:].   
Slide1.JPG

For a gaussian beam, we see the beam scatter in depth, and see a broader beam at the surface than in the volume.  Great!

I can repeat this for a planar source:
Slide2.JPG
This also looks like it makes sense.  
7.29e6 photons are detected of 1e7, with no absorbers this seems reasonable. 

The issue comes when I try to use an input pattern image.  Below I put in a sine wave which is constant along Y and varies slowly along X, as can be seen in the flux image and the replay simulation.  

Slide3.JPG
However, when I look at the detp photons returned from the simulation, I see basically the same results as if it were a planar souce.  Again, I see 7.29e6 detected photons, and more critically no pattern in the binned image (or its cross sectional profile). 

I've tried many things in troubleshooting it.  

- Both bc_planes and a discretely placed detector show this issue
- Other patterns show this issue
- Other volume sizes show this issue
- The energy plot does show the input pattern through the volume, but also does not give the proper detp out.  
- Placing a mirror on the  bottom of the volume with negligible scattering and absorption does not show the pattern on the detector plane. 
- Adding some absorption does localize the areas with light flux, but still shows photons in regions with no flux below it.  
- I've tried switching to Shapes input volume description, 
.... others that I'm forgetting now. 

Do you have any advice on what to troubleshoot next, or can you see if this is a bug? 

here I paste my cfg, without the patterned image, from a jdata.savet command.  For the full cfg you can use the link:
(sorry, only available for 21 days)
 
Any help appreciated

Vincent


{
        "dim": [
            961,
            961,
            213
        ],
        "prop": {
            "_ArrayType_": "double",
            "_ArraySize_": [
                2,
                4
            ],
            "_ArrayData_": [
                0.0,
                0.0,
                1.0,
                1.38,
                1.0,
                1.3583032455451094,
                0.6,
                1.42
            ]
        },
        "issrcfrom0": 0,
        "unitinmm": 0.0468,
        "tstart": 0,
        "tend": 5e-09,
        "tstep": 5e-09,
        "srctype": "pattern",
        "srcpos": [
            224.5,
            160.5,
            0
        ],
        "srcdir": [
            0,
            0,
            1,
            0
        ],
        "srcparam1": [
            512,
            0,
            0,
            512
        ],
        "srcparam2": [
            0,
            640,
            0,
            640
        ],
        "srcpattern": {
            "_ArrayType_": "double",
            "_ArraySize_": [
                512,
                640
            ],
            "_ArrayData_": []
        },
        "nphoton": 10000000.0,
        "isreflect": 1,
        "bc": "______001000",
        "isnormalize": 1,
        "seed": -1,
        "maxdetphoton": 10000000.0,
        "autopilot": 1,
        "outputtype": "flux",
        "savedetflag": "pxv",
        "debuglevel": "P",
        "issavedet": 1,
        "issaveseed": 1,
        "verb": 2
    }

Qianqian Fang

unread,
Nov 1, 2023, 5:42:27 PM11/1/23
to mcx-...@googlegroups.com
hi Vincent,

for patterned sources, including Fourier patterns, mcx does not launch photons at the spatial density modulated by the pattern intensity, rather, it launches photons uniformly and use the pattern intensity as the initial weight.

that's why when you see the photon exit/position/trajectories, they are still uniform, because the pattern information is in the launched weight (detp.w0).

the independence of photon paths and the pattern values is also the key reason that enables our "photon-sharing" approach - where a single photon path can be used to simulate many patterns, see


hope this makes sense.

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/09aca37c-a6c3-499f-929e-882a06cdf87cn%40googlegroups.com.


Vincent

unread,
Nov 1, 2023, 7:45:35 PM11/1/23
to mcx-users
Hi Quanqian, 

Thanks for your quick response!  

This was definitely a thought that went through my head on how it was implemented.  I hadn't found this reference while trying to solve this.  I appreciate the link!

Have a good day

Vincent

Qianqian Fang

unread,
Nov 1, 2023, 11:05:10 PM11/1/23
to mcx-...@googlegroups.com, Vincent

just to add two more comments:

- if you have a single source pattern and the pattern contains zeros, mcx will not launch any photon in those 0-valued pixels

- to get the distributions you wanted, you should call mcx/utils/mcxdetweight.m to compute each detected weight (which considers detp.w0), then sum those over a 2D grid based on their exit positions (detp.p) to form your "virtual ccd image" - if you use MMC instead of MCX, this can be done in mmc by setting cfg.issaveexit=2, we call it "widefield detector", see https://github.com/fangq/mmc/blob/master/mmclab/example/demo_wide_det.m#L39

Reply all
Reply to author
Forward
0 new messages