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

Clean title #164

Merged
merged 7 commits into from
May 24, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
3 changes: 2 additions & 1 deletion tests/test_tutorials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
36 changes: 27 additions & 9 deletions tutorials/01_methods_create_synthetic_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down Expand 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. "
]
},
{
Expand Down Expand Up @@ -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$"
]
},
{
Expand Down Expand Up @@ -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."
]
},
{
Expand Down Expand Up @@ -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$."
]
},
{
Expand Down Expand Up @@ -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"
]
},
{
Expand Down
19 changes: 12 additions & 7 deletions tutorials/02_methods_estimate_manifold_dimension.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
]
},
{
Expand Down Expand Up @@ -84,6 +88,7 @@
" skdim_dimension_estimation,\n",
")\n",
"\n",
"import torch\n",
"os.environ[\"GEOMSTATS_BACKEND\"] = \"pytorch\"\n",
"import geomstats.backend as gs"
]
Expand Down Expand Up @@ -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])"
]
}
],
Expand Down
Loading