Skip to content

Commit

Permalink
dwibiasnormmask minor tweaks
Browse files Browse the repository at this point in the history
- Report absence of prior Dice coefficient, rather than a value of 0.0.
- Compute mask overlap image as a bitwise mask.
  • Loading branch information
Lestropie committed Sep 11, 2024
1 parent f30ab69 commit 84ec1fe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions python/mrtrix3/commands/dwibiasnormmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def __init__(self, name, index):
tissue_sum_image = None
iteration = 0
step = 'initialisation'
prev_dice_coefficient = 0.0
prev_dice_coefficient = None
total_scaling_factor = 1.0

def msg():
Expand Down Expand Up @@ -388,7 +388,7 @@ def msg():
app.debug(f'Old mask voxel count: {dwi_old_mask_count}')
app.debug(f'New mask voxel count: {dwi_new_mask_count}')
dwi_mask_overlap_image = f'dwi_mask_overlap{iter_string}.mif'
run.command(f'mrcalc {dwi_mask_image} {new_dwi_mask_image} -mult {dwi_mask_overlap_image}')
run.command(f'mrcalc {dwi_mask_image} {new_dwi_mask_image} -mult {dwi_mask_overlap_image} -datatype bit')

old_dwi_mask_image = dwi_mask_image
dwi_mask_image = new_dwi_mask_image
Expand Down Expand Up @@ -422,7 +422,7 @@ def msg():
total_scaling_factor *= scale_multiplier
break

if new_dice_coefficient < prev_dice_coefficient:
if prev_dice_coefficient is not None and new_dice_coefficient < prev_dice_coefficient:
progress.done()
app.warn(f'Mask divergence at iteration {iteration} '
f'(Dice coefficient = {new_dice_coefficient}); '
Expand Down

0 comments on commit 84ec1fe

Please sign in to comment.