Problem getting DECODE to work with an sCMOS camera (no EM gain) #71
-
Hi, I'm trying to train DECODE for acquired sequences from a microscope with sCMOS cameras rather than EMCCD.
When using this yaml file as input in the training Jupyter notebook, first I get an error at the step that makes:
The error being:
The "division by zero" suggested that DECODE had a problem with em_gain=0, so I replaced it by em_gain = 1 in the yaml file from SMAP:
Now it runs up to the comparison between the simulated frames and the experimental frames. However, the simulated frame show only noise and no visible blinking event using the parameters from the SMAP file, with an intensity span from 0-300 on the simulation vs 0-80 on the experimental frame: So there seem to be a problem here. I don't understand why I don't see any blinking event on the simulated frame with this yaml parameter file. If you want to reproduce using the yaml file above, I also attach the calibration file used: Thank you for your help! PS.
Indeed, the mean intensity of the simulation is 44.0, while the average intensity of the experimental frames as reported in the notebook is 157.0 before the camera.backward rescaling and 27.0 after the rescaling (which is consistent with [(157-baseline)/(e_per_adu•em_gain)], with the values from the yaml file above (baseline 100, e_per_adu 0.48, em_gain 1). As an aside I think "rescaled by the em_gain" in the notebook test is imprecise as it's rescaled by (e_per_adu•em_gain) if I understand correctly what happens. |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 9 replies
-
Hey @cleterrier, for no EM-Gain, it should be set to Camera:
baseline: 100.0
e_per_adu: 0.48
em_gain:
px_size: [97.0, 97.0]
read_sigma: 74.4
spur_noise: 0.002 I'll have a look at your calibration file. If you want to debug you can overwrite your camera in the notebook with # ...
camera = decode.simulation.camera.PerfectCamera(device='cpu') which will only result in shot noise. |
Beta Was this translation helpful? Give feedback.
-
I added the perfect camera in the training notebook, just before: and the result is the same pattern of pure shot noise. So I guess the Z calibration is the culprit. This is a spline calibration made by SMAP using a larger window (31x31 pixels) because there is a lot of astigmatism on this setup, so PF are extended. Here's the SMAP Matlab Figure corresponding to the calibration: and the corresponding Z stack tif (34 steps, 50 nm Z steps, 97 nm/pixel, 0.48 e-/ADU): |
Beta Was this translation helpful? Give feedback.
-
To me the PSF looks fine. |
Beta Was this translation helpful? Give feedback.
-
Thanks @Haydnspass! Seems that the problem is not in the calibration then? Can you try to execute the Training notebook with
I'd be interested to see if you get something that looks like pure noise also... You can see the experimental data doesn't have a high SNR, maybe the SMAP parameters inferred make it even worse, and it just looks like noise? Because with the above files, to me right now the comparison looks like this: |
Beta Was this translation helpful? Give feedback.
-
Just tried, it is just the low photon count. As soon as I used a factor of 10 for intensity_mu_sig the emitters became visible to the eye (so no bug). Where did you get the intensity and bg values from? From the SMAP plugin or by guess? |
Beta Was this translation helpful? Give feedback.
-
I still don't understand why the simulation just shows noise visually in the Training notebook though - 2500 ± 500 photons per blinking events on a 30-50 background should be already very visible, and these the the values SMAP determines from the experimental sequence (where events are visible). I've thought about it while not sleeping last night - can't see any issue with gain value as sCMOS gain very straightforward (only one value for e/ADU, and em gain equivalent to 1) - also camera gain should not influence the simulation as intensity is in photons in the Figure shown. Background definition issue? Those mysterious camera parameters (74.4 and 0.002)? I mean as an SMLM microscopist, having to manually add a 10X factor to the number of photons (to 25,000) suggests there's a problem somewhere, as it's far from a typical Alexa Fluor 647 value. One thing I can imagine is that as the astigmatism is large, the PSF is spread over a large number of pixels, so each pixel as a small fraction of the photon count (your PSF above at Z=0 has only 2.5% of the total photons - 0.025 to a normalized 1 total, would be even smaller away from the focal plane). But still the simulation should look like the experimental frames as it's derived from the SMAP estimates? I also thought maybe the background was a problem. But making the background from 0-50 to 1-2 does not change the result - a shot noise images with a span of around 250 photons from the intensity scale bar. What about camera baseline? Is it in photons or ADU for DECODE (as the simulation is in photons)? In SMAP it's in ADU (100 ADU) |
Beta Was this translation helpful? Give feedback.
-
No problem to post everything here. I posted the files necessary to run the training above (3Dcal.mat, yaml out of SMAP, extracted images for comparison). Here is the .sml.mat file from which the SMAP yaml file was generated (used fixed grouping at 97 nm to get the same yaml statistics as mine): Here is the tif sequence (768x768, 5K frames from a larger sequence) from which the localization .sml.mat file was calculated using SMAP (peak detection DoG 1.7, dynamic factor 1.3, window for detection 21 pixels, peak fitting Spline with 3dcal.mat above, window for fitting 21 pixels) Here is the cameras.mat file with the camera parameters used to process the sequence and obtain the sml.mat file (I find working with several cameras quite confusing, it keeps reverting to default, so I use a cameras.mat file with only one camera as default): (btw just to avoid misunderstanding, I use the edit function extensively in github to add precision and correct stuff on my messages so it's best to read here rather than using the email sent with the first "draft" version :) |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@cleterrier Another thing that popped into my mind: Since you were talking about using SCMOS, have you turned off |
Beta Was this translation helpful? Give feedback.
OK I made some progress!
The camera.read_sigma was fixed at 74.4 from the SMAP yaml file. Looking at the spec sheet from my sCMOS camera, this is the read noise profile:
So the readout noise is at 1.65 e- with a sigma of around 0.5 e-
If I put camera.read_sigma at 0.5, all other parameters equal, I get something much closer between simulation and experimental frame (keeping the 2500±500 values for blinking events given by SMAP):
I guess the 74.4 value is after EM gain for an EMCCD? Not sure what are camera.read_sigma and camera.spur_noise exactly, but it looks like sigma should be much lower than 74.4 for an EMCCD and that the SMAP parameter evaluation should reflect this difference