ultrasound: reworked after tests
- new classes in frappy_psi/ultrasound.py and frappy_psi/adq.mr.py - add signal plottter - move clients to bin/ directory Change-Id: I8db8e5ebc082c346278f09e0e54504e070655f14
This commit is contained in:
46
bin/peus-plot
Normal file
46
bin/peus-plot
Normal file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
from frappy.client.interactive import Client
|
||||
from frappy_psi.iqplot import Plot
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print('Usage: python peusplot.py <maxY>')
|
||||
|
||||
|
||||
def get_modules(name):
|
||||
return list(filter(None, (globals().get(name % i) for i in range(10))))
|
||||
|
||||
|
||||
secnode = Client('localhost:5000')
|
||||
time_size = {'time', 'size'}
|
||||
int_mods = [u] + get_modules('roi%d')
|
||||
t_rois = get_modules('roi%d')
|
||||
i_rois = get_modules('roi%di')
|
||||
q_rois = get_modules('roi%dq')
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
maxy = float(sys.argv[1])
|
||||
else:
|
||||
maxy = 0.02
|
||||
|
||||
|
||||
iqplot = Plot(maxy)
|
||||
|
||||
for i in range(99):
|
||||
pass
|
||||
|
||||
try:
|
||||
while True:
|
||||
curves = np.array(u.get_curves())
|
||||
iqplot.plot(curves,
|
||||
rois=[(r.time, r.time + r.size) for r in int_mods],
|
||||
average=([r.time for r in t_rois],
|
||||
[r.value for r in i_rois],
|
||||
[r.value for r in q_rois]))
|
||||
plt.pause(0.5)
|
||||
if iqplot.fig is None: # graph window closed
|
||||
break
|
||||
except KeyboardInterrupt:
|
||||
iqplot.close()
|
60
bin/us-plot
Normal file
60
bin/us-plot
Normal file
@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
from frappy.client.interactive import Client
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
Client('pc13252:5000')
|
||||
|
||||
|
||||
def plot(array, ax, style, xs):
|
||||
xaxis = np.arange(len(array)) * xs
|
||||
return ax.plot(xaxis, array, style)[0]
|
||||
|
||||
|
||||
def update(array, line, xs):
|
||||
xaxis = np.arange(len(array)) * xs
|
||||
line.set_data(np.array([xaxis, array]))
|
||||
|
||||
def on_close(event):
|
||||
sys.exit(0)
|
||||
|
||||
# inp_signal.read()
|
||||
# out_signal.read()
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print("""
|
||||
Usage: python3 sig.py <end> [<start> [<npoints>]]
|
||||
|
||||
end: end of window [ns]
|
||||
start: start of window [n2], default: 0
|
||||
npoints: number fo points (default 1000)
|
||||
""")
|
||||
else:
|
||||
start = 0
|
||||
end = float(sys.argv[1])
|
||||
npoints = 1000
|
||||
if len(sys.argv) > 2:
|
||||
start = float(sys.argv[2])
|
||||
if len(sys.argv) > 3:
|
||||
npoints = float(sys.argv[3])
|
||||
|
||||
fig, ax = plt.subplots(figsize=(15,3))
|
||||
fig.canvas.mpl_connect('close_event', on_close)
|
||||
try:
|
||||
get_signal = iq.get_signal
|
||||
print('plotting RUS signal')
|
||||
except NameError:
|
||||
get_signal = u.get_signal
|
||||
print('plotting PE signal')
|
||||
|
||||
xs, signal = get_signal(start, end, npoints)
|
||||
|
||||
lines = [plot(s, ax, '-', xs) for s in signal]
|
||||
|
||||
while True:
|
||||
plt.pause(0.5)
|
||||
plt.draw()
|
||||
xs, signal = get_signal(start, end, npoints)
|
||||
for line, sig in zip(lines, signal):
|
||||
update(sig, line, xs)
|
Reference in New Issue
Block a user