Skip to content

Commit

Permalink
fix vox_vol multiplication in PVMeasure
Browse files Browse the repository at this point in the history
better save_maps test
  • Loading branch information
dkuegler committed Apr 1, 2024
1 parent 6952cda commit 67304c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
3 changes: 2 additions & 1 deletion FastSurferCNN/segstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,8 @@ def main(args: argparse.Namespace) -> Literal[0] | str:
pv_data = pv_preproc_future.result()

names = ["nbr", "nbr_means", "seg_means", "mix_coeff", "nbr_mix_coeff"]
save_maps = any(getattr(args, n, "") for n in names)
save_maps_paths = (getattr(args, n, "") for n in names)
save_maps = any(bool(path) and path != Path() for path in save_maps_paths)
out = pv_calc(seg_data, pv_data, norm_data, labels, return_maps=save_maps, **kwargs)

_io_futures = []
Expand Down
12 changes: 3 additions & 9 deletions FastSurferCNN/utils/brainvolstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,6 @@ def __init__(
self._classes = classes
super().__init__(name, description, unit)
self._pv_value = None
self._vox_vol = 0.

@property
def vox_vol(self) -> float:
Expand All @@ -736,12 +735,8 @@ def __call__(self) -> float:
f"The partial volume of {self._name} has not been updated in the "
f"PVMeasure object yet!"
)
if self.unit == "unitless":
vox_vol, col = 1, "NVoxels"
else:
vox_vol, col = self._vox_vol, "Volume_mm3"
out = self._pv_value[col].item() * vox_vol
return out
col = "NVoxels" if self.unit == "unitless" else "Volume_mm3"
return self._pv_value[col].item()

def _parsable_args(self) -> list[str]:
return ["classes"]
Expand Down Expand Up @@ -2191,8 +2186,7 @@ def mask_77_lat(arr):
brain_seg_classes.extend(range(2002, 2032))
brain_seg_classes.remove(2004)
brain_seg_classes.extend((2034, 2035))
brainseg_class = self.voxel_class
return brainseg_class(
return self.voxel_class(
brain_seg_classes,
"BrainSegVol",
"Brain Segmentation Volume",
Expand Down

0 comments on commit 67304c5

Please sign in to comment.