diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 594c578..782d789 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,11 +46,6 @@ jobs: run: | pip install -e .[${{ matrix.flavor }}] - - name: Typecheck [mypy] - run: | - mypy -p neurometry - continue-on-error: true - - name: Run tests [pytest] run: | pytest --cov --cov-report=xml:coverage.xml diff --git a/.gitignore b/.gitignore index ac43064..0346980 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ neurometry/wandb/* neurometry/datasets/rnn_grid_cells/Dual agent path integration high res/* neurometry/datasets/rnn_grid_cells/Single agent path integration high res/* neurometry/curvature/grid-cells-curvature/models/xu_rnn/results/* - +notebooks/ *viewer* *vizcortex* diff --git a/tests/test_tutorials.py b/tests/test_tutorials.py index 664b415..bbb462a 100644 --- a/tests/test_tutorials.py +++ b/tests/test_tutorials.py @@ -24,7 +24,8 @@ def _exec_tutorial(path): TUTORIALS_DIR = "tutorials" -paths = [f"{TUTORIALS_DIR}/01_methods_create_synthetic_data.ipynb"] +paths = [ + f"{TUTORIALS_DIR}/01_methods_create_synthetic_data.ipynb"] @pytest.mark.parametrize("path", paths) diff --git a/tutorials/01_methods_create_synthetic_data.ipynb b/tutorials/01_methods_create_synthetic_data.ipynb index 5697b92..ac71320 100644 --- a/tutorials/01_methods_create_synthetic_data.ipynb +++ b/tutorials/01_methods_create_synthetic_data.ipynb @@ -4,14 +4,16 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Create Synthetic Neural Manifolds" + "# Create Synthetic Neural Manifolds\n", + "\n", + "This notebook explains how to use the module `synthetic` to generate points on neural manifolds in neural state space." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### Set-up + Imports" + "### Set-up" ] }, { @@ -107,11 +109,11 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Plot circle $\\mathcal{S}^1$ and $N=3$ encoding vectors\n", - "\n", + "## Ring $\\mathcal{S}^1$ in Neural State Space $\\mathbb{R}^3$\n", "\n", + "We use $N=3$ encoding vectors to represent the recording of $N=3$ neurons.\n", "\n", - "We will project latent manifold $\\mathcal{S}^1$ (minimal embedding dimension $d=2$) into $N$-dimensional neural state space ($N=3$) with a $d\\times N$ matrix $A$. The entries of $A$ are randomly sampled from a uniform distribution $U[-1,1]$ and its columns are random encoding vectors. " + "We will project the latent manifold $\\mathcal{S}^1$ (minimal embedding dimension $d=2$) into $N$-dimensional neural state space ($N=3$) with a $d\\times N$ matrix $A$. The entries of $A$ are randomly sampled from a uniform distribution $U[-1,1]$ and its columns are random encoding vectors. " ] }, { @@ -19486,7 +19488,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Visualize cylinder ($\\mathcal{S}^1 \\times [0,1]$)" + "## Cylinder ($\\mathcal{S}^1 \\times [0,1]$) in Neural State Space $\\mathbb{R}^3$" ] }, { @@ -23422,7 +23424,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Encode 2-dim Flat torus in $N$-dimensional neural state space (N=3)." + "## Flat torus $\\mathcal{T}^2$ in Neural State Space $\\mathbb{R}^3$" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We propose to encode the 2-dimensional flat torus in $N$-dimensional neural state space, where $N = 3$ neurons." ] }, { @@ -27372,7 +27381,16 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Extrinsic dimension of curved low-dim manifold" + "## Estimate Extrinsic Dimension of Neural Manifold" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Here, we use `skdim` to estimate the extrinsic dimension of a ring (circle) manifold embedded in neural state space $\\mathbb{R}^N$ where the number of neurons $N$ can vary.\n", + "\n", + "We observe whether the estimated extrinsic dimension varies with $N$." ] }, { @@ -43358,7 +43376,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Synthetic neural activity encoding Van der Pol Oscillator" + "## Synthetic Neural Activity Encoding: Van der Pol Oscillator" ] }, { diff --git a/tutorials/02_methods_estimate_manifold_dimension.ipynb b/tutorials/02_methods_estimate_manifold_dimension.ipynb index ae78412..6f40994 100644 --- a/tutorials/02_methods_estimate_manifold_dimension.ipynb +++ b/tutorials/02_methods_estimate_manifold_dimension.ipynb @@ -4,7 +4,11 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Estimate Neural Dimensions" + "# Estimate Neural Dimensions\n", + "\n", + "This notebook explains how to use the module `dimension` to estimate the dimension (extrinsic or intrinsic) of the neural manifold embedded in neural state space $\\mathbb{R}^N$.\n", + "\n", + "In particular, this notebook tests several existing methods of dimension estimation on the synthetic manifolds from the module `datasets.synthetic` to evaluate their performance." ] }, { @@ -84,6 +88,7 @@ " skdim_dimension_estimation,\n", ")\n", "\n", + "import torch\n", "os.environ[\"GEOMSTATS_BACKEND\"] = \"pytorch\"\n", "import geomstats.backend as gs" ] @@ -4812,17 +4817,17 @@ } ], "source": [ - "n_components = 4\n", + "# n_components = 4\n", "\n", - "X_pls = pls_transformed_X[n_components - 1]\n", + "# X_pls = pls_transformed_X[n_components - 1]\n", "\n", - "X_pca = pca_transformed_X[n_components - 1]\n", + "# X_pca = pca_transformed_X[n_components - 1]\n", "\n", - "from gtda.homology import WeakAlphaPersistence\n", + "# from gtda.homology import WeakAlphaPersistence\n", "\n", - "wa_pers = WeakAlphaPersistence(homology_dimensions=(0, 1, 2))\n", + "# wa_pers = WeakAlphaPersistence(homology_dimensions=(0, 1, 2))\n", "\n", - "diagrams_wa_pers = wa_pers.fit_transform([X_pca, X_pls])" + "# diagrams_wa_pers = wa_pers.fit_transform([X_pca, X_pls])" ] } ],