From 647a0a172a2369fc34bfe05cdcb889508e2ea5b0 Mon Sep 17 00:00:00 2001 From: timonmerk Date: Fri, 1 Nov 2024 17:39:18 +0100 Subject: [PATCH] Fix RMAP and stats dependencies --- README.rst | 2 ++ docs/source/contributing.rst | 20 +++++++++++++------- py_neuromodulation/analysis/RMAP.py | 6 +++--- py_neuromodulation/analysis/stats.py | 6 +++--- pyproject.toml | 1 + 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/README.rst b/README.rst index 2da2f059..eee10892 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,8 @@ py_neuromodulation ================== +Documentation: https://neuromodulation.github.io/py_neuromodulation/ + Analyzing neural data can be a troublesome, trial and error prone, and beginner unfriendly process. *py_neuromodulation* allows using a simple interface for extraction of established neurophysiological features and includes commonly applied pre -and postprocessing methods. diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 6fcb3ce6..ad313bb1 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -7,30 +7,36 @@ In general we recommend placing questions and issues in the `GitHub issue tracke For code formatting we use `ruff `_. -For code development, we recommend using the package manager `rye `_. +For code development, we recommend using the package manager `uv `_. To setup the python environment, type :: - rye pin 3.12 + uv python install 3.11 + uv venv -then sync the environment with + +Depending on your operating system, activate the rye virtual environment: :: - rye sync + . .venv/bin/activate -Depending on your operating system, activate the rye virtual environment: +And install the pyproject.toml dependencies: + +:: + + then sync the environment with :: - . .venv/bin/activate + uv sync To install the documentation dependencies use pip: :: - python -m pip install .[docs] + uv pip install -e .[docs] diff --git a/py_neuromodulation/analysis/RMAP.py b/py_neuromodulation/analysis/RMAP.py index 1085aced..adc5e3a1 100644 --- a/py_neuromodulation/analysis/RMAP.py +++ b/py_neuromodulation/analysis/RMAP.py @@ -8,8 +8,8 @@ import nibabel as nib from matplotlib import pyplot as plt -from py_neuromodulation.plots import reg_plot -from py_neuromodulation.types import _PathLike +from py_neuromodulation.analysis import reg_plot +from py_neuromodulation.utils.types import _PathLike from py_neuromodulation import PYNM_DIR LIST_STRUC_UNCONNECTED_GRIDPOINTS_HULL = [256, 385, 417, 447, 819, 914] @@ -335,7 +335,7 @@ def save_Nii( reshape: bool = True, ): if reshape: - fp = np.reshape(fp, (91, 109, 91), order="F") + fp = np.reshape(fp, (91, 109, 91), order="C") img = nib.nifti1.Nifti1Image(fp, affine=affine) diff --git a/py_neuromodulation/analysis/stats.py b/py_neuromodulation/analysis/stats.py index 83afe3ec..dd298c5f 100644 --- a/py_neuromodulation/analysis/stats.py +++ b/py_neuromodulation/analysis/stats.py @@ -6,7 +6,7 @@ # from numba import njit import numpy as np import pandas as pd -import scipy.stats as stats +import scipy.stats as scipy_stats def fitlm_kfold(x, y, kfold_splits=5): @@ -51,7 +51,7 @@ def permutationTestSpearmansRho(x, y, plot_distr=True, x_unit=None, p=5000): """ # compute ground truth difference - gT = stats.spearmanr(x, y)[0] + gT = scipy_stats.spearmanr(x, y)[0] # pV = np.array((x, y)) # Initialize permutation: @@ -65,7 +65,7 @@ def permutationTestSpearmansRho(x, y, plot_distr=True, x_unit=None, p=5000): random.shuffle(args_order_2) # Compute permuted absolute difference of your two sampled # distributions and store it in pD: - pD.append(stats.spearmanr(pV[0, args_order], pV[1, args_order_2])[0]) + pD.append(scipy_stats.spearmanr(pV[0, args_order], pV[1, args_order_2])[0]) # calculate p value if gT < 0: diff --git a/pyproject.toml b/pyproject.toml index f403b3f3..14adf15a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,6 +51,7 @@ dependencies = [ "seaborn >= 0.11", "llvmlite>=0.43.0", "numba>=0.60.0", + "nibabel>=5.3.2", ] [project.optional-dependencies]