Skip to content

Commit

Permalink
rat_example
Browse files Browse the repository at this point in the history
  • Loading branch information
agosztolai committed May 21, 2024
1 parent 23efcbb commit 20038f4
Show file tree
Hide file tree
Showing 5 changed files with 3,018 additions and 324 deletions.
1,660 changes: 1,660 additions & 0 deletions examples/rat_hippocampus/decoding.ipynb

Large diffs are not rendered by default.

108 changes: 41 additions & 67 deletions examples/rat_hippocampus/multianimal_consistency.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,71 +22,30 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: cebra in /home/robert/anaconda3/lib/python3.9/site-packages (0.3.0)\n",
"Requirement already satisfied: joblib in /home/robert/anaconda3/lib/python3.9/site-packages (from cebra) (1.2.0)\n",
"Requirement already satisfied: literate-dataclasses in /home/robert/anaconda3/lib/python3.9/site-packages (from cebra) (0.0.6)\n",
"Requirement already satisfied: scikit-learn in /home/robert/anaconda3/lib/python3.9/site-packages (from cebra) (1.2.2)\n",
"Requirement already satisfied: scipy in /home/robert/anaconda3/lib/python3.9/site-packages (from cebra) (1.12.0)\n",
"Requirement already satisfied: torch in /home/robert/anaconda3/lib/python3.9/site-packages (from cebra) (2.2.0)\n",
"Requirement already satisfied: tqdm in /home/robert/anaconda3/lib/python3.9/site-packages (from cebra) (4.65.0)\n",
"Requirement already satisfied: matplotlib in /home/robert/anaconda3/lib/python3.9/site-packages (from cebra) (3.7.1)\n",
"Requirement already satisfied: requests in /home/robert/anaconda3/lib/python3.9/site-packages (from cebra) (2.28.1)\n",
"Requirement already satisfied: contourpy>=1.0.1 in /home/robert/anaconda3/lib/python3.9/site-packages (from matplotlib->cebra) (1.0.7)\n",
"Requirement already satisfied: cycler>=0.10 in /home/robert/anaconda3/lib/python3.9/site-packages (from matplotlib->cebra) (0.11.0)\n",
"Requirement already satisfied: fonttools>=4.22.0 in /home/robert/anaconda3/lib/python3.9/site-packages (from matplotlib->cebra) (4.39.3)\n",
"Requirement already satisfied: kiwisolver>=1.0.1 in /home/robert/anaconda3/lib/python3.9/site-packages (from matplotlib->cebra) (1.4.4)\n",
"Requirement already satisfied: numpy>=1.20 in /home/robert/anaconda3/lib/python3.9/site-packages (from matplotlib->cebra) (1.23.5)\n",
"Requirement already satisfied: packaging>=20.0 in /home/robert/anaconda3/lib/python3.9/site-packages (from matplotlib->cebra) (23.1)\n",
"Requirement already satisfied: pillow>=6.2.0 in /home/robert/anaconda3/lib/python3.9/site-packages (from matplotlib->cebra) (9.5.0)\n",
"Requirement already satisfied: pyparsing>=2.3.1 in /home/robert/anaconda3/lib/python3.9/site-packages (from matplotlib->cebra) (3.0.9)\n",
"Requirement already satisfied: python-dateutil>=2.7 in /home/robert/anaconda3/lib/python3.9/site-packages (from matplotlib->cebra) (2.8.2)\n",
"Requirement already satisfied: importlib-resources>=3.2.0 in /home/robert/anaconda3/lib/python3.9/site-packages (from matplotlib->cebra) (5.12.0)\n",
"Requirement already satisfied: charset-normalizer<3,>=2 in /home/robert/anaconda3/lib/python3.9/site-packages (from requests->cebra) (2.0.4)\n",
"Requirement already satisfied: idna<4,>=2.5 in /home/robert/anaconda3/lib/python3.9/site-packages (from requests->cebra) (3.4)\n",
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/robert/anaconda3/lib/python3.9/site-packages (from requests->cebra) (1.26.14)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /home/robert/anaconda3/lib/python3.9/site-packages (from requests->cebra) (2022.12.7)\n",
"Requirement already satisfied: threadpoolctl>=2.0.0 in /home/robert/anaconda3/lib/python3.9/site-packages (from scikit-learn->cebra) (3.1.0)\n",
"Requirement already satisfied: filelock in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (3.9.0)\n",
"Requirement already satisfied: typing-extensions>=4.8.0 in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (4.9.0)\n",
"Requirement already satisfied: sympy in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (1.10.1)\n",
"Requirement already satisfied: networkx in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (3.1)\n",
"Requirement already satisfied: jinja2 in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (3.1.2)\n",
"Requirement already satisfied: fsspec in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (2024.2.0)\n",
"Requirement already satisfied: nvidia-cuda-nvrtc-cu12==12.1.105 in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (12.1.105)\n",
"Requirement already satisfied: nvidia-cuda-runtime-cu12==12.1.105 in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (12.1.105)\n",
"Requirement already satisfied: nvidia-cuda-cupti-cu12==12.1.105 in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (12.1.105)\n",
"Requirement already satisfied: nvidia-cudnn-cu12==8.9.2.26 in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (8.9.2.26)\n",
"Requirement already satisfied: nvidia-cublas-cu12==12.1.3.1 in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (12.1.3.1)\n",
"Requirement already satisfied: nvidia-cufft-cu12==11.0.2.54 in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (11.0.2.54)\n",
"Requirement already satisfied: nvidia-curand-cu12==10.3.2.106 in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (10.3.2.106)\n",
"Requirement already satisfied: nvidia-cusolver-cu12==11.4.5.107 in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (11.4.5.107)\n",
"Requirement already satisfied: nvidia-cusparse-cu12==12.1.0.106 in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (12.1.0.106)\n",
"Requirement already satisfied: nvidia-nccl-cu12==2.19.3 in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (2.19.3)\n",
"Requirement already satisfied: nvidia-nvtx-cu12==12.1.105 in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (12.1.105)\n",
"Requirement already satisfied: triton==2.2.0 in /home/robert/anaconda3/lib/python3.9/site-packages (from torch->cebra) (2.2.0)\n",
"Requirement already satisfied: nvidia-nvjitlink-cu12 in /home/robert/anaconda3/lib/python3.9/site-packages (from nvidia-cusolver-cu12==11.4.5.107->torch->cebra) (12.3.101)\n",
"Requirement already satisfied: zipp>=3.1.0 in /home/robert/anaconda3/lib/python3.9/site-packages (from importlib-resources>=3.2.0->matplotlib->cebra) (3.11.0)\n",
"Requirement already satisfied: six>=1.5 in /home/robert/anaconda3/lib/python3.9/site-packages (from python-dateutil>=2.7->matplotlib->cebra) (1.16.0)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /home/robert/anaconda3/lib/python3.9/site-packages (from jinja2->torch->cebra) (2.1.1)\n",
"Requirement already satisfied: mpmath>=0.19 in /home/robert/anaconda3/lib/python3.9/site-packages (from sympy->torch->cebra) (1.2.1)\n",
"\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.0\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-05-02 08:11:55.834014: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT\n",
"/home/robert/anaconda3/lib/python3.9/site-packages/umap/distances.py:1063: NumbaDeprecationWarning: \u001b[1mThe 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.\u001b[0m\n",
" @numba.jit()\n",
"/home/robert/anaconda3/lib/python3.9/site-packages/umap/distances.py:1071: NumbaDeprecationWarning: \u001b[1mThe 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.\u001b[0m\n",
" @numba.jit()\n",
"/home/robert/anaconda3/lib/python3.9/site-packages/umap/distances.py:1086: NumbaDeprecationWarning: \u001b[1mThe 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.\u001b[0m\n",
" @numba.jit()\n",
"/home/robert/anaconda3/lib/python3.9/site-packages/umap/umap_.py:660: NumbaDeprecationWarning: \u001b[1mThe 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.\u001b[0m\n",
" @numba.jit()\n"
"Requirement already satisfied: cebra in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (0.4.0)\n",
"Requirement already satisfied: joblib in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from cebra) (1.1.0)\n",
"Requirement already satisfied: torch in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from cebra) (1.12.1)\n",
"Requirement already satisfied: requests in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from cebra) (2.28.1)\n",
"Requirement already satisfied: tqdm in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from cebra) (4.64.1)\n",
"Requirement already satisfied: literate-dataclasses in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from cebra) (0.0.6)\n",
"Requirement already satisfied: matplotlib in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from cebra) (3.5.2)\n",
"Requirement already satisfied: scikit-learn in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from cebra) (1.1.2)\n",
"Requirement already satisfied: scipy in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from cebra) (1.13.0)\n",
"Requirement already satisfied: fonttools>=4.22.0 in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from matplotlib->cebra) (4.25.0)\n",
"Requirement already satisfied: cycler>=0.10 in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from matplotlib->cebra) (0.11.0)\n",
"Requirement already satisfied: pillow>=6.2.0 in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from matplotlib->cebra) (9.2.0)\n",
"Requirement already satisfied: packaging>=20.0 in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from matplotlib->cebra) (21.3)\n",
"Requirement already satisfied: python-dateutil>=2.7 in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from matplotlib->cebra) (2.8.2)\n",
"Requirement already satisfied: pyparsing>=2.2.1 in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from matplotlib->cebra) (3.0.9)\n",
"Requirement already satisfied: numpy>=1.17 in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from matplotlib->cebra) (1.23.3)\n",
"Requirement already satisfied: kiwisolver>=1.0.1 in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from matplotlib->cebra) (1.4.2)\n",
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from requests->cebra) (1.26.11)\n",
"Requirement already satisfied: charset-normalizer<3,>=2 in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from requests->cebra) (2.0.4)\n",
"Requirement already satisfied: idna<4,>=2.5 in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from requests->cebra) (3.4)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from requests->cebra) (2023.11.17)\n",
"Requirement already satisfied: threadpoolctl>=2.0.0 in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from scikit-learn->cebra) (2.2.0)\n",
"Requirement already satisfied: typing_extensions in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from torch->cebra) (4.3.0)\n",
"Requirement already satisfied: six>=1.5 in /mnt/scratch/lts2/gosztolai/miniconda3/envs/MARBLE/lib/python3.9/site-packages (from python-dateutil>=2.7->matplotlib->cebra) (1.16.0)\n"
]
}
],
Expand Down Expand Up @@ -121,7 +80,22 @@
"name": "stdout",
"output_type": "stream",
"text": [
"File ‘rat_data.pkl’ already there; not retrieving.\r\n"
"--2024-05-16 11:16:07-- https://dataverse.harvard.edu/api/access/datafile/7609512\n",
"Resolving dataverse.harvard.edu (dataverse.harvard.edu)... 34.202.108.237, 54.208.155.175, 52.44.148.164\n",
"Connecting to dataverse.harvard.edu (dataverse.harvard.edu)|34.202.108.237|:443... connected.\n",
"HTTP request sent, awaiting response... 303 See Other\n",
"Location: https://dvn-cloud.s3.amazonaws.com/10.7910/DVN/KTE4PC/18c1046ee1a-ed164613d7ea?response-content-disposition=attachment%3B%20filename%2A%3DUTF-8%27%27rat_data.pkl&response-content-type=application%2Foctet-stream&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20240516T091608Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=AKIAIEJ3NV7UYCSRJC7A%2F20240516%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=4cff93594c20ece8b7533170399be94b70067705001959ecefeb98b2299fa604 [following]\n",
"--2024-05-16 11:16:08-- https://dvn-cloud.s3.amazonaws.com/10.7910/DVN/KTE4PC/18c1046ee1a-ed164613d7ea?response-content-disposition=attachment%3B%20filename%2A%3DUTF-8%27%27rat_data.pkl&response-content-type=application%2Foctet-stream&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20240516T091608Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=AKIAIEJ3NV7UYCSRJC7A%2F20240516%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=4cff93594c20ece8b7533170399be94b70067705001959ecefeb98b2299fa604\n",
"Resolving dvn-cloud.s3.amazonaws.com (dvn-cloud.s3.amazonaws.com)... 52.216.214.65, 52.216.209.225, 3.5.27.166, ...\n",
"Connecting to dvn-cloud.s3.amazonaws.com (dvn-cloud.s3.amazonaws.com)|52.216.214.65|:443... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 22055089 (21M) [application/octet-stream]\n",
"Saving to: ‘data/rat_data.pkl’\n",
"\n",
"data/rat_data.pkl 100%[===================>] 21.03M 1.40MB/s in 21s \n",
"\n",
"2024-05-16 11:16:30 (1005 KB/s) - ‘data/rat_data.pkl’ saved [22055089/22055089]\n",
"\n"
]
}
],
Expand All @@ -142,7 +116,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand Down
3 changes: 1 addition & 2 deletions examples/rat_hippocampus/rat_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ def prepare_marble(spikes,
frac_geodesic_nb=1,
kernel_width=10,):

s_interval = 1

if spiking_rates:
gk = GaussianKernel(kernel_width * ms)
rates = []
for sp in spikes:
sp_times = np.where(sp)[0]
st = neo.SpikeTrain(sp_times, units="ms", t_stop=len(sp))
r = instantaneous_rate(st, kernel=gk, sampling_period=s_interval * ms).magnitude
r = instantaneous_rate(st, kernel=gk, sampling_period=1. * ms).magnitude
rates.append(r.T)

rates = np.vstack(rates)
Expand Down
Loading

0 comments on commit 20038f4

Please sign in to comment.