From 25cbcbb8c07c2deffd6af56189be203003336425 Mon Sep 17 00:00:00 2001 From: Laurent Brock Date: Wed, 20 May 2026 11:53:58 +0200 Subject: [PATCH] Display main pass progression using tqdm instead of prints --- python/MRzeroCore/simulation/main_pass.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/MRzeroCore/simulation/main_pass.py b/python/MRzeroCore/simulation/main_pass.py index cc5e0cf..0f39ed3 100644 --- a/python/MRzeroCore/simulation/main_pass.py +++ b/python/MRzeroCore/simulation/main_pass.py @@ -5,6 +5,7 @@ from ..phantom.sim_data import SimData from .pre_pass import Graph import numpy as np +from tqdm.auto import tqdm # NOTE: return encoding and magnetization is currently missing. If we want to @@ -103,9 +104,10 @@ def execute_graph(graph: Graph, graph[0][0].kt_vec = torch.zeros(4, device=data.device) mag_adc = [] - for i, (dists, rep) in enumerate(zip(graph[1:], seq)): + pbar = tqdm(total=len(seq), desc="Calculating repetitions", disable=not print_progress) + for dists, rep in zip(graph[1:], seq): if print_progress: - print(f"\rCalculating repetition {i+1} / {len(seq)}", end='') + pbar.update(1) angle = torch.as_tensor(rep.pulse.angle) phase = torch.as_tensor(rep.pulse.phase) @@ -278,7 +280,8 @@ def calc_mag(ancestor: tuple) -> torch.Tensor: ancestor[1].mag = None if print_progress: - print(" - done") + pbar.close() + print('Done.') if return_mag_adc: return torch.cat(signal), mag_adc