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:
2025-03-26 15:31:46 +01:00
parent 71372a450b
commit c3b6aca7bc
7 changed files with 553 additions and 167 deletions

View File

@ -7,10 +7,12 @@ Created on Tue Feb 4 11:07:56 2020
import numpy as np
import matplotlib.pyplot as plt
NAN = float('nan')
def rect(x1, x2, y1, y2):
return np.array([[x1,x2,x2,x1,x1],[y1,y1,y2,y2,y1]])
NAN = float('nan')
def rects(intervals, y12):
result = [rect(*intervals[0], *y12)]
@ -19,13 +21,14 @@ def rects(intervals, y12):
result.append(rect(*x12, *y12))
return np.concatenate(result, axis=1)
class Plot:
def __init__(self, maxy):
self.lines = {}
self.yaxis = ((-2 * maxy, maxy), (-maxy, 2 * maxy))
self.first = True
self.fig = None
def set_line(self, iax, name, data, fmt, **kwds):
"""
plot or update a line
@ -54,6 +57,9 @@ class Plot:
self.fig = None
self.first = True
def on_close(self, event):
self.fig = None
def plot(self, curves, rois=None, average=None):
boxes = rects(rois[1:], self.yaxis[0])
pbox = rect(*rois[0], *self.yaxis[1])
@ -68,6 +74,7 @@ class Plot:
if self.first:
plt.ion()
self.fig, axleft = plt.subplots(figsize=(15,7))
self.fig.canvas.mpl_connect('close_event', self.on_close)
plt.title("I/Q", fontsize=14)
axleft.set_xlim(0, curves[0][-1])
self.ax = [axleft, axleft.twinx()]
@ -95,7 +102,7 @@ class Plot:
plt.tight_layout()
finally:
self.first = False
plt.draw()
self.fig.canvas.draw()
self.fig.canvas.flush_events()