Skip to content

Commit

Permalink
Fix filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
tfarago committed Mar 2, 2015
1 parent ffd0bf3 commit 2eee3f7
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions concert/ext/ufo.py
@@ -1,5 +1,6 @@
from __future__ import absolute_import
import threading
import sys
import numpy as np

try:
Expand All @@ -8,6 +9,12 @@
except ImportError as e:
print(str(e))

try:
from tofu.reco import setup_padding
except ImportError:
print >> sys.stderr, "You must install tofu to use Ufo features, see "\
"'https://github.com/ufo-kit/tofu.git'"

from concert.quantities import q
from concert.coroutines.base import coroutine, inject
from concert.coroutines.filters import sinograms, flat_correct
Expand Down Expand Up @@ -161,6 +168,8 @@ class Backproject(InjectProcess):

def __init__(self, axis_pos=None):
self.pm = PluginManager()
self.pad = self.pm.get_task('pad')
self.crop = self.pm.get_task('cut-roi')
self.fft = self.pm.get_task('fft', dimensions=1)
self.ifft = self.pm.get_task('ifft', dimensions=1)
self.fltr = self.pm.get_task('filter')
Expand All @@ -177,10 +186,13 @@ def _connect_nodes(self, first=None):
"""Connect processing nodes. *first* is the node before fft."""
graph = Ufo.TaskGraph()
if first:
graph.connect_nodes(first, self.fft)
graph.connect_nodes(first, self.pad)

graph.connect_nodes(self.pad, self.fft)
graph.connect_nodes(self.fft, self.fltr)
graph.connect_nodes(self.fltr, self.ifft)
graph.connect_nodes(self.ifft, self.backprojector)
graph.connect_nodes(self.ifft, self.crop)
graph.connect_nodes(self.crop, self.backprojector)

return graph

Expand All @@ -204,7 +216,7 @@ def __call__(self, consumer):
self.start()

sinogram = yield
self.ifft.props.crop_width = sinogram.shape[1]
setup_padding(self.pad, self.crop, sinogram.shape[1], sinogram.shape[0])
self._process(sinogram, consumer)

while True:
Expand Down Expand Up @@ -256,7 +268,6 @@ def dark_row(self):
def dark_row(self, row):
if row is not None:
row = row.astype(np.float32)
self.ifft.props.crop_width = row.shape[0]

self._dark_row = row

Expand Down

0 comments on commit 2eee3f7

Please sign in to comment.