VBoussot commited on
Commit
2843777
·
1 Parent(s): 8cce8eb

Show resolution level and metric in the registration progress bar

Browse files
CBCT_CT_HeadNeck/Model.py CHANGED
@@ -164,10 +164,29 @@ class ElastixEngine:
164
  # chained parameter maps), so the bar spans the whole chain of registration stages.
165
  progress = tqdm.tqdm(total=self._iterations or None, desc="Registration", ncols=0, leave=True)
166
  assert proc.stdout is not None
 
167
  for line in proc.stdout:
168
  captured.append(line)
169
- if iteration_line.match(line):
 
 
 
 
 
 
170
  progress.update(1)
 
 
 
 
 
 
 
 
 
 
 
 
171
  progress.close()
172
  returncode = proc.wait()
173
  if returncode != 0:
 
164
  # chained parameter maps), so the bar spans the whole chain of registration stages.
165
  progress = tqdm.tqdm(total=self._iterations or None, desc="Registration", ncols=0, leave=True)
166
  assert proc.stdout is not None
167
+ resolution = 0
168
  for line in proc.stdout:
169
  captured.append(line)
170
+ stripped = line.strip()
171
+ if stripped.startswith("Resolution:"):
172
+ try:
173
+ resolution = int(stripped.split(":", 1)[1])
174
+ except ValueError:
175
+ pass
176
+ elif iteration_line.match(line):
177
  progress.update(1)
178
+ # Mirror KonfAI's informative bars (which surface runtime state in the description):
179
+ # show the elastix resolution level and the similarity metric being optimised so the
180
+ # bar conveys convergence, not a bare iteration count. Column 2 of the iteration table
181
+ # is the metric (header: "1:ItNr 2:Metric ...").
182
+ columns = line.split()
183
+ if len(columns) > 1:
184
+ try:
185
+ progress.set_description(
186
+ f"Registration : res {resolution} | metric {float(columns[1]):.4f}"
187
+ )
188
+ except ValueError:
189
+ pass
190
  progress.close()
191
  returncode = proc.wait()
192
  if returncode != 0:
CBCT_CT_MRSeg/Model.py CHANGED
@@ -164,10 +164,29 @@ class ElastixEngine:
164
  # chained parameter maps), so the bar spans the whole chain of registration stages.
165
  progress = tqdm.tqdm(total=self._iterations or None, desc="Registration", ncols=0, leave=True)
166
  assert proc.stdout is not None
 
167
  for line in proc.stdout:
168
  captured.append(line)
169
- if iteration_line.match(line):
 
 
 
 
 
 
170
  progress.update(1)
 
 
 
 
 
 
 
 
 
 
 
 
171
  progress.close()
172
  returncode = proc.wait()
173
  if returncode != 0:
 
164
  # chained parameter maps), so the bar spans the whole chain of registration stages.
165
  progress = tqdm.tqdm(total=self._iterations or None, desc="Registration", ncols=0, leave=True)
166
  assert proc.stdout is not None
167
+ resolution = 0
168
  for line in proc.stdout:
169
  captured.append(line)
170
+ stripped = line.strip()
171
+ if stripped.startswith("Resolution:"):
172
+ try:
173
+ resolution = int(stripped.split(":", 1)[1])
174
+ except ValueError:
175
+ pass
176
+ elif iteration_line.match(line):
177
  progress.update(1)
178
+ # Mirror KonfAI's informative bars (which surface runtime state in the description):
179
+ # show the elastix resolution level and the similarity metric being optimised so the
180
+ # bar conveys convergence, not a bare iteration count. Column 2 of the iteration table
181
+ # is the metric (header: "1:ItNr 2:Metric ...").
182
+ columns = line.split()
183
+ if len(columns) > 1:
184
+ try:
185
+ progress.set_description(
186
+ f"Registration : res {resolution} | metric {float(columns[1]):.4f}"
187
+ )
188
+ except ValueError:
189
+ pass
190
  progress.close()
191
  returncode = proc.wait()
192
  if returncode != 0:
CBCT_CT_TS/Model.py CHANGED
@@ -164,10 +164,29 @@ class ElastixEngine:
164
  # chained parameter maps), so the bar spans the whole chain of registration stages.
165
  progress = tqdm.tqdm(total=self._iterations or None, desc="Registration", ncols=0, leave=True)
166
  assert proc.stdout is not None
 
167
  for line in proc.stdout:
168
  captured.append(line)
169
- if iteration_line.match(line):
 
 
 
 
 
 
170
  progress.update(1)
 
 
 
 
 
 
 
 
 
 
 
 
171
  progress.close()
172
  returncode = proc.wait()
173
  if returncode != 0:
 
164
  # chained parameter maps), so the bar spans the whole chain of registration stages.
165
  progress = tqdm.tqdm(total=self._iterations or None, desc="Registration", ncols=0, leave=True)
166
  assert proc.stdout is not None
167
+ resolution = 0
168
  for line in proc.stdout:
169
  captured.append(line)
170
+ stripped = line.strip()
171
+ if stripped.startswith("Resolution:"):
172
+ try:
173
+ resolution = int(stripped.split(":", 1)[1])
174
+ except ValueError:
175
+ pass
176
+ elif iteration_line.match(line):
177
  progress.update(1)
178
+ # Mirror KonfAI's informative bars (which surface runtime state in the description):
179
+ # show the elastix resolution level and the similarity metric being optimised so the
180
+ # bar conveys convergence, not a bare iteration count. Column 2 of the iteration table
181
+ # is the metric (header: "1:ItNr 2:Metric ...").
182
+ columns = line.split()
183
+ if len(columns) > 1:
184
+ try:
185
+ progress.set_description(
186
+ f"Registration : res {resolution} | metric {float(columns[1]):.4f}"
187
+ )
188
+ except ValueError:
189
+ pass
190
  progress.close()
191
  returncode = proc.wait()
192
  if returncode != 0:
Generic_Rigid/Model.py CHANGED
@@ -164,10 +164,29 @@ class ElastixEngine:
164
  # chained parameter maps), so the bar spans the whole chain of registration stages.
165
  progress = tqdm.tqdm(total=self._iterations or None, desc="Registration", ncols=0, leave=True)
166
  assert proc.stdout is not None
 
167
  for line in proc.stdout:
168
  captured.append(line)
169
- if iteration_line.match(line):
 
 
 
 
 
 
170
  progress.update(1)
 
 
 
 
 
 
 
 
 
 
 
 
171
  progress.close()
172
  returncode = proc.wait()
173
  if returncode != 0:
 
164
  # chained parameter maps), so the bar spans the whole chain of registration stages.
165
  progress = tqdm.tqdm(total=self._iterations or None, desc="Registration", ncols=0, leave=True)
166
  assert proc.stdout is not None
167
+ resolution = 0
168
  for line in proc.stdout:
169
  captured.append(line)
170
+ stripped = line.strip()
171
+ if stripped.startswith("Resolution:"):
172
+ try:
173
+ resolution = int(stripped.split(":", 1)[1])
174
+ except ValueError:
175
+ pass
176
+ elif iteration_line.match(line):
177
  progress.update(1)
178
+ # Mirror KonfAI's informative bars (which surface runtime state in the description):
179
+ # show the elastix resolution level and the similarity metric being optimised so the
180
+ # bar conveys convergence, not a bare iteration count. Column 2 of the iteration table
181
+ # is the metric (header: "1:ItNr 2:Metric ...").
182
+ columns = line.split()
183
+ if len(columns) > 1:
184
+ try:
185
+ progress.set_description(
186
+ f"Registration : res {resolution} | metric {float(columns[1]):.4f}"
187
+ )
188
+ except ValueError:
189
+ pass
190
  progress.close()
191
  returncode = proc.wait()
192
  if returncode != 0:
Generic_Rigid_BSpline/Model.py CHANGED
@@ -164,10 +164,29 @@ class ElastixEngine:
164
  # chained parameter maps), so the bar spans the whole chain of registration stages.
165
  progress = tqdm.tqdm(total=self._iterations or None, desc="Registration", ncols=0, leave=True)
166
  assert proc.stdout is not None
 
167
  for line in proc.stdout:
168
  captured.append(line)
169
- if iteration_line.match(line):
 
 
 
 
 
 
170
  progress.update(1)
 
 
 
 
 
 
 
 
 
 
 
 
171
  progress.close()
172
  returncode = proc.wait()
173
  if returncode != 0:
 
164
  # chained parameter maps), so the bar spans the whole chain of registration stages.
165
  progress = tqdm.tqdm(total=self._iterations or None, desc="Registration", ncols=0, leave=True)
166
  assert proc.stdout is not None
167
+ resolution = 0
168
  for line in proc.stdout:
169
  captured.append(line)
170
+ stripped = line.strip()
171
+ if stripped.startswith("Resolution:"):
172
+ try:
173
+ resolution = int(stripped.split(":", 1)[1])
174
+ except ValueError:
175
+ pass
176
+ elif iteration_line.match(line):
177
  progress.update(1)
178
+ # Mirror KonfAI's informative bars (which surface runtime state in the description):
179
+ # show the elastix resolution level and the similarity metric being optimised so the
180
+ # bar conveys convergence, not a bare iteration count. Column 2 of the iteration table
181
+ # is the metric (header: "1:ItNr 2:Metric ...").
182
+ columns = line.split()
183
+ if len(columns) > 1:
184
+ try:
185
+ progress.set_description(
186
+ f"Registration : res {resolution} | metric {float(columns[1]):.4f}"
187
+ )
188
+ except ValueError:
189
+ pass
190
  progress.close()
191
  returncode = proc.wait()
192
  if returncode != 0:
MR_CT_HeadNeck/Model.py CHANGED
@@ -164,10 +164,29 @@ class ElastixEngine:
164
  # chained parameter maps), so the bar spans the whole chain of registration stages.
165
  progress = tqdm.tqdm(total=self._iterations or None, desc="Registration", ncols=0, leave=True)
166
  assert proc.stdout is not None
 
167
  for line in proc.stdout:
168
  captured.append(line)
169
- if iteration_line.match(line):
 
 
 
 
 
 
170
  progress.update(1)
 
 
 
 
 
 
 
 
 
 
 
 
171
  progress.close()
172
  returncode = proc.wait()
173
  if returncode != 0:
 
164
  # chained parameter maps), so the bar spans the whole chain of registration stages.
165
  progress = tqdm.tqdm(total=self._iterations or None, desc="Registration", ncols=0, leave=True)
166
  assert proc.stdout is not None
167
+ resolution = 0
168
  for line in proc.stdout:
169
  captured.append(line)
170
+ stripped = line.strip()
171
+ if stripped.startswith("Resolution:"):
172
+ try:
173
+ resolution = int(stripped.split(":", 1)[1])
174
+ except ValueError:
175
+ pass
176
+ elif iteration_line.match(line):
177
  progress.update(1)
178
+ # Mirror KonfAI's informative bars (which surface runtime state in the description):
179
+ # show the elastix resolution level and the similarity metric being optimised so the
180
+ # bar conveys convergence, not a bare iteration count. Column 2 of the iteration table
181
+ # is the metric (header: "1:ItNr 2:Metric ...").
182
+ columns = line.split()
183
+ if len(columns) > 1:
184
+ try:
185
+ progress.set_description(
186
+ f"Registration : res {resolution} | metric {float(columns[1]):.4f}"
187
+ )
188
+ except ValueError:
189
+ pass
190
  progress.close()
191
  returncode = proc.wait()
192
  if returncode != 0:
MR_CT_MRSeg/Model.py CHANGED
@@ -164,10 +164,29 @@ class ElastixEngine:
164
  # chained parameter maps), so the bar spans the whole chain of registration stages.
165
  progress = tqdm.tqdm(total=self._iterations or None, desc="Registration", ncols=0, leave=True)
166
  assert proc.stdout is not None
 
167
  for line in proc.stdout:
168
  captured.append(line)
169
- if iteration_line.match(line):
 
 
 
 
 
 
170
  progress.update(1)
 
 
 
 
 
 
 
 
 
 
 
 
171
  progress.close()
172
  returncode = proc.wait()
173
  if returncode != 0:
 
164
  # chained parameter maps), so the bar spans the whole chain of registration stages.
165
  progress = tqdm.tqdm(total=self._iterations or None, desc="Registration", ncols=0, leave=True)
166
  assert proc.stdout is not None
167
+ resolution = 0
168
  for line in proc.stdout:
169
  captured.append(line)
170
+ stripped = line.strip()
171
+ if stripped.startswith("Resolution:"):
172
+ try:
173
+ resolution = int(stripped.split(":", 1)[1])
174
+ except ValueError:
175
+ pass
176
+ elif iteration_line.match(line):
177
  progress.update(1)
178
+ # Mirror KonfAI's informative bars (which surface runtime state in the description):
179
+ # show the elastix resolution level and the similarity metric being optimised so the
180
+ # bar conveys convergence, not a bare iteration count. Column 2 of the iteration table
181
+ # is the metric (header: "1:ItNr 2:Metric ...").
182
+ columns = line.split()
183
+ if len(columns) > 1:
184
+ try:
185
+ progress.set_description(
186
+ f"Registration : res {resolution} | metric {float(columns[1]):.4f}"
187
+ )
188
+ except ValueError:
189
+ pass
190
  progress.close()
191
  returncode = proc.wait()
192
  if returncode != 0:
MR_CT_TS/Model.py CHANGED
@@ -164,10 +164,29 @@ class ElastixEngine:
164
  # chained parameter maps), so the bar spans the whole chain of registration stages.
165
  progress = tqdm.tqdm(total=self._iterations or None, desc="Registration", ncols=0, leave=True)
166
  assert proc.stdout is not None
 
167
  for line in proc.stdout:
168
  captured.append(line)
169
- if iteration_line.match(line):
 
 
 
 
 
 
170
  progress.update(1)
 
 
 
 
 
 
 
 
 
 
 
 
171
  progress.close()
172
  returncode = proc.wait()
173
  if returncode != 0:
 
164
  # chained parameter maps), so the bar spans the whole chain of registration stages.
165
  progress = tqdm.tqdm(total=self._iterations or None, desc="Registration", ncols=0, leave=True)
166
  assert proc.stdout is not None
167
+ resolution = 0
168
  for line in proc.stdout:
169
  captured.append(line)
170
+ stripped = line.strip()
171
+ if stripped.startswith("Resolution:"):
172
+ try:
173
+ resolution = int(stripped.split(":", 1)[1])
174
+ except ValueError:
175
+ pass
176
+ elif iteration_line.match(line):
177
  progress.update(1)
178
+ # Mirror KonfAI's informative bars (which surface runtime state in the description):
179
+ # show the elastix resolution level and the similarity metric being optimised so the
180
+ # bar conveys convergence, not a bare iteration count. Column 2 of the iteration table
181
+ # is the metric (header: "1:ItNr 2:Metric ...").
182
+ columns = line.split()
183
+ if len(columns) > 1:
184
+ try:
185
+ progress.set_description(
186
+ f"Registration : res {resolution} | metric {float(columns[1]):.4f}"
187
+ )
188
+ except ValueError:
189
+ pass
190
  progress.close()
191
  returncode = proc.wait()
192
  if returncode != 0: