-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #261 from CJ-Wright/tomo_3D
Support 3D pencil reconstruction
- Loading branch information
Showing
16 changed files
with
565 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import os | ||
import time | ||
|
||
import bluesky.plans as bp | ||
import dxchange | ||
import numpy as np | ||
import tomopy | ||
from bluesky.run_engine import RunEngine | ||
from ophyd.sim import SynSignal, hw | ||
from xpdan.vend.callbacks.zmq import Publisher | ||
from xpdconf.conf import glbl_dict | ||
|
||
hw = hw() | ||
rot_center = 290 | ||
m = hw.motor1 | ||
m.kind = "hinted" | ||
mm = hw.motor2 | ||
mm.kind = "hinted" | ||
mmm = hw.motor3 | ||
mmm.kind = "hinted" | ||
xrun(0, | ||
bp.grid_scan( | ||
[xpd_pe1c], | ||
mmm, | ||
0, | ||
2, | ||
2, | ||
m, | ||
0, | ||
180, | ||
4, | ||
True, | ||
mm, | ||
200, | ||
401, | ||
4, | ||
True, | ||
|
||
md={ | ||
"tomo": { | ||
"type": "pencil", | ||
"rotation": "motor1", | ||
"translation": "motor2", | ||
"stack": "motor3", | ||
"center": rot_center - 200, | ||
} | ||
}, | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
import os | ||
import time | ||
|
||
import bluesky.plans as bp | ||
import dxchange | ||
import numpy as np | ||
import tomopy | ||
from bluesky.run_engine import RunEngine | ||
from ophyd.sim import SynSignal, hw, SynSignalWithRegistry | ||
from xpdan.vend.callbacks.zmq import Publisher | ||
from xpdconf.conf import glbl_dict | ||
|
||
hw = hw() | ||
fname = os.path.expanduser("~/Downloads/tooth.h5") | ||
|
||
proj, flat, dark, theta = dxchange.read_aps_32id(fname, sino=(0, 1)) | ||
|
||
proj = tomopy.normalize(proj, flat, dark) | ||
|
||
rot_center = tomopy.find_center(proj, theta, init=290, ind=0, tol=0.5) | ||
# proj2 = np.hstack((proj[:, :, :],) * 200) | ||
# proj2 = np.hstack((proj[:, :, :],) * 1) | ||
# rot_center -= 200 | ||
proj2 = proj | ||
m = hw.motor1 | ||
m.kind = "hinted" | ||
mm = hw.motor2 | ||
mm.kind = "hinted" | ||
mmm = hw.motor3 | ||
mmm.kind = "hinted" | ||
|
||
|
||
class FullField: | ||
def __call__(self, *args, **kwargs): | ||
v = m.get()[0] | ||
out = proj2[int(v), :, :] | ||
print(v) | ||
time.sleep(.5) | ||
return out | ||
|
||
|
||
class Pencil: | ||
def __call__(self, *args, **kwargs): | ||
v = m.get()[0] | ||
vv = mm.get()[0] | ||
out = proj2[int(v), :, int(vv)] | ||
print(v, vv, mmm.get()[0]) | ||
time.sleep(.5) | ||
return np.squeeze(out) | ||
|
||
|
||
f = FullField() | ||
# det = SynSignal(f, name="img", labels={"detectors"}) | ||
det = SynSignalWithRegistry(f, name="img", labels={"detectors"},) | ||
det.kind = "hinted" | ||
|
||
#g = Pencil() | ||
#det2 = SynSignal(g, name="img", labels={"detectors"}) | ||
#det2.kind = "hinted" | ||
|
||
RE = RunEngine() | ||
RE.md['analysis_stage'] = 'raw' | ||
p = Publisher(glbl_dict["inbound_proxy_address"], prefix=b"raw") | ||
t = RE.subscribe(p) | ||
# RE.subscribe(print) | ||
|
||
# Build scan | ||
l = [0, 90] | ||
for i in range(8): | ||
ll = l.copy() | ||
interval = sorted(set(ll))[1] / 2 | ||
for lll in ll: | ||
j = lll + interval | ||
j = round(j, 0) | ||
if j not in l and j < 180: | ||
l.append(j) | ||
# Run Full Field Scans, each scan has more slices, showing how we can minimize | ||
# the number of slices by interleaving them by half | ||
for i in [2 ** n for n in range(2, 8)] + [180]: | ||
RE( | ||
bp.list_scan( | ||
[det], | ||
m, | ||
l[:i], | ||
md={ | ||
"tomo": { | ||
"type": "full_field", | ||
"rotation": "motor1", | ||
"center": rot_center, | ||
} | ||
}, | ||
) | ||
) | ||
print(i) | ||
time.sleep(3) | ||
''' | ||
# Run in pencil beam geometry (this takes a long time!) | ||
RE( | ||
bp.grid_scan( | ||
[det2], | ||
m, | ||
0, | ||
180, | ||
181, | ||
mm, | ||
0, | ||
639, | ||
640, | ||
True, | ||
md={ | ||
"tomo": { | ||
"type": "pencil", | ||
"rotation": "motor1", | ||
"translation": "motor2", | ||
"center": rot_center, | ||
} | ||
}, | ||
) | ||
) | ||
# Run in 3D pencil beam geometry | ||
RE( | ||
bp.grid_scan( | ||
[det2], | ||
mmm, | ||
0, | ||
2, | ||
10, | ||
m, | ||
0, | ||
180, | ||
41, | ||
True, | ||
mm, | ||
200, | ||
401, | ||
21, | ||
True, | ||
md={ | ||
"tomo": { | ||
"type": "pencil", | ||
"rotation": "motor1", | ||
"translation": "motor2", | ||
"stack": "motor3", | ||
"center": rot_center - 200, | ||
} | ||
}, | ||
) | ||
) | ||
RE.abort() | ||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
**Added:** | ||
|
||
* Support for 3D pencil beam reconstructions | ||
* Support for Registry backed full field reconstructions | ||
* ``ctPDF_example.py`` example for pencil beam | ||
|
||
**Changed:** | ||
|
||
* ``tomo_example.py`` runs on a registry backed detector | ||
|
||
**Deprecated:** None | ||
|
||
**Removed:** None | ||
|
||
**Fixed:** | ||
|
||
* Pencil beam no longer tries to run independent var reconstructions | ||
|
||
**Security:** None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
"viz_server", | ||
"analysis_server", | ||
"qoi_server", | ||
"tomo_server", | ||
] | ||
|
||
entry_points = { | ||
|
Oops, something went wrong.