Skip to content

Commit 113c3db

Browse files
committed
lyse analysis script demonstrating some Run methods for example_IMAQdx_remote
1 parent c38877a commit 113c3db

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import lyse
2+
from pathlib import Path
3+
import matplotlib.pyplot as plt
4+
5+
# Is this script being run from within an interactive lyse session?
6+
if lyse.spinning_top:
7+
# If so, use the filepath of the current shot
8+
h5_path = lyse.path
9+
else:
10+
# If not, get the filepath of the last shot of the lyse DataFrame
11+
df = lyse.data()
12+
h5_path = df.filepath.iloc[-1]
13+
14+
# Instantiate a lyse.Run object for this shot
15+
run = lyse.Run(h5_path)
16+
17+
# Get a dictionary of the global variables used in this shot
18+
run_globals = run.get_globals()
19+
20+
# Extract the images 'before' and 'after' generated from camera.expose
21+
before, after = run.get_images('camera', 'comparison', 'before', 'after')
22+
23+
# Compute the difference of the two images, after casting them to signed integers
24+
# (otherwise negative differences wrap to 2**16 - 1 - diff)
25+
diff = after.astype('int16') - before.astype('int16')
26+
27+
# Plot the row-wise mean of each image
28+
plt.plot(before.mean(axis=0), label='before')
29+
plt.plot(after.mean(axis=0), label='after')
30+
plt.xlabel('pixel coordinate (column)')
31+
plt.ylabel('counts')
32+
33+
# Label the plot with a unique string representing the shot
34+
plt.title(Path(run.h5_path).name)
35+
36+
# Plot adornments
37+
plt.legend(loc='lower left')
38+
plt.grid()
39+
40+
# Show the plot
41+
plt.show()
42+
43+
# Compute a result based on the image processing and save it to the 'results' group of
44+
# the shot file
45+
result = diff.std()
46+
run.save_result('foobar', result)

0 commit comments

Comments
 (0)