Sometimes p-values are not clipped correctly with montecarlo simulations
In the function `null_to_p`, sometimes this line:
https://github.com/neurostuff/NiMARE/blob/db6347569309d580fcd51e044da764bb9b1286ea/nimare/stats.py#L144

can evaluate to a percentile that is less than the lower bound of p-values, (e.g., if the null array is 100 items making the minimum p-value 0.01 and if there are repeat values in the null_array like (1, 1, 1, 2, ..., 5, 5, 6), the percentile can be under 0.01 without being zero, which becomes a problem in this line:
https://github.com/neurostuff/NiMARE/blob/db6347569309d580fcd51e044da764bb9b1286ea/nimare/stats.py#L151-L152

resulting in some instances where the returned p-value is outside the expected range (0.01 - 0.99).

I'll submit a fix.
diff --git a/nimare/stats.py b/nimare/stats.py
index 45c87e3..f28a296 100755
--- a/nimare/stats.py
+++ b/nimare/stats.py
@@ -148,10 +148,10 @@ def null_to_p(test_value, null_array, tail="two"):
         raise ValueError('Argument "tail" must be one of ["two", "upper", ' '"lower"]')
 
     smallest_value = np.maximum(np.finfo(float).eps, 1.0 / len(null_array))
-    if p_value == 0:
-        p_value = smallest_value
-    elif p_value == 1:
-        p_value = 1.0 - smallest_value
+
+    # ensure p_value in the following range:
+    # smallest_value <= p_value <= (1.0 - smallest_value)
+    p_value = max(smallest_value, min(p_value, 1.0 - smallest_value))
 
     return p_value
 
diff --git a/nimare/tests/test_stats.py b/nimare/tests/test_stats.py
index 54d34e0..249ab0e 100644
--- a/nimare/tests/test_stats.py
+++ b/nimare/tests/test_stats.py
@@ -25,3 +25,11 @@ def test_null_to_p():
     assert math.isclose(stats.null_to_p(101, data, "lower"), 0.99)
     assert math.isclose(stats.null_to_p(101, data, "upper"), 0.01)
     assert math.isclose(stats.null_to_p(101, data, "two"), 0.01)
+
+    # modify data to handle edge case
+    data[98] = 100
+    assert math.isclose(stats.null_to_p(1, data, "lower"), 0.01)
+    assert math.isclose(stats.null_to_p(1, data, "upper"), 0.99)
+    assert math.isclose(stats.null_to_p(100, data, "lower"), 0.99)
+    assert math.isclose(stats.null_to_p(100, data, "upper"), 0.01)
+    assert math.isclose(stats.null_to_p(100, data, "two"), 0.01)
['nimare/tests/test_stats.py', 'nimare/stats.py']