Skip to content

Commit

Permalink
feat: add capability to track progress of sinogram generation
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Feb 25, 2019
1 parent 0af9fc6 commit 0e23e51
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
0.2.0
- feat: add capability to track progress of sinogram generation
0.1.0
- add basic example to docs
- drawing refractive index and fluorescence phantoms
Expand Down
6 changes: 5 additions & 1 deletion cellsino/phantoms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from .ph_simple_cell import SimpleCell

available = [SimpleCell]
phan_dict = {
"simple cell": SimpleCell,
}

available = sorted(phan_dict.keys())
4 changes: 2 additions & 2 deletions cellsino/propagators/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from .pp_rytov import Rytov
from .pp_projection import Projection

dictionary = {
prop_dict = {
"projection": Projection,
"rytov": Rytov,
}

available = sorted(dictionary.keys())
available = sorted(prop_dict.keys())
25 changes: 18 additions & 7 deletions cellsino/sinogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@
import qpimage

from .fluorescence import Fluorescence
from .propagators import dictionary as pp_dict
from .propagators import prop_dict
from .phantoms import phan_dict


class Sinogram(object):
def __init__(self, phantom, wavelength, pixel_size, grid_size):
self.phantom = phantom
if isinstance(phantom, str):
self.phantom = phan_dict[phantom]()
else:
self.phantom = phantom
self.wavelength = wavelength
self.pixel_size = pixel_size
self.grid_size = grid_size

def compute(self, angles, path=None, propagator="rytov"):
def compute(self, angles, path=None, propagator="rytov",
count=None, max_count=None):
if max_count is not None:
max_count.value += angles.size

if isinstance(angles, int):
angles = np.linspace(0, 2*np.pi, angles, endpoint=False)

Expand All @@ -38,10 +46,10 @@ def compute(self, angles, path=None, propagator="rytov"):
for ii, ang in enumerate(angles):
ph = self.phantom.transform(rot_main=ang)

pp = pp_dict[propagator](phantom=ph,
grid_size=self.grid_size,
pixel_size=self.pixel_size,
wavelength=self.wavelength)
pp = prop_dict[propagator](phantom=ph,
grid_size=self.grid_size,
pixel_size=self.pixel_size,
wavelength=self.wavelength)
qpi = pp.propagate()
fluor = Fluorescence(phantom=ph,
grid_size=self.grid_size,
Expand All @@ -61,6 +69,9 @@ def compute(self, angles, path=None, propagator="rytov"):
sino_fields[ii] = qpi.field
sino_fluor[ii] = fluor

if count is not None:
count.value += 1

if write:
return path
else:
Expand Down

0 comments on commit 0e23e51

Please sign in to comment.