jonbramble / RScattnlay

An R wrapper to the scattnlay program
1 stars 1 forks source link

return scattering parameters? #1

Open rogerswt opened 6 years ago

rogerswt commented 6 years ago

Hi Jon,

First, profuse thanks for writing RScattnlay! I'm an R guy, and have written an R wrapper for bhmie, but now need to do multi-layer particles, and your code seems to be the class act.

I'm dealing with polarized incident light, so need to account for polarization effects on the scattered signal. To do that I need to calculate S11 and S12. Would it be possible for you to return the complex vectors S1 and S2 for that purpose?

Many thanks in advance, Wade

jonbramble commented 6 years ago

Hi Wade,

Thanks for the kind words, I think you might be the only other person to use my code.

Looking at the wrapper code I wrote, I didn't need the scattering parameters at the time so I missed them out when the RCpp numeric vector is created.
It should be possible to do but I will have to check how the complex types can be returned together. I'll have a look shortly and post back here.

Cheers,

Jonathan

jonbramble commented 6 years ago

This turned out to be a bit more complex but I have added a 'ampl' branch with and amplitudes function on the R side which returns a data frame with the complex S1 and S2 values over a range of nt values. See the test.R file. It needs more testing to ensure that it is producing sensible values but it is getting there.

rogerswt commented 6 years ago

Hi Jonathan,

Checking it out now. Sorry for the slow turn. Will let you know how it goes.

Thank you!!! Wade

rogerswt commented 6 years ago

Jonathan,

This is perfect. I haven't carefully tested for numerical accuracy, but when I do I will confirm with you.

Just to let you know what I'm up to, I work with extracellular vesicles using flow cytometry as the detection platform. I am interested in carefully modeling the flow cytometer's response to small particles, including artificial reference materials (polystyrene and silica beads) and EVs. Ultimately I'm thinking of writing a flow cytometry-centric bioconductor package to facilitate accurate modeling. In keeping with other bioconductor packages for flow (flowCore, flowStats, flowFP, etc), thinking of calling it flowMie (of course, with appropriate pronunciation emphasis ;>)). Would love to leverage your RScattnlay with your permission and/or authorship.

All the best, Wade

rogerswt commented 6 years ago

I compared RScattnlay vs bhmie_fortran. I used a single-layer particle of radius 60 nm with real refractive index of 1.45, in water (n = 1.34), with 488nm light. I compared the scattering matrix elements S11, Pol = -S12 / S11, S33 and S34. The agreement was excellent, generally out to 6-7 significant digits. The error is apparently random and gaussian distributed. Nice work.

jonbramble commented 6 years ago

That sounds great. I didn't have any other programs to compare it to at the moment.
I was hoping to include the sum of the S1 and S2 on the C++ end but I ran into problems with the RCpp wrap function and haven't managed to fix it up yet.

With regards to your proposed package, would you want to include the code directly or have it as a dependency? I don't have much experience with getting packages on CRAN, I read that it would need to be tested on windows which I don't have access to in the short term.

In general I would like to keep the wrapper going separately on here as I will reference it in a paper shortly but I think you would be able to include it in your package too. Let me know if I can contribute :)

I will be travelling for the next week to the UK so might not be online that much.

Cheers, Jon

rogerswt commented 5 years ago

Hi Jon, Sorry for the VERY slow turn. Have you submitted your manuscript?

I've been away from this project (left previous company and busy with a plethora of distractions). My new direct email is wade.rogers@spcytomics.com. Would love to pick back up on discussion of a bioconductor package. Feel free to email me directly.

Cheers, and happy new year, Wade