Skip to content

Commit

Permalink
deploy: 0aae9b9
Browse files Browse the repository at this point in the history
  • Loading branch information
qian-chu committed Oct 4, 2024
1 parent 0e1daae commit 859936e
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 169 deletions.
File renamed without changes
File renamed without changes
95 changes: 38 additions & 57 deletions _sources/tutorials/read_recording.ipynb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"In this tutorial, we will show how to load a single Neon recording downloaded from [Pupil Cloud](https://docs.pupil-labs.com/neon/pupil-cloud/).\n",
"\n",
"## Reading sample data\n",
"We will use a sample recording produced by the NCC Lab called `OfficeWalk`. It's a project with 2 recordings and multiple enrichments and can be downloaded with the `get_sample_data()` function:"
"We will use a sample recording produced by the NCC Lab called `OfficeWalk`. It's a project with 2 recordings and multiple enrichments and can be downloaded with the `get_sample_data()` function. It returns a [`Pathlib.Path`](https://docs.python.org/3/library/pathlib.html) object to the downloaded & unzipped directory."
]
},
{
Expand All @@ -17,7 +17,6 @@
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"from pyneon import get_sample_data, NeonDataset, NeonRecording\n",
"\n",
"sample_dir = get_sample_data(\"OfficeWalk\")"
Expand Down Expand Up @@ -47,7 +46,7 @@
"└── OfficeWalk_STATIC-IMAGE-MAPPER_ManualMap_csv\n",
"```\n",
"\n",
"The `Timeseries Data` folder contains what PyNeon calls a `NeonDataset`. It contains multiple recordings, each with its own `info.json` file and data files. These recordings can either be loaded individually as `NeonRecording`s or as a wholist `NeonDataset`.\n",
"The `Timeseries Data` folder contains what PyNeon calls a [`NeonDataset`](https://ncc-brain.github.io/PyNeon/reference/dataset.html#pyneon.NeonDataset). It contains multiple recordings, each with its own `info.json` file and data files. These recordings can either be loaded individually as a [`NeonRecording`](https://ncc-brain.github.io/PyNeon/reference/recording.html#pyneon.NeonRecording) or as a wholist `NeonDataset`.\n",
"\n",
"If loading a `NeonDataset`, specify the path to the `Timeseries Data` folder to create a `NeonDataset` object:"
]
Expand Down Expand Up @@ -100,7 +99,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Alternatively, one can directly load a single `NeonRecording` by specifying the path to the recording's folder:"
"Equivalently, one can directly load a single `NeonRecording` by specifying the path to the recording's folder."
]
},
{
Expand Down Expand Up @@ -171,7 +170,7 @@
"source": [
"As seen in the output, this recording contains every file other than the scene video. This is because we downloaded the \"Timeseries Data\" instead of \"Timeseries Data + Scene Video\" from Pupil Cloud. For more information on how to process video files, see the [video tutorial](video.ipynb).\n",
"\n",
"Individual data streams can be accessed as properties of the `NeonRecording` object. For example, the gaze data can be accessed as `recording.gaze`, and upon accessing, the tabular data is loaded into memory."
"Individual data streams can be accessed as properties of the `NeonRecording` object. For example, the gaze data can be accessed as `recording.gaze`, and upon accessing, the tabular data is loaded into memory. On the other hand, if you try to access unavailable data like the video, it will simply return `None` and a warning message."
]
},
{
Expand All @@ -183,49 +182,22 @@
"name": "stdout",
"output_type": "stream",
"text": [
"recording._gaze size before accessing `gaze`: 16\n",
"recording.gaze is of type: <class 'pyneon.stream.NeonGaze'>\n",
"recording._gaze size after accessing `gaze`: 48\n"
]
}
],
"source": [
"print(f\"recording._gaze size before accessing `gaze`: {sys.getsizeof(recording._gaze)}\")\n",
"\n",
"gaze = recording.gaze\n",
"print(f\"recording.gaze is of type: {type(gaze)}\")\n",
"print(f\"recording._gaze size after accessing `gaze`: {sys.getsizeof(recording._gaze)}\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"On the other hand, if you try to access unavailable data like the video, it will simply return `None`."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<pyneon.stream.NeonGaze object at 0x00000270398494C0>\n",
"None\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\qian.chu\\Documents\\GitHub\\pyneon\\pyneon\\recording.py:273: UserWarning: Scene video not loaded because no video or video timestamps file was found.\n",
"C:\\Users\\qian.chu\\Documents\\GitHub\\pyneon\\pyneon\\recording.py:275: UserWarning: Scene video not loaded because no video or video timestamps file was found.\n",
" warnings.warn(\n"
]
}
],
"source": [
"gaze = recording.gaze\n",
"print(gaze)\n",
"video = recording.video\n",
"print(video)"
]
Expand All @@ -234,31 +206,40 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We can access the timeseries data in the gaze stream as a pandas DataFrame by accessing the `data` attribute of the gaze stream. The columns of the DataFrame include `timestamp [ns]` and channel data columns. During loading, PyNeon strips the redundant `section id` and `recording id` columns and adds a more human-readable `time [s]` column to represent the time of each sample in seconds relative to the start of the data stream."
"We can access the timeseries data in the gaze stream as a [`pandas.DataFrame`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html) by accessing the `data` attribute of the gaze stream. The DataFrame has the datetime of each data point as its index. The raw UTC `timestamp [ns]` is available as a column along with data from channnels like `gaze x [px]`.\n",
"\n",
"During loading, PyNeon strips the redundant `section id` and `recording id` columns and adds a more human-readable `time [s]` column to represent the time of each sample in seconds relative to the start of the data stream."
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" timestamp [ns] gaze x [px] gaze y [px] worn fixation id blink id \\\n",
"0 1725032224852161732 1067.486 620.856 True 1 <NA> \n",
"1 1725032224857165732 1066.920 617.117 True 1 <NA> \n",
"2 1725032224862161732 1072.699 615.780 True 1 <NA> \n",
"3 1725032224867161732 1067.447 617.062 True 1 <NA> \n",
"4 1725032224872161732 1071.564 613.158 True 1 <NA> \n",
" timestamp [ns] gaze x [px] gaze y [px] \\\n",
"2024-08-30 15:37:04.852161732 1725032224852161732 1067.486 620.856 \n",
"2024-08-30 15:37:04.857165732 1725032224857165732 1066.920 617.117 \n",
"2024-08-30 15:37:04.862161732 1725032224862161732 1072.699 615.780 \n",
"2024-08-30 15:37:04.867161732 1725032224867161732 1067.447 617.062 \n",
"2024-08-30 15:37:04.872161732 1725032224872161732 1071.564 613.158 \n",
"\n",
" azimuth [deg] elevation [deg] time [s] \n",
"0 16.213030 -0.748998 0.000000 \n",
"1 16.176285 -0.511733 0.005004 \n",
"2 16.546413 -0.426618 0.010000 \n",
"3 16.210049 -0.508251 0.015000 \n",
"4 16.473521 -0.260388 0.020000 \n"
" worn fixation id blink id azimuth [deg] \\\n",
"2024-08-30 15:37:04.852161732 True 1 <NA> 16.213030 \n",
"2024-08-30 15:37:04.857165732 True 1 <NA> 16.176285 \n",
"2024-08-30 15:37:04.862161732 True 1 <NA> 16.546413 \n",
"2024-08-30 15:37:04.867161732 True 1 <NA> 16.210049 \n",
"2024-08-30 15:37:04.872161732 True 1 <NA> 16.473521 \n",
"\n",
" elevation [deg] time [s] \n",
"2024-08-30 15:37:04.852161732 -0.748998 0.000000 \n",
"2024-08-30 15:37:04.857165732 -0.511733 0.005004 \n",
"2024-08-30 15:37:04.862161732 -0.426618 0.010000 \n",
"2024-08-30 15:37:04.867161732 -0.508251 0.015000 \n",
"2024-08-30 15:37:04.872161732 -0.260388 0.020000 \n"
]
}
],
Expand All @@ -275,7 +256,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -310,7 +291,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"metadata": {},
"outputs": [
{
Expand All @@ -319,7 +300,7 @@
"<Axes: xlabel='timestamp [ns]', ylabel='gyro x [deg/s]'>"
]
},
"execution_count": 10,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
},
Expand Down Expand Up @@ -390,7 +371,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -423,14 +404,14 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\qian.chu\\Documents\\GitHub\\pyneon\\pyneon\\recording.py:273: UserWarning: Scene video not loaded because no video or video timestamps file was found.\n",
"C:\\Users\\qian.chu\\Documents\\GitHub\\pyneon\\pyneon\\recording.py:275: UserWarning: Scene video not loaded because no video or video timestamps file was found.\n",
" warnings.warn(\n"
]
},
Expand Down Expand Up @@ -473,7 +454,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
"version": "3.12.6"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

Loading

0 comments on commit 859936e

Please sign in to comment.