diff --git a/src/pinto_lab_to_nwb/widefield/tutorials/data_types.png b/src/pinto_lab_to_nwb/widefield/tutorials/data_types.png new file mode 100644 index 0000000..30cc143 Binary files /dev/null and b/src/pinto_lab_to_nwb/widefield/tutorials/data_types.png differ diff --git a/src/pinto_lab_to_nwb/widefield/tutorials/widefield_demo.ipynb b/src/pinto_lab_to_nwb/widefield/tutorials/widefield_demo.ipynb new file mode 100644 index 0000000..bff5512 --- /dev/null +++ b/src/pinto_lab_to_nwb/widefield/tutorials/widefield_demo.ipynb @@ -0,0 +1,2942 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "6242b563-faf9-411b-b61e-ff6d5d802609", + "metadata": {}, + "source": [ + "# Widefield tutorial\n", + "\n", + "This tutorial demonstraces how to access the *Widefield dataset* using `pynwb`. \n", + "\n", + "This dataset contains the Widefield imaging from multiple cortical visual areas and behavior measurements from the ViRMEN system.\n", + "\n", + "Contents:\n", + "\n", + "- [Reading an NWB file](#read-nwb)\n", + "- [Access subject and task metadata](#access-subject)\n", + "- [Access Imaging](#access-imaging)\n", + "- [Access Behavior](#access-behavior)\n", + "- [View NWB files](#view-nwb)\n", + "\n", + "![Alt text](data_types.png)" + ] + }, + { + "cell_type": "markdown", + "id": "6bc8942c-2b51-4bd9-9e87-51cdd58f25ef", + "metadata": {}, + "source": [ + "# Reading an NWB file \n", + "\n", + "This section demonstrates how to read an NWB file using `pynwb`.\n", + "\n", + "Based on the [NWB File Basics](https://pynwb.readthedocs.io/en/stable/tutorials/general/plot_file.html#sphx-glr-tutorials-general-plot-file-py) tutorial from [PyNWB](https://pynwb.readthedocs.io/en/stable/#).\n", + "\n", + "Reading is carried out using the [NWBHDF5IO](https://pynwb.readthedocs.io/en/stable/pynwb.html#pynwb.NWBHDF5IO) class. To read the NWB file use the read mode (\"r\") to retrieve an NWBFile object.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "b2968627-3cdd-4c65-825c-4e239cf9a5ea", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + "
\n", + " | lStart | \n", + "lCue | \n", + "lMemory | \n", + "lContext | \n", + "turnHint | \n", + "hideHintUntil | \n", + "cueDuration | \n", + "cueVisibleAt | \n", + "cueProbability | \n", + "cueDensityPerM | \n", + "... | \n", + "numSessions | \n", + "numTrials | \n", + "numTrialsPerMin | \n", + "performance | \n", + "warmupBias | \n", + "warmupMaxNTrials | \n", + "warmupMaze | \n", + "warmupMotor | \n", + "warmupNTrials | \n", + "warmupPerform | \n", + "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | \n", + "\n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " |
0 | \n", + "5 | \n", + "45 | \n", + "10 | \n", + "10 | \n", + "1 | \n", + "-15 | \n", + "NaN | \n", + "10 | \n", + "inf | \n", + "3 | \n", + "... | \n", + "0 | \n", + "10 | \n", + "2 | \n", + "0.00 | \n", + "[nan] | \n", + "[nan] | \n", + "[nan] | \n", + "[nan] | \n", + "[nan] | \n", + "[nan] | \n", + "
1 | \n", + "30 | \n", + "100 | \n", + "20 | \n", + "20 | \n", + "1 | \n", + "-50 | \n", + "NaN | \n", + "10 | \n", + "inf | \n", + "3 | \n", + "... | \n", + "0 | \n", + "40 | \n", + "2 | \n", + "0.00 | \n", + "[nan] | \n", + "[nan] | \n", + "[nan] | \n", + "[nan] | \n", + "[nan] | \n", + "[nan] | \n", + "
2 | \n", + "30 | \n", + "190 | \n", + "20 | \n", + "30 | \n", + "1 | \n", + "-60 | \n", + "NaN | \n", + "10 | \n", + "inf | \n", + "3 | \n", + "... | \n", + "0 | \n", + "80 | \n", + "2 | \n", + "0.60 | \n", + "[nan] | \n", + "[nan] | \n", + "[nan] | \n", + "[nan] | \n", + "[nan] | \n", + "[nan] | \n", + "
3 | \n", + "30 | \n", + "230 | \n", + "20 | \n", + "50 | \n", + "1 | \n", + "0 | \n", + "NaN | \n", + "10 | \n", + "inf | \n", + "4 | \n", + "... | \n", + "2 | \n", + "80 | \n", + "2 | \n", + "0.90 | \n", + "[nan] | \n", + "[nan] | \n", + "[nan] | \n", + "[nan] | \n", + "[nan] | \n", + "[nan] | \n", + "
4 | \n", + "30 | \n", + "230 | \n", + "20 | \n", + "50 | \n", + "0 | \n", + "0 | \n", + "NaN | \n", + "10 | \n", + "inf | \n", + "4 | \n", + "... | \n", + "1 | \n", + "80 | \n", + "2 | \n", + "0.80 | \n", + "[0.1] | \n", + "[60.0] | \n", + "[4.0] | \n", + "[0.0] | \n", + "[30.0] | \n", + "[0.8] | \n", + "
5 | \n", + "30 | \n", + "190 | \n", + "60 | \n", + "50 | \n", + "0 | \n", + "0 | \n", + "NaN | \n", + "10 | \n", + "inf | \n", + "4 | \n", + "... | \n", + "1 | \n", + "80 | \n", + "2 | \n", + "0.80 | \n", + "[0.1] | \n", + "[60.0] | \n", + "[4.0] | \n", + "[0.0] | \n", + "[30.0] | \n", + "[0.8] | \n", + "
6 | \n", + "30 | \n", + "150 | \n", + "100 | \n", + "50 | \n", + "0 | \n", + "0 | \n", + "NaN | \n", + "10 | \n", + "inf | \n", + "4 | \n", + "... | \n", + "1 | \n", + "80 | \n", + "2 | \n", + "0.80 | \n", + "[0.1] | \n", + "[60.0] | \n", + "[4.0] | \n", + "[0.0] | \n", + "[30.0] | \n", + "[0.8] | \n", + "
7 | \n", + "30 | \n", + "150 | \n", + "100 | \n", + "50 | \n", + "0 | \n", + "0 | \n", + "NaN | \n", + "10 | \n", + "2.5 | \n", + "4 | \n", + "... | \n", + "1 | \n", + "80 | \n", + "2 | \n", + "0.75 | \n", + "[0.1, 0.1] | \n", + "[20.0, 30.0] | \n", + "[4.0, 7.0] | \n", + "[0.75, 0.75] | \n", + "[10.0, 15.0] | \n", + "[0.85, 0.8] | \n", + "
8 | \n", + "30 | \n", + "150 | \n", + "100 | \n", + "50 | \n", + "0 | \n", + "0 | \n", + "NaN | \n", + "10 | \n", + "1.6 | \n", + "4 | \n", + "... | \n", + "1 | \n", + "80 | \n", + "2 | \n", + "0.70 | \n", + "[0.1] | \n", + "[20.0] | \n", + "[4.0] | \n", + "[0.75] | \n", + "[10.0] | \n", + "[0.85] | \n", + "
9 | \n", + "30 | \n", + "150 | \n", + "100 | \n", + "50 | \n", + "0 | \n", + "0 | \n", + "0.2 | \n", + "10 | \n", + "1.6 | \n", + "4 | \n", + "... | \n", + "1 | \n", + "80 | \n", + "2 | \n", + "0.70 | \n", + "[0.1] | \n", + "[20.0] | \n", + "[4.0] | \n", + "[0.75] | \n", + "[10.0] | \n", + "[0.85] | \n", + "
10 | \n", + "30 | \n", + "150 | \n", + "100 | \n", + "50 | \n", + "0 | \n", + "0 | \n", + "0.2 | \n", + "10 | \n", + "1.2 | \n", + "4 | \n", + "... | \n", + "1 | \n", + "80 | \n", + "2 | \n", + "inf | \n", + "[0.1] | \n", + "[20.0] | \n", + "[13.0] | \n", + "[0.75] | \n", + "[10.0] | \n", + "[0.85] | \n", + "
11 | \n", + "30 | \n", + "150 | \n", + "100 | \n", + "50 | \n", + "1 | \n", + "0 | \n", + "NaN | \n", + "10 | \n", + "inf | \n", + "0 | \n", + "... | \n", + "1 | \n", + "80 | \n", + "2 | \n", + "inf | \n", + "[0.1] | \n", + "[nan] | \n", + "[nan] | \n", + "[0.75] | \n", + "[nan] | \n", + "[0.85] | \n", + "
12 | \n", + "30 | \n", + "150 | \n", + "100 | \n", + "50 | \n", + "1 | \n", + "0 | \n", + "NaN | \n", + "10 | \n", + "inf | \n", + "0 | \n", + "... | \n", + "1 | \n", + "80 | \n", + "2 | \n", + "inf | \n", + "[0.1] | \n", + "[nan] | \n", + "[nan] | \n", + "[0.75] | \n", + "[nan] | \n", + "[0.85] | \n", + "
13 rows × 32 columns
\n", + "\n", + " | numMazesInProtocol | \n", + "trialDraw | \n", + "stimDraw | \n", + "cueMinSeparation | \n", + "totalRepeatProbability | \n", + "numRepeatTrials | \n", + "visualcolor | \n", + "memorycolor | \n", + "princetonImplementation | \n", + "stimulus_code | \n", + "
---|---|---|---|---|---|---|---|---|---|---|
id | \n", + "\n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " |
0 | \n", + "11 | \n", + "EradeCapped | \n", + "LeftOneOnly | \n", + "12 | \n", + "0.05 | \n", + "2 | \n", + "[0, 0, 1] | \n", + "[1, 1, 0] | \n", + "1 | \n", + "TowersTaskSwitchStimulusTrain | \n", + "
\n", + " | start_time | \n", + "stop_time | \n", + "InterTrial | \n", + "SetupTrial | \n", + "InitializeTrial | \n", + "WithinTrial | \n", + "WithinContext | \n", + "WithinCue | \n", + "WithinDelay | \n", + "WithinArms | \n", + "... | \n", + "nDistract | \n", + "posSalient | \n", + "posDistract | \n", + "startIdx | \n", + "mazeID | \n", + "mainMazeID | \n", + "distanceTraveled | \n", + "excessTravel | \n", + "rewardFactor | \n", + "reward | \n", + "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | \n", + "\n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " |
0 | \n", + "0.909966 | \n", + "7.271522 | \n", + "8.583685 | \n", + "0.000000 | \n", + "0.000000 | \n", + "6.450284 | \n", + "1.358135 | \n", + "2.166536 | \n", + "4.641668 | \n", + "6.458506 | \n", + "... | \n", + "0 | \n", + "[nan] | \n", + "[nan] | \n", + "1.0 | \n", + "13.0 | \n", + "11.0 | \n", + "350.353220 | \n", + "-0.166818 | \n", + "1.5 | \n", + "1.0 | \n", + "
1 | \n", + "10.814495 | \n", + "18.314169 | \n", + "19.626610 | \n", + "102.490120 | \n", + "10.775707 | \n", + "16.609617 | \n", + "11.667454 | \n", + "12.484078 | \n", + "15.042678 | \n", + "16.617932 | \n", + "... | \n", + "0 | \n", + "[nan] | \n", + "[nan] | \n", + "1102.0 | \n", + "13.0 | \n", + "11.0 | \n", + "355.420683 | \n", + "-0.154767 | \n", + "1.5 | \n", + "1.0 | \n", + "
2 | \n", + "21.743707 | \n", + "27.903475 | \n", + "29.219161 | \n", + "111.852504 | \n", + "21.710063 | \n", + "26.685581 | \n", + "22.360060 | \n", + "23.101868 | \n", + "25.243717 | \n", + "26.693910 | \n", + "... | \n", + "0 | \n", + "[nan] | \n", + "[nan] | \n", + "2362.0 | \n", + "13.0 | \n", + "11.0 | \n", + "352.031584 | \n", + "-0.162826 | \n", + "1.5 | \n", + "1.0 | \n", + "
3 | \n", + "31.322219 | \n", + "37.632828 | \n", + "38.953310 | \n", + "120.488884 | \n", + "31.302666 | \n", + "36.094812 | \n", + "31.752710 | \n", + "32.394347 | \n", + "34.602882 | \n", + "36.103057 | \n", + "... | \n", + "0 | \n", + "[nan] | \n", + "[nan] | \n", + "3461.0 | \n", + "13.0 | \n", + "11.0 | \n", + "357.422186 | \n", + "-0.150007 | \n", + "1.5 | \n", + "1.0 | \n", + "
4 | \n", + "41.075315 | \n", + "46.084046 | \n", + "47.404256 | \n", + "136.962611 | \n", + "41.036849 | \n", + "45.545664 | \n", + "41.461924 | \n", + "42.020375 | \n", + "43.937248 | \n", + "45.554195 | \n", + "... | \n", + "0 | \n", + "[nan] | \n", + "[nan] | \n", + "4580.0 | \n", + "13.0 | \n", + "11.0 | \n", + "345.586712 | \n", + "-0.178153 | \n", + "1.5 | \n", + "1.0 | \n", + "
5 | \n", + "49.547212 | \n", + "54.684280 | \n", + "56.013430 | \n", + "155.345215 | \n", + "49.521185 | \n", + "54.138277 | \n", + "49.929496 | \n", + "50.521363 | \n", + "52.563017 | \n", + "54.146616 | \n", + "... | \n", + "0 | \n", + "[nan] | \n", + "[nan] | \n", + "5541.0 | \n", + "13.0 | \n", + "11.0 | \n", + "345.630288 | \n", + "-0.178049 | \n", + "1.5 | \n", + "1.0 | \n", + "
6 | \n", + "58.108839 | \n", + "63.149754 | \n", + "64.472509 | \n", + "164.816137 | \n", + "58.096967 | \n", + "62.872325 | \n", + "58.472001 | \n", + "59.071988 | \n", + "61.230530 | \n", + "62.880761 | \n", + "... | \n", + "0 | \n", + "[nan] | \n", + "[nan] | \n", + "6520.0 | \n", + "13.0 | \n", + "11.0 | \n", + "346.368546 | \n", + "-0.176294 | \n", + "1.5 | \n", + "1.0 | \n", + "
7 | \n", + "66.567484 | \n", + "72.458560 | \n", + "73.773566 | \n", + "173.978186 | \n", + "66.556058 | \n", + "71.589923 | \n", + "67.056115 | \n", + "67.747934 | \n", + "69.964713 | \n", + "71.598314 | \n", + "... | \n", + "0 | \n", + "[nan] | \n", + "[nan] | \n", + "7487.0 | \n", + "13.0 | \n", + "11.0 | \n", + "351.158302 | \n", + "-0.164903 | \n", + "1.5 | \n", + "1.0 | \n", + "
8 | \n", + "75.868855 | \n", + "81.534504 | \n", + "82.849307 | \n", + "183.373662 | \n", + "75.857036 | \n", + "81.224259 | \n", + "76.290304 | \n", + "76.973813 | \n", + "79.423986 | \n", + "81.232587 | \n", + "... | \n", + "0 | \n", + "[nan] | \n", + "[nan] | \n", + "8556.0 | \n", + "13.0 | \n", + "11.0 | \n", + "346.586614 | \n", + "-0.175775 | \n", + "1.5 | \n", + "1.0 | \n", + "
9 | \n", + "84.951920 | \n", + "91.718480 | \n", + "93.033739 | \n", + "192.879341 | \n", + "84.932914 | \n", + "89.766764 | \n", + "85.433002 | \n", + "86.233040 | \n", + "88.191617 | \n", + "89.775102 | \n", + "... | \n", + "0 | \n", + "[nan] | \n", + "[nan] | \n", + "9597.0 | \n", + "13.0 | \n", + "11.0 | \n", + "357.552212 | \n", + "-0.149697 | \n", + "1.5 | \n", + "1.0 | \n", + "
10 rows × 47 columns
\n", + "\n", + " | start_time | \n", + "stop_time | \n", + "InterTrial | \n", + "SetupTrial | \n", + "InitializeTrial | \n", + "WithinTrial | \n", + "WithinContext | \n", + "WithinCue | \n", + "WithinDelay | \n", + "WithinArms | \n", + "... | \n", + "nDistract | \n", + "posSalient | \n", + "posDistract | \n", + "startIdx | \n", + "mazeID | \n", + "mainMazeID | \n", + "distanceTraveled | \n", + "excessTravel | \n", + "rewardFactor | \n", + "reward | \n", + "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | \n", + "\n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " | \n", + " |
0 | \n", + "0.909966 | \n", + "7.271522 | \n", + "8.583685 | \n", + "0.000000 | \n", + "0.000000 | \n", + "6.450284 | \n", + "1.358135 | \n", + "2.166536 | \n", + "4.641668 | \n", + "6.458506 | \n", + "... | \n", + "0 | \n", + "[nan] | \n", + "[nan] | \n", + "1.0 | \n", + "13.0 | \n", + "11.0 | \n", + "350.353220 | \n", + "-0.166818 | \n", + "1.5 | \n", + "1.0 | \n", + "
1 | \n", + "10.814495 | \n", + "18.314169 | \n", + "19.626610 | \n", + "102.490120 | \n", + "10.775707 | \n", + "16.609617 | \n", + "11.667454 | \n", + "12.484078 | \n", + "15.042678 | \n", + "16.617932 | \n", + "... | \n", + "0 | \n", + "[nan] | \n", + "[nan] | \n", + "1102.0 | \n", + "13.0 | \n", + "11.0 | \n", + "355.420683 | \n", + "-0.154767 | \n", + "1.5 | \n", + "1.0 | \n", + "
2 | \n", + "21.743707 | \n", + "27.903475 | \n", + "29.219161 | \n", + "111.852504 | \n", + "21.710063 | \n", + "26.685581 | \n", + "22.360060 | \n", + "23.101868 | \n", + "25.243717 | \n", + "26.693910 | \n", + "... | \n", + "0 | \n", + "[nan] | \n", + "[nan] | \n", + "2362.0 | \n", + "13.0 | \n", + "11.0 | \n", + "352.031584 | \n", + "-0.162826 | \n", + "1.5 | \n", + "1.0 | \n", + "
3 rows × 47 columns
\n", + "\n", + " | image_mask | \n", + "ROICentroids | \n", + "Accepted | \n", + "Rejected | \n", + "location | \n", + "
---|---|---|---|---|---|
id | \n", + "\n", + " | \n", + " | \n", + " | \n", + " | \n", + " |
0 | \n", + "[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | \n", + "[14.705515088449532, 112.51925078043705] | \n", + "1 | \n", + "0 | \n", + "VISp-L | \n", + "
1 | \n", + "[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | \n", + "[106.82650142993327, 114.68255481410867] | \n", + "1 | \n", + "0 | \n", + "VISp-R | \n", + "
2 | \n", + "[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | \n", + "[30.074074074074073, 107.95833333333333] | \n", + "1 | \n", + "0 | \n", + "VISpm-L | \n", + "
3 | \n", + "[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | \n", + "[88.71363636363637, 110.15] | \n", + "1 | \n", + "0 | \n", + "VISpm-R | \n", + "
4 | \n", + "[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | \n", + "[29.676855895196507, 92.2882096069869] | \n", + "1 | \n", + "0 | \n", + "VISam-L | \n", + "
5 | \n", + "[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | \n", + "[90.1889400921659, 94.58986175115207] | \n", + "1 | \n", + "0 | \n", + "VISam-R | \n", + "
6 | \n", + "[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | \n", + "[21.92622950819672, 83.87158469945355] | \n", + "1 | \n", + "0 | \n", + "VISa-L | \n", + "
7 | \n", + "[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | \n", + "[98.55342465753425, 86.38356164383562] | \n", + "1 | \n", + "0 | \n", + "VISa-R | \n", + "
8 | \n", + "[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | \n", + "[5.009615384615385, 90.4326923076923] | \n", + "1 | \n", + "0 | \n", + "VISrl-L | \n", + "
9 | \n", + "[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... | \n", + "[119.74090909090908, 98.00454545454545] | \n", + "1 | \n", + "0 | \n", + "VISrl-R | \n", + "