Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Do not zero out one-tailed z-statistics for p-values > 0.5" #769

Merged
merged 3 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/outputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ Some of the values found in NiMARE include:
- ``tau2``: Estimated between-study variance (IBMA only)
- ``sigma2``: Estimated within-study variance (IBMA only)

.. note::
For one-sided tests, p-values > 0.5 will have negative z-statistics. These values should not
be confused with significant negative results. As a result, in NiMARE, these values are
replaced by 0.

Next, a series of key/value pairs describe the methods applied to generate the map.

- ``desc``: Description of the data type. Only used when multiple maps with the same data type are produced by the same method.
Expand Down
11 changes: 4 additions & 7 deletions nimare/tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def test_ddimages_to_coordinates_merge_strategy(testdata_ibma):


@pytest.mark.parametrize(
"expected_z,tail,expected_p",
"z,tail,expected_p",
[
(0.0, "two", 1.0),
(0.0, "one", 0.5),
Expand All @@ -256,13 +256,10 @@ def test_ddimages_to_coordinates_merge_strategy(testdata_ibma):
(-1.959963, "one", 0.975),
(-1.959963, "two", 0.05),
([0.0, 1.959963, -1.959963], "two", [1.0, 0.05, 0.05]),
([0.0, 1.959963, -1.959963], "one", [0.5, 0.025, 0.975]),
],
)
def test_z_to_p(expected_z, tail, expected_p):
"""Test z to p, and p to z conversion."""
p = transforms.z_to_p(expected_z, tail)
z = transforms.p_to_z(expected_p, tail) * np.sign(expected_z)
def test_z_to_p(z, tail, expected_p):
"""Test z to p conversion."""
p = transforms.z_to_p(z, tail)

assert np.all(np.isclose(p, expected_p))
assert np.all(np.isclose(z, expected_z))
7 changes: 3 additions & 4 deletions nimare/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,13 +678,12 @@ def p_to_z(p, tail="two"):
Z-statistics (unsigned)
"""
p = np.array(p)

# Ensure that no p-values are converted to Inf/NaNs
p = np.clip(p, 1.0e-300, 1.0 - 1.0e-16)
if tail == "two":
z = stats.norm.isf(p / 2)
elif tail == "one":
z = np.abs(stats.norm.isf(p))
z = stats.norm.isf(p)
z = np.array(z)
z[z < 0] = 0
else:
raise ValueError('Argument "tail" must be one of ["one", "two"]')

Expand Down