Commit d5e61cdb authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Fixes to ProbabilisticAtlas.maskPropotions method - was not calculating

weighted mean correctly.
parent f162bb5b
......@@ -825,16 +825,18 @@ class ProbabilisticAtlas(Atlas):
# Make sure that the mask has the same
# 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
for label in range(self.shape[3]):
vals = self[..., label]
vals = vals[boolmask] * mask[boolmask]
prop = vals.mean()
weights = mask[boolmask]
vals = self[..., label]
vals = vals[boolmask] * weights
prop = vals.sum() / weights.sum()
if not np.isclose(prop, 0):
if prop != 0:
labels.append(label)
props .append(prop)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment