Definition of the classes used to model the camera noise
%load_ext autoreload
%autoreload 2
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(img, bg, 99)
!nbdev_build_lib