Skip to content

Commit

Permalink
feat: simulate photobleaching
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Mar 26, 2019
1 parent 83dc583 commit 47a5047
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- feat: new options for sinogram generation
- measurement duration (or specific times per angle)
- specify simulated imaging modalities
- simulate photobleaching
0.2.1
- ref: migrate to flimage
0.2.0
Expand Down
8 changes: 6 additions & 2 deletions cellsino/fluorescence.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

class Fluorescence(object):

def __init__(self, phantom, grid_size, pixel_size, displacement=(0, 0)):
def __init__(self, phantom, grid_size, pixel_size, displacement=(0, 0),
bleach_factor=1):
"""Fluorescence projector
Notes
Expand All @@ -23,6 +24,9 @@ def __init__(self, phantom, grid_size, pixel_size, displacement=(0, 0)):
self.center = np.array([gx, gy, 0]) / 2 - .5
self.center[0] += displacement[0]
self.center[1] += displacement[1]
#: bleaching factor (image is multiplied by this factor
#: to simulate photobleaching)
self.bleach_factor = bleach_factor

def project(self):
fluor = np.zeros(self.grid_size, dtype=float)
Expand All @@ -31,7 +35,7 @@ def project(self):
fluor += self.project_sphere(element)

flifull = flimage.FLImage(
data=fluor,
data=fluor * self.bleach_factor,
meta_data={
"pixel size": self.pixel_size,
}
Expand Down
10 changes: 7 additions & 3 deletions cellsino/sinogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, phantom, wavelength, pixel_size, grid_size):

def compute(self, angles, axis_roll=0, displacements=None,
times=3.0, mode=["field", "fluorescence"], propagator="rytov",
path=None, count=None, max_count=None):
bleach_decay=0, path=None, count=None, max_count=None):
"""Compute sinogram data
Parameters
Expand All @@ -30,7 +30,7 @@ def compute(self, angles, axis_roll=0, displacements=None,
of the rotation. If an int, defines the number of angles
of a steady rotation from 0 to 2π.
axis_roll: float
In-plane rotation of the rotational axis [rad].
In-plane rotation of the rotational axis [rad]
displacements: 2d ndarray of shape (N, 2) or float
A float value indicates the standard deviation of a
Gaussian noise distribution (using
Expand All @@ -46,6 +46,8 @@ def compute(self, angles, axis_roll=0, displacements=None,
propagator: str
The propagator to use for field computation. Must be in
:data:`cellsino.propagators.available`.
bleach_decay: float
Photobleaching decay constant [1/s]
path: str or pathlib.Path
If not None, the data will be written to this file and
a :class:`pathlib.Path` object will be returned.
Expand Down Expand Up @@ -114,10 +116,12 @@ def compute(self, angles, axis_roll=0, displacements=None,
qpi = pp.propagate()
qpi["time"] = times[ii]
if do_fls: # Fluorescence
bleach_factor = np.exp(-bleach_decay*times[ii])
fli = Fluorescence(phantom=ph,
grid_size=self.grid_size,
pixel_size=self.pixel_size,
displacement=displacements[ii]
displacement=displacements[ii],
bleach_factor=bleach_factor,
).project()
fli["time"] = times[ii]

Expand Down

0 comments on commit 47a5047

Please sign in to comment.