Skip to content

Commit ef45a31

Browse files
committed
Reapply "Select lowest registration cost for auto PET reference"
This reverts commit 58e8491.
1 parent efdae0f commit ef45a31

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

petprep/workflows/pet/fit.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,20 +209,23 @@ def _extract_sum_image(pet_file: str, output_dir: 'Path') -> str:
209209

210210

211211
def _select_best_petref(labels, scores, transforms, inv_transforms, winners, petrefs):
212-
"""Select the PET reference with the highest registration score."""
212+
"""Select the PET reference with the lowest registration cost."""
213213

214214
if not labels or not scores:
215215
raise ValueError('No PET reference candidates were provided for selection.')
216216

217-
best_idx = 0
218-
best_score = float('-inf')
217+
best_idx = None
218+
best_score = float('inf')
219219
for idx, score in enumerate(scores):
220220
if score is None:
221221
continue
222-
if score > best_score:
222+
if score < best_score:
223223
best_idx = idx
224224
best_score = score
225225

226+
if best_idx is None:
227+
raise ValueError('No registration scores were available for selection.')
228+
226229
return (
227230
labels[best_idx],
228231
best_score,

0 commit comments

Comments
 (0)