-
Notifications
You must be signed in to change notification settings - Fork 0
/
ufo_simple_reconstruction.py
53 lines (40 loc) · 1.32 KB
/
ufo_simple_reconstruction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""---\nThis session demonstrates reconstruction with the UFO data
processing framework.
Usage:
await main()
"""
import asyncio
import concert
concert.require("0.31")
try:
import gi
gi.require_version('Ufo', '0.0')
from gi.repository import Ufo
except ImportError as e:
print(str(e))
import numpy as np
from concert.quantities import q
from concert.session.utils import ddoc, dstate, pdoc
from concert.ext.ufo import PluginManager, InjectProcess
from concert.ext.viewers import PyplotImageViewer
viewer = await PyplotImageViewer(title='Sinogram', fast=False)
slice_viewer = await PyplotImageViewer(title='Slice', fast=False)
async def reconstruct(sino):
pm = PluginManager()
fft = pm.get_task('fft', dimensions=1)
ifft = pm.get_task('ifft', dimensions=1)
fltr = pm.get_task('filter')
bp = pm.get_task('backproject')
graph = Ufo.TaskGraph()
graph.connect_nodes(fft, fltr)
graph.connect_nodes(fltr, ifft)
graph.connect_nodes(ifft, bp)
with InjectProcess(graph, get_output=True) as process:
await process.insert(sino)
return await process.result(leave_index=0)
async def main():
sino = np.random.normal(size=(1024, 1024)).astype(np.float32)
sino[:, 760:770] = 5
slc = await reconstruct(sino)
await viewer.show(sino)
await slice_viewer.show(slc)