Skip to content

Commit deb2e92

Browse files
authored
[FIX] Convert histogram weights to null distribution in p-to-stat conversion (#430)
1 parent e865c6c commit deb2e92

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

nimare/meta/cbma/base.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,16 @@ def _p_to_summarystat(self, p, null_method=None):
260260
assert "histogram_bins" in self.null_distributions_.keys()
261261
assert "histogram_weights" in self.null_distributions_.keys()
262262

263-
hist_weights = self.null_distributions_["histogram_weights"]
263+
# Convert unnormalized histogram weights to null distribution
264+
histogram_weights = self.null_distributions_["histogram_weights"]
265+
null_distribution = histogram_weights / np.sum(histogram_weights)
266+
null_distribution = np.cumsum(null_distribution[::-1])[::-1]
267+
null_distribution /= np.max(null_distribution)
268+
null_distribution = np.squeeze(null_distribution)
269+
264270
# Desired bin is the first one _before_ the target p-value (for consistency
265271
# with the empirical null).
266-
ss_idx = np.maximum(0, np.where(hist_weights <= p)[0][0] - 1)
272+
ss_idx = np.maximum(0, np.where(null_distribution <= p)[0][0] - 1)
267273
ss = self.null_distributions_["histogram_bins"][ss_idx]
268274

269275
elif null_method == "empirical":

0 commit comments

Comments
 (0)