From 65951296b8fd71289e02f275aeed177d259a0fb2 Mon Sep 17 00:00:00 2001 From: ljchang Date: Mon, 5 Feb 2024 14:59:50 -0500 Subject: [PATCH 1/6] updated deprecated function name --- nltools/analysis.py | 5 ++--- requirements.txt | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/nltools/analysis.py b/nltools/analysis.py index 5f0684e8..08ff8884 100644 --- a/nltools/analysis.py +++ b/nltools/analysis.py @@ -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 @@ -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 ) diff --git a/requirements.txt b/requirements.txt index 1de2e090..34cdb4c2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 From f5b471954fbeaed700e426c64e105367847a1ac9 Mon Sep 17 00:00:00 2001 From: ejolly Date: Tue, 26 Mar 2024 16:51:38 -0400 Subject: [PATCH 2/6] fix roc print output --- nltools/analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nltools/analysis.py b/nltools/analysis.py index 08ff8884..f7bd16a7 100644 --- a/nltools/analysis.py +++ b/nltools/analysis.py @@ -317,7 +317,7 @@ 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)) From 081c4e3e867307ca88a9e55d2b9020b091b0f6d5 Mon Sep 17 00:00:00 2001 From: ejolly Date: Tue, 26 Mar 2024 20:02:04 -0400 Subject: [PATCH 3/6] fix roc print output --- nltools/analysis.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nltools/analysis.py b/nltools/analysis.py index f7bd16a7..056ec975 100644 --- a/nltools/analysis.py +++ b/nltools/analysis.py @@ -317,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.pvalue)) + 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)) From 81fbe4e2a8ce6ac34da035b6a9241e8963d5e00a Mon Sep 17 00:00:00 2001 From: ejolly Date: Wed, 27 Mar 2024 15:52:10 -0400 Subject: [PATCH 4/6] fix path check test on windows --- nltools/tests/test_brain_data.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nltools/tests/test_brain_data.py b/nltools/tests/test_brain_data.py index c93dc794..2a682612 100644 --- a/nltools/tests/test_brain_data.py +++ b/nltools/tests/test_brain_data.py @@ -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): From 468fe424d57b82e7bfc52bbbb43575cfaf4b2598 Mon Sep 17 00:00:00 2001 From: ejolly Date: Wed, 27 Mar 2024 16:10:19 -0400 Subject: [PATCH 5/6] Remove sphinx napoleon as it's included with sphinx now --- docs/conf.py | 1 - requirements-dev.txt | 2 -- 2 files changed, 3 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 200b6499..d5199b32 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -44,7 +44,6 @@ "sphinx.ext.autosummary", "sphinx.ext.viewcode", "sphinx.ext.mathjax", - "sphinxcontrib.napoleon", "sphinx_gallery.gen_gallery", ] diff --git a/requirements-dev.txt b/requirements-dev.txt index e9c977d7..422e0f63 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -6,5 +6,3 @@ coveralls sphinx sphinx_gallery sphinx_bootstrap_theme -sphinxcontrib-napoleon - From 38368671be75fc50492f92a20c63b43ab9fb1861 Mon Sep 17 00:00:00 2001 From: ejolly Date: Wed, 27 Mar 2024 16:17:47 -0400 Subject: [PATCH 6/6] Fix random seeds for reproducible testing --- nltools/tests/conftest.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nltools/tests/conftest.py b/nltools/tests/conftest.py index 92c0cb5b..66a479d5 100644 --- a/nltools/tests/conftest.py +++ b/nltools/tests/conftest.py @@ -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 @@ -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 @@ -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], [ @@ -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],