Skip to content

Commit

Permalink
add plotting at the end.
Browse files Browse the repository at this point in the history
  • Loading branch information
paquiteau committed Sep 24, 2023
1 parent c4de251 commit 62dac85
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions examples/example_vds_simrec.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# Create The simulation
# ---------------------
# We create a simple simulation with 4 coils and a 64x64 image.
# ``lazy=True`` means that the data will be generated on the fly when needed.
# This is useful to avoid storing large data in memory.

sim = SimulationData(
(64, 64), sim_tr=0.1, sim_time=300, fov=0.192, n_coils=4, rng=42, lazy=True
Expand Down Expand Up @@ -108,17 +110,10 @@ def plot_ts_roi(arr, sim, roi_idx, ax=None, center=False, **kwargs):
arr_ = np.abs(arr) if np.iscomplexobj(arr) else arr
arr_ = arr_[:, sim.roi]

if roi_idx is None:
ts = np.mean(arr_, axis=-1)
if center:
mean_val = np.mean(ts, axis=0)
ts -= mean_val
ts_plot = ax.plot(time_samples, ts, **kwargs)
else:
ts = arr_[:, roi_idx]
if center:
ts -= np.mean(ts, axis=0)
ax.plot(time_samples, ts, **kwargs)
ts = arr_[:, roi_idx] if roi_idx is not None else np.mean(arr_, axis=-1)
if center:
ts -= np.mean(ts, axis=0)
ax.plot(time_samples, ts, **kwargs)
return ax


Expand All @@ -137,3 +132,19 @@ def plot_ts_roi_many(arr_dict, sim, roi_idx, ax=None, center=False, **kwargs):
ax.legend(loc="center left", bbox_to_anchor=(1, 0.5), borderaxespad=0.0)

return ax


# %%
# Time serie of the ROI
# ~~~~~~~~~~~~~~~~~~~~~
#

fig, ax = plt.subplots()
ax.set_title("Time serie of the ROI")
plot_ts_roi_many(
{"acquired": sim.data_acq, "zero-filled": adj_data, "sequential": seq_data},
sim,
roi_idx=0,
ax=ax,
center=True,
)

0 comments on commit 62dac85

Please sign in to comment.