aherbert / gdsc-smlm

GDSC Single Molecule Light Microscopy ImageJ Plugins
GNU General Public License v3.0
15 stars 4 forks source link

Question about sCMOS gain #12

Open Z-Qing opened 1 year ago

Z-Qing commented 1 year ago

Hi, Injust had a test run using the sCMOS analysis. In the histgoram of gain, I have 216298 pixel at 16.9, 1 pixel at 299, and 1 pixel at 1756. But in the log file, it shows Gain Mean = 2.217 +/- 3.801 Could you explain how 'Gain Mean' is calculated? Why the Mean gain isn't round 16.9? Thanks for your help.

aherbert commented 1 year ago

Hi, it seems to me that you may have an issue with some of the pixels on your sCMOS chip.

The mean and standard deviation that is reported is correct. This is computed using the standard formulas given the individual gain values. The histogram is a grouping of the data to the show frequency within a range. Thus you have 216298 pixels with a value between 0 and 16.9. This is almost all of your data. Note that the histogram is just plotting a bar over the entire interval. The data within this range may not be uniformly spread so the single bar is misleading.

The histogram is computing the number of bins and then counting data in the bins. The number of bins is using the Sturge's rule:

ceil(1 + log2(n))

This is then doubled. It seems rather arbitrary but it worked OK on my data. But it does not work with heavily skewed data. Note that the number of bins is uniformly used to cover the range from the minimum to the maximum. So if you have some outliers (heavily skewed data) then the number of bins will be too small. Your single pixels at 299 and 1756 are outliers since the mean gain is around 2.2. So you may have an issue with "hot" pixels on your CMOS chip (which are close to saturation most of the time).

You should have as one of the outputs a stack image of the offset, variance and gain. You can find the gain image and identify the hot pixels (e.g. just use the contrast and set the minimum above 17). Then look at the corresponding variance and see if the same pixels have low variance. Also check the input images and see if those pixels are always very bright or saturated.

If you do have hot pixels then there are a few options:

  1. If the pixels are conveniently located then you may be able to perform imaging using a crop that does not include the bad pixels.

  2. Map them out using an average of the surrounding pixels. You will then have to repeat the sCMOS analysis on your mapped out image. Some cameras can be configured to map out "hot" pixels at the hardware level which would replace it with some averaging of the surrounding pixels. Perhaps your camera has this functionality.

  3. Use the sCMOS camera model as is. When fitting an image the same pixels will have their value scaled down by this extremely high gain value. If this normalisation works then these bright pixels will be reduced to the same intensity as their neighbours and so will no longer be local maxima. This will prevent the program fitting a spot at that position on every image. The effect on fitting will depend also on the variance of the pixel when it contributes to the PSF region of a spot.

You can see the camera model and apply filtering to an image using the model (i.e. subtract the bias and divide by the gain) with the 'Camera Model Manager' plugin.

Note that we never encountered such pixels in our sCMOS camera and so the SMLM code does not have special handling to ignore these pixels. If your camera is under warranty then you could report it to the manufacturer and it may be fixable.