Skip to content

Commit

Permalink
ref: allow to manually set frame times
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Mar 22, 2019
1 parent 9d58a6d commit 728ac24
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
0.3.0
- feat: allow to define a measurement duration when generating sinograms
- feat: allow to specify a measurement duration or the frame times
when generating sinograms
0.2.1
- ref: migrate to flimage
0.2.0
Expand Down
18 changes: 9 additions & 9 deletions cellsino/sinogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, phantom, wavelength, pixel_size, grid_size):
self.grid_size = grid_size

def compute(self, angles, axis_roll=0, displacements=None,
duration=3.0, propagator="rytov",
times=3.0, propagator="rytov",
path=None, count=None, max_count=None):
"""Compute sinogram data
Expand All @@ -39,10 +39,9 @@ def compute(self, angles, axis_roll=0, displacements=None,
:func:`numpy.random.normal`) in pixels.
A 2d array directly specifies the x-y-displacement for each
frame in pixels.
duration: float
Measurement time of the full sinogram [s]. The frame rate is
always constant. Use the `angles` argument to simulate
varying rotation speeds.
times: 1d ndarray of size N or float
If an array, sets the measurement time of each frame
of the rotation. If a float, defines the measurement duration.
propagator: str
The propagator to use. Must be in
:data:`cellsino.propagators.available`.
Expand All @@ -62,6 +61,9 @@ def compute(self, angles, axis_roll=0, displacements=None,
if isinstance(angles, int):
angles = np.linspace(0, 2*np.pi, angles, endpoint=False)

if isinstance(times, (int, float)):
times = np.linspace(0, times, angles.shape[0], endpoint=False)

if displacements is None:
displacements = np.zeros((angles.shape[0], 2))
elif isinstance(displacements, float):
Expand All @@ -85,8 +87,6 @@ def compute(self, angles, axis_roll=0, displacements=None,
self.grid_size[1]),
dtype=float)

frame_times = np.linspace(0, duration, len(angles), endpoint=False)

for ii, ang in enumerate(angles):
ph = self.phantom.transform(rot_main=ang, rot_in_plane=axis_roll)
# QPI
Expand All @@ -103,8 +103,8 @@ def compute(self, angles, axis_roll=0, displacements=None,
displacement=displacements[ii]
).project()
# recording time of each sinogram slice
qpi["time"] = frame_times[ii]
fli["time"] = frame_times[ii]
qpi["time"] = times[ii]
fli["time"] = times[ii]

if write:
with h5py.File(path, "a") as h5:
Expand Down

0 comments on commit 728ac24

Please sign in to comment.