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

update deprecated binom_test #426

Merged
merged 6 commits into from
Mar 27, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"sphinx.ext.autosummary",
"sphinx.ext.viewcode",
"sphinx.ext.mathjax",
"sphinxcontrib.napoleon",
"sphinx_gallery.gen_gallery",
]

Expand Down
10 changes: 6 additions & 4 deletions nltools/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
import pandas as pd
import numpy as np
from nltools.plotting import roc_plot
from scipy.stats import norm, binom_test
from scipy.stats import norm, binomtest
from sklearn.metrics import auc
from copy import deepcopy


class Roc(object):

"""Roc Class

The Roc class is based on Tor Wager's Matlab roc_plot.m function and
Expand Down Expand Up @@ -233,7 +232,7 @@ def calculate(

# Calculate p-Value using binomial test (can add hierarchical version of binomial test)
self.n = len(self.misclass)
self.accuracy_p = binom_test(int(np.sum(~self.misclass)), self.n, p=0.5)
self.accuracy_p = binomtest(int(np.sum(~self.misclass)), self.n, p=0.5)
self.accuracy_se = np.sqrt(
np.mean(~self.misclass) * (np.mean(~self.misclass)) / self.n
)
Expand Down Expand Up @@ -318,7 +317,10 @@ def summary(self):
print("------------------------")
print("{:20s}".format("Accuracy:") + "{:.2f}".format(self.accuracy))
print("{:20s}".format("Accuracy SE:") + "{:.2f}".format(self.accuracy_se))
print("{:20s}".format("Accuracy p-value:") + "{:.2f}".format(self.accuracy_p))
print(
"{:20s}".format("Accuracy p-value:")
+ "{:.2f}".format(self.accuracy_p.pvalue)
)
print("{:20s}".format("Sensitivity:") + "{:.2f}".format(self.sensitivity))
print("{:20s}".format("Specificity:") + "{:.2f}".format(self.specificity))
print("{:20s}".format("AUC:") + "{:.2f}".format(self.auc))
Expand Down
4 changes: 4 additions & 0 deletions nltools/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

@pytest.fixture(scope="module", params=["2mm"])
def sim_brain_data():
np.random.seed(0)
# MNI_Template["resolution"] = request.params
sim = Simulator()
r = 10
Expand All @@ -25,6 +26,7 @@ def sim_brain_data():

@pytest.fixture(scope="module")
def sim_design_matrix():
np.random.seed(0)
# Design matrices are specified in terms of sampling frequency
TR = 2.0
sampling_freq = 1.0 / TR
Expand All @@ -37,6 +39,7 @@ def sim_design_matrix():

@pytest.fixture(scope="module")
def sim_adjacency_single():
np.random.seed(0)
sim = np.random.multivariate_normal(
[0, 0, 0, 0],
[
Expand All @@ -54,6 +57,7 @@ def sim_adjacency_single():

@pytest.fixture(scope="module")
def sim_adjacency_multiple():
np.random.seed(0)
n = 10
sim = np.random.multivariate_normal(
[0, 0, 0, 0],
Expand Down
4 changes: 3 additions & 1 deletion nltools/tests/test_brain_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def test_load(tmpdir):
bb = Brain_Data(
os.path.join(tmpdir.join("test_write.h5")), mask=MNI_Template["mask"]
)
assert bb.mask.get_filename() == MNI_Template["mask"]
assert os.path.abspath(bb.mask.get_filename()) == os.path.abspath(
MNI_Template["mask"]
)


def test_shape(sim_brain_data):
Expand Down
2 changes: 0 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ coveralls
sphinx
sphinx_gallery
sphinx_bootstrap_theme
sphinxcontrib-napoleon

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pandas>=1.1.0
numpy<1.24
seaborn>=0.7.0
matplotlib>=2.2.0
scipy
scipy>=1.7.0
pynv
joblib>=0.15
h5py