See also

This page was generated from examples/bleaching.ipynb.

Download the Jupyter Notebook for this section: bleaching.ipynb. View in nbviewer.

https://colab.research.google.com/assets/colab-badge.svg https://mybinder.org/badge_logo.svg

Photo bleachingΒΆ

This is an example to test the effect of photo bleaching.

[1]:
import scopyon

Enable photo bleaching and set the half life of fluorophore.

[2]:
config = scopyon.DefaultConfiguration()
config.update("""
default:
    magnification: 360
    detector:
        exposure_time: 0.033
    effects:
        photo_bleaching:
            switch: true
            half_life: 2.5
""")
[3]:
pixel_length = config.default.detector.pixel_length / config.default.magnification
L_2 = config.default.detector.image_size[0] * pixel_length * 0.5

Set the number of processes to enable multiprocessing:

[4]:
config.environ.processes = 20

Generate input data.

[5]:
import numpy
rng = numpy.random.RandomState(123)
num_frames = 30
N = 1000
D = 0.1e-12  # m ** 2 / s
dt = config.default.detector.exposure_time
t = numpy.arange(0, (num_frames + 1) * dt, dt)
inputs = scopyon.sample_inputs(t, N=N, lower=-L_2, upper=+L_2, ndim=2, D=D, rng=rng)

Form images.

[6]:
imgs = list(scopyon.generate_images(inputs, num_frames=num_frames, config=config, rng=rng))

Create a video (matplotlib and ffmpeg are required).

[7]:
scopyon.Video.save('video.mp4', imgs)
[8]:
from IPython.display import Video
Video("video.mp4", embed=True)
[8]:

Plot the total intensity of images.

[9]:
import plotly.express as px
px.line(x=numpy.arange(len(imgs)) * config.default.detector.exposure_time, y=[img.as_array().sum() for img in imgs])