Skip to content

Commit

Permalink
[FIX] Convert histogram weights to null distribution in p-to-stat con…
Browse files Browse the repository at this point in the history
…version (#430)
  • Loading branch information
tsalo authored Dec 31, 2020
1 parent e865c6c commit deb2e92
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions nimare/meta/cbma/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,16 @@ def _p_to_summarystat(self, p, null_method=None):
assert "histogram_bins" in self.null_distributions_.keys()
assert "histogram_weights" in self.null_distributions_.keys()

hist_weights = self.null_distributions_["histogram_weights"]
# Convert unnormalized histogram weights to null distribution
histogram_weights = self.null_distributions_["histogram_weights"]
null_distribution = histogram_weights / np.sum(histogram_weights)
null_distribution = np.cumsum(null_distribution[::-1])[::-1]
null_distribution /= np.max(null_distribution)
null_distribution = np.squeeze(null_distribution)

# Desired bin is the first one _before_ the target p-value (for consistency
# with the empirical null).
ss_idx = np.maximum(0, np.where(hist_weights <= p)[0][0] - 1)
ss_idx = np.maximum(0, np.where(null_distribution <= p)[0][0] - 1)
ss = self.null_distributions_["histogram_bins"][ss_idx]

elif null_method == "empirical":
Expand Down

0 comments on commit deb2e92

Please sign in to comment.