-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lyse analysis script demonstrating some Run methods for example_IMAQd…
…x_remote
- Loading branch information
1 parent
a48a9c0
commit 66d0be4
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...pt_profile/default_profile/userlib/analysislib/example_apparatus/example_IMAQdx_remote.py
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,46 @@ | ||
import lyse | ||
from pathlib import Path | ||
import matplotlib.pyplot as plt | ||
|
||
# Is this script being run from within an interactive lyse session? | ||
if lyse.spinning_top: | ||
# If so, use the filepath of the current shot | ||
h5_path = lyse.path | ||
else: | ||
# If not, get the filepath of the last shot of the lyse DataFrame | ||
df = lyse.data() | ||
h5_path = df.filepath.iloc[-1] | ||
|
||
# Instantiate a lyse.Run object for this shot | ||
run = lyse.Run(h5_path) | ||
|
||
# Get a dictionary of the global variables used in this shot | ||
run_globals = run.get_globals() | ||
|
||
# Extract the images 'before' and 'after' generated from camera.expose | ||
before, after = run.get_images('camera', 'comparison', 'before', 'after') | ||
|
||
# Compute the difference of the two images, after casting them to signed integers | ||
# (otherwise negative differences wrap to 2**16 - 1 - diff) | ||
diff = after.astype('int16') - before.astype('int16') | ||
|
||
# Plot the row-wise mean of each image | ||
plt.plot(before.mean(axis=0), label='before') | ||
plt.plot(after.mean(axis=0), label='after') | ||
plt.xlabel('pixel coordinate (column)') | ||
plt.ylabel('counts') | ||
|
||
# Label the plot with a unique string representing the shot | ||
plt.title(Path(run.h5_path).name) | ||
|
||
# Plot adornments | ||
plt.legend(loc='lower left') | ||
plt.grid() | ||
|
||
# Show the plot | ||
plt.show() | ||
|
||
# Compute a result based on the image processing and save it to the 'results' group of | ||
# the shot file | ||
result = diff.std() | ||
run.save_result('foobar', result) |