Skip to content

Commit

Permalink
move pynapple seaborn install to start of notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
stephprince committed Apr 12, 2024
1 parent bd72c99 commit a10bde9
Showing 1 changed file with 20 additions and 72 deletions.
92 changes: 20 additions & 72 deletions Workshop_2024_BCM/houston-analysis-demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"source": [
"First, let's import a few classes. If you are *not* running this notebook on DANDI Hub, you will need to install these packages using `pip` or your favorite Python package manager. For example:\n",
"```\n",
"pip install dandi pynwb fsspec requests aiohttp matplotlib\n",
"pip install dandi pynwb fsspec requests aiohttp matplotlib pynapple seaborn\n",
"```"
]
},
Expand Down Expand Up @@ -85,7 +85,7 @@
"id": "91a4a7b1-3f61-4f04-9df0-5a8b7d2642c2",
"metadata": {},
"source": [
"There are multiple methods to stream data from NWB files. We currently recommend fsspec, but additional options are described in the [pynwb streaming tutorial](https://pynwb.readthedocs.io/en/stable/tutorials/advanced_io/streaming.html)."
"There are multiple methods to stream NWB files. We currently recommend fsspec, but additional options are described in the [pynwb streaming tutorial](https://pynwb.readthedocs.io/en/stable/tutorials/advanced_io/streaming.html)."
]
},
{
Expand Down Expand Up @@ -188,7 +188,7 @@
" <tr>\n",
" <th>0</th>\n",
" <td>MEC</td>\n",
" <td>ElectrodeGroup pynwb.ecephys.ElectrodeGroup at 0x5313095072\\nFields:\\n description: The name of the ElectrodeGroup this electrode is a part of.\\n device: EEG pynwb.device.Device at 0x5313095312\\nFields:\\n description: The device used to record EEG signals.\\n\\n location: MEC\\n</td>\n",
" <td>ElectrodeGroup pynwb.ecephys.ElectrodeGroup at 0x6080627152\\nFields:\\n description: The name of the ElectrodeGroup this electrode is a part of.\\n device: EEG pynwb.device.Device at 0x6080626864\\nFields:\\n description: The device used to record EEG signals.\\n\\n location: MEC\\n</td>\n",
" <td>ElectrodeGroup</td>\n",
" </tr>\n",
" </tbody>\n",
Expand All @@ -211,7 +211,7 @@
" <tr>\n",
" <th>0</th>\n",
" <td>MEC</td>\n",
" <td>ElectrodeGroup pynwb.ecephys.ElectrodeGroup at 0x5313095072\\nFields:\\n description: The name of the ElectrodeGroup this electrode is a part of.\\n device: EEG pynwb.device.Device at 0x5313095312\\nFields:\\n description: The device used to record EEG signals.\\n\\n location: MEC\\n</td>\n",
" <td>ElectrodeGroup pynwb.ecephys.ElectrodeGroup at 0x6080627152\\nFields:\\n description: The name of the ElectrodeGroup this electrode is a part of.\\n device: EEG pynwb.device.Device at 0x6080626864\\nFields:\\n description: The device used to record EEG signals.\\n\\n location: MEC\\n</td>\n",
" <td>ElectrodeGroup</td>\n",
" </tr>\n",
" </tbody>\n",
Expand All @@ -234,7 +234,7 @@
" <tr>\n",
" <th>0</th>\n",
" <td>MEC</td>\n",
" <td>ElectrodeGroup pynwb.ecephys.ElectrodeGroup at 0x5313095072\\nFields:\\n description: The name of the ElectrodeGroup this electrode is a part of.\\n device: EEG pynwb.device.Device at 0x5313095312\\nFields:\\n description: The device used to record EEG signals.\\n\\n location: MEC\\n</td>\n",
" <td>ElectrodeGroup pynwb.ecephys.ElectrodeGroup at 0x6080627152\\nFields:\\n description: The name of the ElectrodeGroup this electrode is a part of.\\n device: EEG pynwb.device.Device at 0x6080626864\\nFields:\\n description: The device used to record EEG signals.\\n\\n location: MEC\\n</td>\n",
" <td>ElectrodeGroup</td>\n",
" </tr>\n",
" </tbody>\n",
Expand Down Expand Up @@ -294,7 +294,7 @@
"</table><p>... and 4 more rows.</p></details></details><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".experiment_description\">experiment_description: </span><span class=\"field-value\">The sample includes conjunctive cells and head direction cells from layers III and V of medial entorhinal cortex and have been published in Sargolini et al. (Science, 2006).</span></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".session_id\">session_id: </span><span class=\"field-value\">17010302</span></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".lab\">lab: </span><span class=\"field-value\">Moser</span></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".institution\">institution: </span><span class=\"field-value\">Centre for the Biology of Memory, Norwegian University of Science and Technology</span></div></div>"
],
"text/plain": [
"root pynwb.file.NWBFile at 0x5311550752\n",
"root pynwb.file.NWBFile at 0x6062620448\n",
"Fields:\n",
" acquisition: {\n",
" ElectricalSeries <class 'pynwb.ecephys.ElectricalSeries'>\n",
Expand All @@ -321,7 +321,7 @@
" session_description: This session includes spike and position times for recorded cells from a Long Evans rat that was running in a 1 x 1 meter enclosure. The cells were recorded in the dorsocaudal 25% portion of the medial entorhinal cortex (MEC).Position is given for two LEDs to enable calculation of head direction.\n",
" session_id: 17010302\n",
" session_start_time: 1900-01-01 00:00:00+01:00\n",
" subject: subject pynwb.file.Subject at 0x5312899136\n",
" subject: subject pynwb.file.Subject at 0x6051471456\n",
"Fields:\n",
" age: P3M/P5M\n",
" age__reference: birth\n",
Expand Down Expand Up @@ -400,7 +400,7 @@
" <div class='container-wrap'><div class='container-header'><div class='xr-obj-type'><h3>subject (Subject)</h3></div></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".age\">age: </span><span class=\"field-value\">P3M/P5M</span></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".age__reference\">age__reference: </span><span class=\"field-value\">birth</span></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".description\">description: </span><span class=\"field-value\">A Long Evans rat.</span></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".sex\">sex: </span><span class=\"field-value\">M</span></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".species\">species: </span><span class=\"field-value\">Rattus norvegicus</span></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".subject_id\">subject_id: </span><span class=\"field-value\">10073</span></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".weight\">weight: </span><span class=\"field-value\">0.35/0.45</span></div></div>"
],
"text/plain": [
"subject pynwb.file.Subject at 0x5312899136\n",
"subject pynwb.file.Subject at 0x6051471456\n",
"Fields:\n",
" age: P3M/P5M\n",
" age__reference: birth\n",
Expand Down Expand Up @@ -476,7 +476,7 @@
" <div class='container-wrap'><div class='container-header'><div class='xr-obj-type'><h3>SpatialSeriesLED1 (SpatialSeries)</h3></div></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".resolution\">resolution: </span><span class=\"field-value\">-1.0</span></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".comments\">comments: </span><span class=\"field-value\">no comments</span></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".description\">description: </span><span class=\"field-value\">Position (x, y) for the first tracking LED.</span></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".conversion\">conversion: </span><span class=\"field-value\">0.01</span></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".offset\">offset: </span><span class=\"field-value\">0.0</span></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".unit\">unit: </span><span class=\"field-value\">meters</span></div><details><summary style=\"display: list-item; margin-left: 0px;\" class=\"container-fields field-key\" title=\".data\"><b>data</b></summary></details><details><summary style=\"display: list-item; margin-left: 0px;\" class=\"container-fields field-key\" title=\".timestamps\"><b>timestamps</b></summary></details><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".timestamps_unit\">timestamps_unit: </span><span class=\"field-value\">seconds</span></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".interval\">interval: </span><span class=\"field-value\">1</span></div><div style=\"margin-left: 0px;\" class=\"container-fields\"><span class=\"field-key\" title=\".reference_frame\">reference_frame: </span><span class=\"field-value\">(0,0) is not known.</span></div></div>"
],
"text/plain": [
"SpatialSeriesLED1 pynwb.behavior.SpatialSeries at 0x5309434624\n",
"SpatialSeriesLED1 pynwb.behavior.SpatialSeries at 0x6058780640\n",
"Fields:\n",
" comments: no comments\n",
" conversion: 0.01\n",
Expand Down Expand Up @@ -804,7 +804,7 @@
"</table><p>... and 4 more rows.</p></details></div>"
],
"text/plain": [
"units pynwb.misc.Units at 0x5313096848\n",
"units pynwb.misc.Units at 0x6062849200\n",
"Fields:\n",
" colnames: ['unit_name' 'spike_times' 'histology' 'hemisphere' 'depth']\n",
" columns: (\n",
Expand Down Expand Up @@ -1086,59 +1086,7 @@
"id": "1eb0cc7d-87cb-4919-a4d7-b7478614477e",
"metadata": {},
"source": [
"[Pynapple](https://pynapple-org.github.io/pynapple/) is a light-weight python library for neurophysiological data analysis that accepts NWB files as input. Let's install pynapple and a plotting package, seaborn, using `pip`."
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "a758f310-dc9b-41b8-8abd-7abd3b5d8558",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: pynapple in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (0.6.1)\n",
"Requirement already satisfied: seaborn in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (0.13.2)\n",
"Requirement already satisfied: pandas>1.0.3 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from pynapple) (2.2.1)\n",
"Requirement already satisfied: numpy>=1.17.4 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from pynapple) (1.26.4)\n",
"Requirement already satisfied: scipy>=1.3.2 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from pynapple) (1.13.0)\n",
"Requirement already satisfied: numba>=0.46.0 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from pynapple) (0.59.1)\n",
"Requirement already satisfied: pynwb>=2.0.0 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from pynapple) (2.6.0)\n",
"Requirement already satisfied: tabulate in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from pynapple) (0.9.0)\n",
"Requirement already satisfied: h5py in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from pynapple) (3.10.0)\n",
"Requirement already satisfied: rich in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from pynapple) (13.7.1)\n",
"Requirement already satisfied: matplotlib!=3.6.1,>=3.4 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from seaborn) (3.8.4)\n",
"Requirement already satisfied: contourpy>=1.0.1 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (1.2.1)\n",
"Requirement already satisfied: cycler>=0.10 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (0.12.1)\n",
"Requirement already satisfied: fonttools>=4.22.0 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (4.50.0)\n",
"Requirement already satisfied: kiwisolver>=1.3.1 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (1.4.5)\n",
"Requirement already satisfied: packaging>=20.0 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (24.0)\n",
"Requirement already satisfied: pillow>=8 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (10.3.0)\n",
"Requirement already satisfied: pyparsing>=2.3.1 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (3.1.2)\n",
"Requirement already satisfied: python-dateutil>=2.7 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (2.9.0.post0)\n",
"Requirement already satisfied: llvmlite<0.43,>=0.42.0dev0 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from numba>=0.46.0->pynapple) (0.42.0)\n",
"Requirement already satisfied: pytz>=2020.1 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from pandas>1.0.3->pynapple) (2024.1)\n",
"Requirement already satisfied: tzdata>=2022.7 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from pandas>1.0.3->pynapple) (2024.1)\n",
"Requirement already satisfied: hdmf>=3.12.2 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from pynwb>=2.0.0->pynapple) (3.13.0)\n",
"Requirement already satisfied: setuptools in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from pynwb>=2.0.0->pynapple) (68.2.2)\n",
"Requirement already satisfied: markdown-it-py>=2.2.0 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from rich->pynapple) (3.0.0)\n",
"Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from rich->pynapple) (2.17.2)\n",
"Requirement already satisfied: jsonschema>=2.6.0 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from hdmf>=3.12.2->pynwb>=2.0.0->pynapple) (4.21.1)\n",
"Requirement already satisfied: ruamel-yaml>=0.16 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from hdmf>=3.12.2->pynwb>=2.0.0->pynapple) (0.18.6)\n",
"Requirement already satisfied: mdurl~=0.1 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from markdown-it-py>=2.2.0->rich->pynapple) (0.1.2)\n",
"Requirement already satisfied: six>=1.5 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from python-dateutil>=2.7->matplotlib!=3.6.1,>=3.4->seaborn) (1.16.0)\n",
"Requirement already satisfied: attrs>=22.2.0 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from jsonschema>=2.6.0->hdmf>=3.12.2->pynwb>=2.0.0->pynapple) (23.2.0)\n",
"Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from jsonschema>=2.6.0->hdmf>=3.12.2->pynwb>=2.0.0->pynapple) (2023.12.1)\n",
"Requirement already satisfied: referencing>=0.28.4 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from jsonschema>=2.6.0->hdmf>=3.12.2->pynwb>=2.0.0->pynapple) (0.34.0)\n",
"Requirement already satisfied: rpds-py>=0.7.1 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from jsonschema>=2.6.0->hdmf>=3.12.2->pynwb>=2.0.0->pynapple) (0.18.0)\n",
"Requirement already satisfied: ruamel.yaml.clib>=0.2.7 in /Users/smprince/anaconda3/envs/houston-workshop/lib/python3.12/site-packages (from ruamel-yaml>=0.16->hdmf>=3.12.2->pynwb>=2.0.0->pynapple) (0.2.8)\n"
]
}
],
"source": [
"!pip install pynapple seaborn"
"[Pynapple](https://pynapple-org.github.io/pynapple/) is a light-weight python library for neurophysiological data analysis that accepts NWB files as input."
]
},
{
Expand All @@ -1151,7 +1099,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 20,
"id": "61cd613d-db4d-4608-b71f-2d97a37fb802",
"metadata": {},
"outputs": [
Expand All @@ -1169,7 +1117,7 @@
"┕━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┙"
]
},
"execution_count": 21,
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -1196,7 +1144,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 21,
"id": "b4957059-c4c0-4c53-99c9-e1855c91d665",
"metadata": {},
"outputs": [
Expand All @@ -1215,7 +1163,7 @@
" 7 1.47 t4c1 MEC LII 0.0024"
]
},
"execution_count": 22,
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -1235,7 +1183,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 22,
"id": "4e24caa5-a4f7-4b2e-87a7-aa085295ae41",
"metadata": {},
"outputs": [
Expand All @@ -1258,7 +1206,7 @@
"dtype: float64, shape: (30000, 2)"
]
},
"execution_count": 23,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -1278,7 +1226,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 23,
"id": "ff2fedad-370e-4bca-a000-6268d8fca444",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1330,7 +1278,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 24,
"id": "24c52805-0a0a-4354-a60c-cef9ab539728",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -1372,7 +1320,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 25,
"id": "ecaa28a4-f9d6-466d-ba76-53e690bfdedc",
"metadata": {},
"outputs": [],
Expand Down

0 comments on commit a10bde9

Please sign in to comment.