InverseLight / ValoMC

Monte Carlo software for simulating light propagation
https://inverselight.github.io/ValoMC/
Other
43 stars 14 forks source link

including internal light sources #21

Open swathimurthy9 opened 2 years ago

swathimurthy9 commented 2 years ago

Hello,

I have been using ValoMC for light simulation in biofilms. We recently published a paper using the tool: https://doi.org/10.1098/rsif.2021.0532

We would like to use the tool for another project to simulate auto-fluorescence in biofilms. For this we like to include internal isotropic light sources in certain domains in the geometry. Could you point out how this can be achieved? Or the possibility for building this together?

Bw Swathi

aaleino commented 2 years ago

Hi! Would you like to have a point-like source in the domain (all photons emitted from the same location to random angles) or a volumetric source (also the locations are random)? In 2D or 3D? Br, Aleksi

swathimurthy9 commented 2 years ago

Thanks for your response. I would like to have a volumetric source in 3D. Where the photons (isotropic) are generated from all the mesh elements in a given domain.

aaleino commented 2 years ago

I have drafted such light sources in the git branch "volumetric_lights". But I haven't tested it. I think next step would be to build some scenario that has an analytical solution, and compare the results of the code to the solution. Otherwise, it is very risky to use the code.

To test the code, you need to run compile_vmc_mex and examples/volumetric_light_test.m

To checkout the branch, you can use "git checkout volumetric_lights"

swathimurthy9 commented 2 years ago

Thank you for including the volumetric light source. I tried to run the code on a 3D geometry consisting of a fluorescent slab surrounded by a non-fuoroscent box, for 3 scenarios:

  1. no fluorescence
  2. 10% fluorescence efficiency
  3. 60% fluorescence efficiency

I have attached the results, normalized to the fluence rate of the exciting light source, as a screen shot here. The results look a bit confusing. At 10% efficiency , the fluence in the surrounding box is close to 1, where as at 60% efficiency it is 0.4. Does the solution.element_fluence include both the excitation light (distribution) and the flourescence? Is it possible to plot only the flourescence?

screen_shot

swathimurthy9 commented 2 years ago

The fluorescent slab is also scattering.

aaleino commented 2 years ago

Hi, sorry for the late response. The field "volumetric_light_source_fraction" is not the efficiency of the fluorescence, but simply the fraction of all photons that will be sent from the volumetric light source. So if you want the contribution of only the volumetric light, set "volumetric_light_source_fraction" to one. Then the internal light source will have the power of one unit. If volumetric_light_source_fraction is something else than one, the summed power of internal and boundary light sources will be one unit.

To get the total result with boundary and volumetric light, you could run another simulation with only the boundary lights on "volumetric_light_source_fraction" zero, and add the results together with a suitable normalization. E.g. volumetric light is 6 times stronger than boundary lights, multiply volumetric results by 6.

So this new addition was simply adding volumetric lights, and not a direct simulation of auto-fluorescence.

If you want absorbed photons (that originated from the boundary) to have some efficiency to get converted to fluorescence photons, that's a more difficult problem, and I have to think about that. That is, a "direct" physical simulation of auto-fluorescence. Is that what you need?

swathimurthy9 commented 2 years ago

Thank you for the reply. Yes, I would like to simulate auto-fluorescence, as consequence of excitation light (originating from the boundary and scattered in the medium) being converted at a certain efficiency. On the lines described here: https://omlc.org/software/mc/ https://omlc.org/software/mc/mcfluor/index.html

Would that be possible to implement in ValoMC?

aaleino commented 2 years ago

At the moment I do not have the time to do literature search, but if you can describe the mathematics and workings of such algorithm here briefly we can see what can be done (unfortunately, without any guarantee of the timetable). How is the efficiency defined? Out of the absorbed photons, certain fraction turn to fluorescence photons?

swathimurthy9 commented 2 years ago

Yes, efficiency is defined as a certain fraction of the excitation light converted by fluorescence. MC_fluor_equations.pdf I have attached the general description of the algorithm and the equations here. Please let me know if you need any further details. Thank you very much.

swathimurthy9 commented 1 year ago

Hello Aleksi Leino,

Was the above attached document descriptive enough? Would you need any further explanation or the c-code for the programs?

Cheers Swathi

aaleino commented 1 year ago

The document was a bit abstract and I got bogged down in details when reading. To put very simply how I imagine this kind of simulation would work: in addition to absorption coefficient, we could define "fluorescence absorption coefficient". This is the probability per unit length that a fluorescence occurs as the photon propagates. If fluorescence occurs, the photon will be re-emitted to (uniformly) random direction. Is that correct? EDIT: in addition, not instead of. How the weighting would work can be probably worked out by my colleague, but I need to know what kind interactions would the photon have in a simple simulation without weighting.

swathimurthy9 commented 1 year ago

Thank you for the quick reply. I will try to explain here.

Let's consider that the geometry has 2 domains and the fluorescence occurs in only domain 1 from a uniform distribution of background fluorophore. There are 2 parts for the simulation:

MonteCarlo simulation of excitation light, using the optical properties of excitation wavelength. This gives a fluence rate distribution in both the domains. Followed by MonteCarlo simulation of auto-fluorescence in domain 1 only, using the optical properties for fluorescence wavelength. Considering the fluorophores as internal, isotropic, light sources generated due to the excitation light. The auto-fluorescence generation in each mesh element in Domain 1 depends on: a. The fluence rate of the excitation light at the given location (mesh element). b. We can use a lumped factor which implies amount of the excitation light converted to fluorescent light (fluorescence yield). Example: excitation fluence rate at a given location is 1 W/cm^2 per W of incident light and the lumped factor is 0.1. Then the intensity of the fluorescent source at that location is 0.1 W/cm^2 per W of incident light.

All the fluorescent light generated in domain 1 undergoes scattering and absorption depending on the optical properties defined for that wavelength (MC simulation). This finally gives a distribution of fluorescent light intensity in the geometry.

Please let me know if something is unclear.

Cheers Swathi

aaleino commented 1 year ago

Just a status update: I haven't forgotten about this. I am just too busy at the moment to work on this!

swathimurthy9 commented 1 year ago

Thank you for the update. I look forward to hearing from you about this.

Cheers Swathi

swathimurthy9 commented 1 year ago

Hello Aleksi Leino,

I was thinking of how to implement auto-fluorescence from the existing code you have already made for Volumetric light sources, Instead of assuming all the internal elements are generating photons uniformly (of the same intensity), we use the element_fluence from the solution for the excitation source and multiply this with 'fluorescence absorption co-efficient', which will give the intensity of the volumetric source as W/m^2/W of incident light (which was the initial boundary source). Is this difficult to implement?

Cheers Swathi

aaleino commented 1 year ago

Hello, What you described in previous messages is possible to implement. You could already do this with the existing code by forming the second solution from a sum of several simulations in which elements were individually lighted up (assuming the code for the volumetric light works - it should be tested).

I can start working on wrapping up a package for doing this in two simulations, but as I can work on this only very inconsistently and seldomly, it will take a while.

So I assume the fluorescent light does not cause any more fluorescence? In other words, if we used the fluorescence wavelength in the "external light source", no fluorescence would occur? Otherwise, the system will not work.

swathimurthy9 commented 1 year ago

Thanks for the reply. It's great to hear that it is possible to implement this with the existing code. Yes, we can assume that the fluorescent light does not cause any more fluorescence.

I understand that you are busy and do not get much time to work on this. Thank you for your time. I look forward to the auto-fluorescence package.

Cheers Swathi