Definition of the classes used to model the camera noise
%load_ext autoreload
%autoreload 2

class sCMOS[source]

sCMOS(theta:float=3.0, baseline:float=0.01) :: Module

Generates sCMOS noise distribution.
Generates sCMOS noise distribution which can be used for sampling and
calculating log probabilites.

Args:
    theta (float): Paramter for gamma distribution
    background (float): background value
    baseline (float): basline

Shape:
    -Input: x_sim: (BS, C, H, W, D)

    -Output: Gamma(concentration: (BS, C, H, W, D), rate:
    (BS, C, H, W, D))
from decode_fish.engine.psf import LinearInterpolatedPSF
from decode_fish.engine.point_process import PointProcessUniform
from decode_fish.engine.microscope import Microscope
from decode_fish.funcs.plotting import plot_3d_projections
from decode_fish.funcs.file_io import get_gaussian_psf

psf = get_gaussian_psf([21,21,21],[1.,1.,1.])
noise = sCMOS(theta=5., baseline=0)

micro = Microscope(parametric_psf=[psf], noise=noise, scale=1000).cuda()

point_process = PointProcessUniform(local_rate = torch.ones([1,1,48,48,48]).cuda()*.0001)
locs_3d, x_os_3d, y_os_3d, z_os_3d, ints_3d, output_shape = point_process.sample()

xsim = micro(locs_3d, x_os_3d, y_os_3d, z_os_3d, ints_3d, output_shape)

background = torch.ones_like(xsim) * 500
xsim_noise = micro.noise(xsim, background).sample()
_ = plot_3d_projections(xsim_noise, size=3)
from decode_fish.funcs.dataset import EstimateBackground
# img = load_tiff_image('/groups/turaga/home/speisera/Mackebox/Artur/WorkDB/deepstorm//datasets/CodFish/smFISH_data_Titlow/msp300_smFISH_3.tif')
img = xsim_noise.cpu()
estimate_bg = EstimateBackground(smoothing_filter_size=5)
bg = estimate_bg(img)

estimate_noise_scale[source]

estimate_noise_scale(img, bg_est, percentile=99, plot=True)

estimate_noise_scale(img, bg, 99)
4.800549444184133
!nbdev_build_lib
Converted 00_models.ipynb.
Converted 01_psf.ipynb.
Converted 02_microscope.ipynb.
Converted 03_noise.ipynb.
Converted 04_pointsource.ipynb.
Converted 05_gmm_loss.ipynb.
Converted 06_plotting.ipynb.
Converted 07_file_io.ipynb.
Converted 08_dataset.ipynb.
Converted 09_output_trafo.ipynb.
Converted 10_evaluation.ipynb.
Converted 11_emitter_io.ipynb.
Converted 12_utils.ipynb.
Converted 13_train.ipynb.
Converted 15_fit_psf.ipynb.
Converted 16_visualization.ipynb.
Converted 17_eval_routines.ipynb.
Converted 18_predict_funcs.ipynb.
Converted index.ipynb.