Skip to content
Snippets Groups Projects
Commit d5e61cdb authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

Fixes to ProbabilisticAtlas.maskPropotions method - was not calculating

weighted mean correctly.
parent f162bb5b
No related branches found
No related tags found
No related merge requests found
...@@ -825,16 +825,18 @@ class ProbabilisticAtlas(Atlas): ...@@ -825,16 +825,18 @@ class ProbabilisticAtlas(Atlas):
# Make sure that the mask has the same # Make sure that the mask has the same
# number of voxels as the atlas image # number of voxels as the atlas image
mask = mask.resample(self.shape[:3], order=1) mask = mask.resample(self.shape[:3], dtype=np.float32, order=1)[0]
boolmask = mask > 0 boolmask = mask > 0
for label in range(self.shape[3]): for label in range(self.shape[3]):
vals = self[..., label] weights = mask[boolmask]
vals = vals[boolmask] * mask[boolmask] vals = self[..., label]
prop = vals.mean() vals = vals[boolmask] * weights
prop = vals.sum() / weights.sum()
if not np.isclose(prop, 0):
if prop != 0:
labels.append(label) labels.append(label)
props .append(prop) props .append(prop)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment