From 7688c7a6b775832e45d3fd939939f97341bc8449 Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Mon, 5 Jun 2023 16:06:44 -0700 Subject: [PATCH 01/19] test commit --- helloworld1.ipynb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 helloworld1.ipynb diff --git a/helloworld1.ipynb b/helloworld1.ipynb new file mode 100644 index 00000000..7458660c --- /dev/null +++ b/helloworld1.ipynb @@ -0,0 +1,21 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print('hello world')\n" + ] + } + ], + "metadata": { + "language_info": { + "name": "python" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +} From e60af1e03573d24b9de926ef1738df5a2a1112a4 Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Tue, 6 Jun 2023 16:21:05 -0700 Subject: [PATCH 02/19] added 2 print() lines for clarity and made comments on errors --- docs/basics/read_nwb.ipynb | 48 ++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/docs/basics/read_nwb.ipynb b/docs/basics/read_nwb.ipynb index 30ad72b8..adea8f74 100644 --- a/docs/basics/read_nwb.ipynb +++ b/docs/basics/read_nwb.ipynb @@ -71,13 +71,26 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 11, "id": "9da13c50", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "sub-699733573_ses-715093703.nwb\n", + "./sub-699733573_ses-715093703.nwb\n" + ] + } + ], "source": [ "filename = dandi_filepath.split(\"/\")[-1]\n", - "filepath = f\"{download_loc}/{filename}\"" + "filepath = f\"{download_loc}/{filename}\"\n", + "\n", + "#this allows you to see what the lines above do\n", + "print(filename)\n", + "print(filepath)" ] }, { @@ -86,13 +99,6 @@ "id": "da61049a", "metadata": {}, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "A newer version (0.53.0) of dandi/dandi-cli is available. You are using 0.46.6\n" - ] - }, { "name": "stdout", "output_type": "stream", @@ -131,9 +137,9 @@ "name": "stderr", "output_type": "stream", "text": [ - "c:\\Users\\carter.peene\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'hdmf-common' version 1.1.3 because version 1.5.1 is already loaded.\n", + "c:\\Users\\katrina.ager\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'hdmf-common' version 1.1.3 because version 1.6.0 is already loaded.\n", " warn(\"Ignoring cached namespace '%s' version %s because version %s is already loaded.\"\n", - "c:\\Users\\carter.peene\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'core' version 2.2.2 because version 2.6.0-alpha is already loaded.\n", + "c:\\Users\\katrina.ager\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'core' version 2.2.2 because version 2.5.0 is already loaded.\n", " warn(\"Ignoring cached namespace '%s' version %s because version %s is already loaded.\"\n" ] }, @@ -141,7 +147,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "root pynwb.file.NWBFile at 0x1716049481344\n", + "root pynwb.file.NWBFile at 0x2749370276352\n", "Fields:\n", " acquisition: {\n", " raw_running_wheel_rotation ,\n", @@ -190,7 +196,7 @@ " session_id: 715093703\n", " session_start_time: 2019-01-19 00:54:18-08:00\n", " stimulus_notes: brain_observatory_1.1\n", - " subject: subject abc.EcephysSpecimen at 0x1716049229424\n", + " subject: subject abc.EcephysSpecimen at 0x2749369366752\n", "Fields:\n", " age: P118D\n", " age_in_days: 118.0\n", @@ -215,18 +221,20 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 19, "id": "2598de2f", "metadata": {}, "outputs": [], "source": [ + "#SEE ERRORS IN THIS CELL!!\n", + "\n", "### uncomment these to view aspects of the file\n", "### note that not all these properties exist for all nwb files\n", "# nwb.identifier\n", "# nwb.processing\n", - "# nwb.acquisition[\"events\"]\n", - "# nwb.intervals[\"trials\"]\n", - "# nwb.stimulus[\"StimulusPresentation\"]\n", + "# nwb.acquisition[\"events\"] #produces KeyError for 'events'\n", + "# nwb.intervals[\"trials\"] #produces KeyError for 'trials'\n", + "# nwb.stimulus[\"StimulusPresentation\"] #KeyError for 'StimulusPresentation'\n", "# nwb.electrodes" ] }, @@ -250,7 +258,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "C:\\Users\\carter.peene\\AppData\\Local\\Temp\\ipykernel_16628\\3249629881.py:4: FutureWarning: Passing a negative integer is deprecated in version 1.0 and will not be supported in future version. Instead, use None to not limit the column width.\n", + "C:\\Users\\katrina.ager\\AppData\\Local\\Temp\\ipykernel_11288\\3249629881.py:4: FutureWarning: Passing a negative integer is deprecated in version 1.0 and will not be supported in future version. Instead, use None to not limit the column width.\n", " pd.set_option('display.max_colwidth', -1)\n" ] } @@ -6393,7 +6401,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.10" + "version": "3.9.13" } }, "nbformat": 4, From a0b39fa08cfe5a201318836947e34e111f124f67 Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Tue, 6 Jun 2023 17:07:53 -0700 Subject: [PATCH 03/19] changes made based on Carter's feedback from PR --- docs/basics/read_nwb.ipynb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/basics/read_nwb.ipynb b/docs/basics/read_nwb.ipynb index adea8f74..50661c65 100644 --- a/docs/basics/read_nwb.ipynb +++ b/docs/basics/read_nwb.ipynb @@ -88,7 +88,6 @@ "filename = dandi_filepath.split(\"/\")[-1]\n", "filepath = f\"{download_loc}/{filename}\"\n", "\n", - "#this allows you to see what the lines above do\n", "print(filename)\n", "print(filepath)" ] @@ -226,15 +225,15 @@ "metadata": {}, "outputs": [], "source": [ - "#SEE ERRORS IN THIS CELL!!\n", - "\n", "### uncomment these to view aspects of the file\n", "### note that not all these properties exist for all nwb files\n", + "### not all of these exist for all NWB files (Key Errors will arise if the fields don't exist for this file)\n", + "\n", "# nwb.identifier\n", "# nwb.processing\n", - "# nwb.acquisition[\"events\"] #produces KeyError for 'events'\n", - "# nwb.intervals[\"trials\"] #produces KeyError for 'trials'\n", - "# nwb.stimulus[\"StimulusPresentation\"] #KeyError for 'StimulusPresentation'\n", + "# nwb.acquisition[\"events\"] \n", + "# nwb.intervals[\"trials\"] \n", + "# nwb.stimulus[\"StimulusPresentation\"] \n", "# nwb.electrodes" ] }, From a3a6660fb92e8fe7bc4c1517697fef3e91d6519c Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Wed, 7 Jun 2023 10:41:35 -0700 Subject: [PATCH 04/19] added a comment to the interacting section and minorly edited a description --- docs/basics/stream_nwb.ipynb | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/docs/basics/stream_nwb.ipynb b/docs/basics/stream_nwb.ipynb index 41b86808..f753df14 100644 --- a/docs/basics/stream_nwb.ipynb +++ b/docs/basics/stream_nwb.ipynb @@ -36,7 +36,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "id": "df1c4cce", "metadata": {}, "outputs": [], @@ -66,7 +66,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "id": "f3f97f13", "metadata": {}, "outputs": [], @@ -79,17 +79,10 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "id": "a51caf90", "metadata": {}, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "A newer version (0.53.0) of dandi/dandi-cli is available. You are using 0.46.6\n" - ] - }, { "name": "stdout", "output_type": "stream", @@ -110,7 +103,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "id": "d131ad56", "metadata": {}, "outputs": [ @@ -118,7 +111,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Retrieved file url https://dandiarchive.s3.amazonaws.com/blobs/f5f/175/f5f1752f-5227-47d5-8f75-cd71937878aa?response-content-disposition=attachment%3B%20filename%3D%22sub-699733573_ses-715093703.nwb%22&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAUBRWC5GAEKH3223E%2F20230420%2Fus-east-2%2Fs3%2Faws4_request&X-Amz-Date=20230420T201648Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=6088e2110f82ce358dec90e827468a37fd995c34e80089139ff1056659e1ccb8\n" + "Retrieved file url https://dandiarchive.s3.amazonaws.com/blobs/f5f/175/f5f1752f-5227-47d5-8f75-cd71937878aa?response-content-disposition=attachment%3B%20filename%3D%22sub-699733573_ses-715093703.nwb%22&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAUBRWC5GAEKH3223E%2F20230607%2Fus-east-2%2Fs3%2Faws4_request&X-Amz-Date=20230607T170103Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=47c78e4993c637e57e9e6296dfd5f0f52d06f4d33574280ca6c527ebd4ed2869\n" ] } ], @@ -152,9 +145,9 @@ "name": "stderr", "output_type": "stream", "text": [ - "c:\\Users\\carter.peene\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'hdmf-common' version 1.1.3 because version 1.5.1 is already loaded.\n", + "c:\\Users\\katrina.ager\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'hdmf-common' version 1.1.3 because version 1.6.0 is already loaded.\n", " warn(\"Ignoring cached namespace '%s' version %s because version %s is already loaded.\"\n", - "c:\\Users\\carter.peene\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'core' version 2.2.2 because version 2.6.0-alpha is already loaded.\n", + "c:\\Users\\katrina.ager\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'core' version 2.2.2 because version 2.5.0 is already loaded.\n", " warn(\"Ignoring cached namespace '%s' version %s because version %s is already loaded.\"\n" ] } @@ -177,18 +170,20 @@ "metadata": {}, "source": [ "### Interacting with a Remote File\n", - "Once the file has been opened remotely, you can explore the file as you wish via `print` statements, or you can view the whole thing with `NWBWidgets` like we showed in *Exploring an NWB File*." + "Once the file has been opened remotely, you can explore the file as you wish via `print` statements, or you can view the whole thing with `NWBWidgets` like we will show in *Exploring NWB files with NWBWidgets*." ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 10, "id": "91031da2", "metadata": {}, "outputs": [], "source": [ "### uncomment these to view aspects of the file\n", "### note that not all these properties exist for all nwb files\n", + "### not all of these exist for all NWB files (Key Errors will arise if the fields don't exist for this file)\n", + "\n", "# nwb.identifier\n", "# nwb.processing\n", "# nwb.acquisition[\"events\"]\n", @@ -199,14 +194,14 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 11, "id": "3e06b964", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "770645b2edf24149ad7158e0ea7c3096", + "model_id": "f5c84701e3b14599ac2adcf1fa35d89d", "version_major": 2, "version_minor": 0 }, @@ -239,7 +234,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.10" + "version": "3.9.13" } }, "nbformat": 4, From 9b4b5b714c4cdc268f327f08feabe300624a01a9 Mon Sep 17 00:00:00 2001 From: Katrina Ager <130607675+katrinaager@users.noreply.github.com> Date: Wed, 7 Jun 2023 12:21:13 -0700 Subject: [PATCH 05/19] updated table of contents for README.md updated table of contents: swapped positions of Streaming NWB and Exploring NWB because they are out of order. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 70c3be2c..ec52ba7e 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ We are releasing this code to the public as a tool we expect others to use and a ### Chapter 1: Using DANDI/getting data - [Downloading NWB files from DANDI](https://github.com/AllenInstitute/openscope_databook/blob/main/docs/basics/download_nwb.ipynb) - [Reading NWB files](https://github.com/AllenInstitute/openscope_databook/blob/main/docs/basics/read_nwb.ipynb) -- [Streaming NWB files from DANDI](https://github.com/AllenInstitute/openscope_databook/blob/main/docs/basics/stream_nwb.ipynb) - [Exploring NWB files with NWBWidgets](https://github.com/AllenInstitute/openscope_databook/blob/main/docs/basics/use_nwbwidgets.ipynb) +- [Streaming NWB files from DANDI](https://github.com/AllenInstitute/openscope_databook/blob/main/docs/basics/stream_nwb.ipynb) - [Querying metadata across sessions from DANDI](https://github.com/AllenInstitute/openscope_databook/blob/main/docs/basics/get_dandiset_metadata.ipynb) ### Chapter 2: Data visualization From 63fc80ce14843d54a11559463fb0bf1773466b59 Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Wed, 7 Jun 2023 14:54:51 -0700 Subject: [PATCH 06/19] includes line by line comments to provide clarity for beginners --- docs/basics/use_nwbwidgets.ipynb | 56 ++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/docs/basics/use_nwbwidgets.ipynb b/docs/basics/use_nwbwidgets.ipynb index 859a54f1..03699fa5 100644 --- a/docs/basics/use_nwbwidgets.ipynb +++ b/docs/basics/use_nwbwidgets.ipynb @@ -36,7 +36,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "id": "24009707", "metadata": {}, "outputs": [], @@ -58,7 +58,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "id": "16c587a2", "metadata": {}, "outputs": [], @@ -73,10 +73,22 @@ "execution_count": 4, "id": "83d7e5f7", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "sub-699733573_ses-715093703.nwb\n", + "./sub-699733573_ses-715093703.nwb\n" + ] + } + ], "source": [ "filename = dandi_filepath.split(\"/\")[-1]\n", - "filepath = f\"{download_loc}/{filename}\"" + "filepath = f\"{download_loc}/{filename}\"\n", + "\n", + "print(filename)\n", + "print(filepath)" ] }, { @@ -85,13 +97,6 @@ "id": "1c5db129", "metadata": {}, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "A newer version (0.53.0) of dandi/dandi-cli is available. You are using 0.46.6\n" - ] - }, { "name": "stdout", "output_type": "stream", @@ -101,9 +106,15 @@ } ], "source": [ + "# initilizes client as an object and creates an instance of the 'DandiAPIClient' class from the 'dandiapi' library \n", "client = dandiapi.DandiAPIClient()\n", - "my_dandiset = client.get_dandiset(dandiset_id)\n", + "\n", + "# the 'get_dandiset()' method retrieves metadata from a specific DANDI dataset identified by 'dandiset_id' \n", + "my_dandiset = client.get_dandiset(dandiset_id) \n", + "\n", + "# the 'get_asset_by_path()' method that calls on the 'my_dandiset' locate a specific asset identified by 'dandi_filepath'\n", "file = my_dandiset.get_asset_by_path(dandi_filepath)\n", + "\n", "# this may take awhile, especially if the file to download is large\n", "file.download(filepath)\n", "\n", @@ -122,7 +133,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "id": "0691fffc", "metadata": { "scrolled": true @@ -132,9 +143,9 @@ "name": "stderr", "output_type": "stream", "text": [ - "c:\\Users\\carter.peene\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'hdmf-common' version 1.1.3 because version 1.5.1 is already loaded.\n", + "c:\\Users\\katrina.ager\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'hdmf-common' version 1.1.3 because version 1.6.0 is already loaded.\n", " warn(\"Ignoring cached namespace '%s' version %s because version %s is already loaded.\"\n", - "c:\\Users\\carter.peene\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'core' version 2.2.2 because version 2.6.0-alpha is already loaded.\n", + "c:\\Users\\katrina.ager\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'core' version 2.2.2 because version 2.5.0 is already loaded.\n", " warn(\"Ignoring cached namespace '%s' version %s because version %s is already loaded.\"\n" ] }, @@ -142,7 +153,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "root pynwb.file.NWBFile at 0x2285253481232\n", + "root pynwb.file.NWBFile at 0x1800960199360\n", "Fields:\n", " acquisition: {\n", " raw_running_wheel_rotation ,\n", @@ -191,7 +202,7 @@ " session_id: 715093703\n", " session_start_time: 2019-01-19 00:54:18-08:00\n", " stimulus_notes: brain_observatory_1.1\n", - " subject: subject abc.EcephysSpecimen at 0x2285271628048\n", + " subject: subject abc.EcephysSpecimen at 0x1800960197056\n", "Fields:\n", " age: P118D\n", " age_in_days: 118.0\n", @@ -208,7 +219,10 @@ } ], "source": [ - "io = NWBHDF5IO(filepath, mode=\"r\", load_namespaces=True)\n", + "# creates instance of 'NWBHDF5IO' class used to read NWB files, 'mode= \"r\"' means read only\n", + "io = NWBHDF5IO(filepath, mode=\"r\", load_namespaces=True) \n", + "\n", + "# reads the nwb file and returns an object with the contents of the file\n", "nwb = io.read()\n", "\n", "print(nwb)" @@ -216,14 +230,14 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "id": "65addc38", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "ff394f60aa434277a364cc6bd96495c5", + "model_id": "0f56df3845274d45b17b0e54cdf888af", "version_major": 2, "version_minor": 0 }, @@ -256,7 +270,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.10" + "version": "3.9.13" } }, "nbformat": 4, From a1a9fa21ab162a85976e156d4d7d92c112892976 Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Wed, 7 Jun 2023 17:07:15 -0700 Subject: [PATCH 07/19] deleted helloworld1.ipynb --- helloworld1.ipynb | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 helloworld1.ipynb diff --git a/helloworld1.ipynb b/helloworld1.ipynb deleted file mode 100644 index 7458660c..00000000 --- a/helloworld1.ipynb +++ /dev/null @@ -1,21 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print('hello world')\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} From f3d791428c0a868b90ad1e33638c474203539cd8 Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Wed, 7 Jun 2023 17:10:07 -0700 Subject: [PATCH 08/19] deleted in line comments and added one sentence to the description --- docs/basics/use_nwbwidgets.ipynb | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/docs/basics/use_nwbwidgets.ipynb b/docs/basics/use_nwbwidgets.ipynb index 03699fa5..f66b29b4 100644 --- a/docs/basics/use_nwbwidgets.ipynb +++ b/docs/basics/use_nwbwidgets.ipynb @@ -36,7 +36,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "id": "24009707", "metadata": {}, "outputs": [], @@ -53,12 +53,12 @@ "metadata": {}, "source": [ "### Downloading an NWB File\n", - "To examine an NWB File locally, it must first be downloaded. `dandiset_id` and `dandi_filepath` may be changed to select a different file off of DANDI. If the file of interest already downloaded, you don't need to run the download cell again. When trying to download an embargoed file, refer to the code from the [Downloading an NWB File](./download_nwb.ipynb) notebook." + "To examine an NWB File locally, it must first be downloaded. `dandiset_id` and `dandi_filepath` may be changed to select a different file off of DANDI. If the file of interest already downloaded, you don't need to run the download cell again. When trying to download an embargoed file, refer to the code from the [Downloading an NWB File](./download_nwb.ipynb) notebook. The method `get_dandiset()` retrieves metadata from a specific DANDI dataset while the `get_asset_by_path()` method locates the asset." ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "id": "16c587a2", "metadata": {}, "outputs": [], @@ -106,13 +106,8 @@ } ], "source": [ - "# initilizes client as an object and creates an instance of the 'DandiAPIClient' class from the 'dandiapi' library \n", "client = dandiapi.DandiAPIClient()\n", - "\n", - "# the 'get_dandiset()' method retrieves metadata from a specific DANDI dataset identified by 'dandiset_id' \n", - "my_dandiset = client.get_dandiset(dandiset_id) \n", - "\n", - "# the 'get_asset_by_path()' method that calls on the 'my_dandiset' locate a specific asset identified by 'dandi_filepath'\n", + "my_dandiset = client.get_dandiset(dandiset_id)\n", "file = my_dandiset.get_asset_by_path(dandi_filepath)\n", "\n", "# this may take awhile, especially if the file to download is large\n", @@ -133,7 +128,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "id": "0691fffc", "metadata": { "scrolled": true @@ -153,7 +148,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "root pynwb.file.NWBFile at 0x1800960199360\n", + "root pynwb.file.NWBFile at 0x2179856764832\n", "Fields:\n", " acquisition: {\n", " raw_running_wheel_rotation ,\n", @@ -202,7 +197,7 @@ " session_id: 715093703\n", " session_start_time: 2019-01-19 00:54:18-08:00\n", " stimulus_notes: brain_observatory_1.1\n", - " subject: subject abc.EcephysSpecimen at 0x1800960197056\n", + " subject: subject abc.EcephysSpecimen at 0x2179856428960\n", "Fields:\n", " age: P118D\n", " age_in_days: 118.0\n", @@ -219,10 +214,7 @@ } ], "source": [ - "# creates instance of 'NWBHDF5IO' class used to read NWB files, 'mode= \"r\"' means read only\n", "io = NWBHDF5IO(filepath, mode=\"r\", load_namespaces=True) \n", - "\n", - "# reads the nwb file and returns an object with the contents of the file\n", "nwb = io.read()\n", "\n", "print(nwb)" @@ -230,14 +222,14 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 7, "id": "65addc38", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "0f56df3845274d45b17b0e54cdf888af", + "model_id": "fb037fcb861e489896b6812becc84a8e", "version_major": 2, "version_minor": 0 }, From f9d78d105b20708b046d4b98f804ffc0b9d83f0a Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Thu, 8 Jun 2023 14:35:57 -0700 Subject: [PATCH 09/19] removed trailing space --- docs/basics/use_nwbwidgets.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/basics/use_nwbwidgets.ipynb b/docs/basics/use_nwbwidgets.ipynb index f66b29b4..4b64afc0 100644 --- a/docs/basics/use_nwbwidgets.ipynb +++ b/docs/basics/use_nwbwidgets.ipynb @@ -214,7 +214,7 @@ } ], "source": [ - "io = NWBHDF5IO(filepath, mode=\"r\", load_namespaces=True) \n", + "io = NWBHDF5IO(filepath, mode=\"r\", load_namespaces=True)\n", "nwb = io.read()\n", "\n", "print(nwb)" From c70554262c5fecbf2cb67cf3b5a2bb59025ab351 Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Thu, 8 Jun 2023 14:38:34 -0700 Subject: [PATCH 10/19] removed unecessary comment on line 2 --- docs/basics/read_nwb.ipynb | 1 - docs/basics/stream_nwb.ipynb | 1 - 2 files changed, 2 deletions(-) diff --git a/docs/basics/read_nwb.ipynb b/docs/basics/read_nwb.ipynb index 50661c65..73762702 100644 --- a/docs/basics/read_nwb.ipynb +++ b/docs/basics/read_nwb.ipynb @@ -226,7 +226,6 @@ "outputs": [], "source": [ "### uncomment these to view aspects of the file\n", - "### note that not all these properties exist for all nwb files\n", "### not all of these exist for all NWB files (Key Errors will arise if the fields don't exist for this file)\n", "\n", "# nwb.identifier\n", diff --git a/docs/basics/stream_nwb.ipynb b/docs/basics/stream_nwb.ipynb index 45d2fe68..0892e97e 100644 --- a/docs/basics/stream_nwb.ipynb +++ b/docs/basics/stream_nwb.ipynb @@ -181,7 +181,6 @@ "outputs": [], "source": [ "### uncomment these to view aspects of the file\n", - "### note that not all these properties exist for all nwb files\n", "### not all of these exist for all NWB files (Key Errors will arise if the fields don't exist for this file)\n", "\n", "# nwb.identifier\n", From 2f850c7eac077051013a2058c82eb893dfa19f19 Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Thu, 8 Jun 2023 15:09:55 -0700 Subject: [PATCH 11/19] added informative comment for dandi api key --- docs/basics/download_nwb.ipynb | 41 ++++++++++++++++++------- docs/basics/get_dandiset_metadata.ipynb | 1 + 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/docs/basics/download_nwb.ipynb b/docs/basics/download_nwb.ipynb index 6fbd4367..00b0993d 100644 --- a/docs/basics/download_nwb.ipynb +++ b/docs/basics/download_nwb.ipynb @@ -61,8 +61,10 @@ "metadata": {}, "outputs": [], "source": [ - "dandiset_id = \"000021\"\n", - "download_loc = \".\"\n", + "\n", + "dandiset_id = \"000021\" #the set ID can be found under the title of the dandiset\n", + "download_loc = \".\" #a filepath specifies the location of a file relative to the current directory (not starting from the root directory)\n", + "#explain how to access the filepath?\n", "authenticate = False\n", "dandi_api_key = \"\"" ] @@ -116,10 +118,22 @@ "execution_count": 6, "id": "c176c129", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "sub-699733573_ses-715093703.nwb\n", + "./sub-699733573_ses-715093703.nwb\n" + ] + } + ], "source": [ "filename = dandi_filepath.split(\"/\")[-1]\n", - "filepath = f\"{download_loc}/{filename}\"" + "filepath = f\"{download_loc}/{filename}\"\n", + "\n", + "print(filename)\n", + "print(filepath)\n" ] }, { @@ -129,10 +143,15 @@ "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "Downloaded file to ./sub-699733573_ses-715093703.nwb\n" + "ename": "PermissionError", + "evalue": "[Errno 13] Permission denied", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mPermissionError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[7], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m file \u001b[39m=\u001b[39m my_dandiset\u001b[39m.\u001b[39mget_asset_by_path(dandi_filepath)\n\u001b[0;32m 2\u001b[0m \u001b[39m# this may take awhile, especially if the file to download is large\u001b[39;00m\n\u001b[1;32m----> 3\u001b[0m file\u001b[39m.\u001b[39;49mdownload(filepath)\n\u001b[0;32m 5\u001b[0m \u001b[39mprint\u001b[39m(\u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mDownloaded file to \u001b[39m\u001b[39m{\u001b[39;00mfilepath\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m)\n\u001b[0;32m 7\u001b[0m \u001b[39m#this step took 30 min, is this a reasonable amount of time for this step?\u001b[39;00m\n", + "File \u001b[1;32mc:\\Users\\katrina.ager\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\dandi\\dandiapi.py:1451\u001b[0m, in \u001b[0;36mBaseRemoteAsset.download\u001b[1;34m(self, filepath, chunk_size)\u001b[0m\n\u001b[0;32m 1449\u001b[0m \u001b[39mwith\u001b[39;00m \u001b[39mopen\u001b[39m(filepath, \u001b[39m\"\u001b[39m\u001b[39mwb\u001b[39m\u001b[39m\"\u001b[39m) \u001b[39mas\u001b[39;00m fp:\n\u001b[0;32m 1450\u001b[0m \u001b[39mfor\u001b[39;00m chunk \u001b[39min\u001b[39;00m downloader(\u001b[39m0\u001b[39m):\n\u001b[1;32m-> 1451\u001b[0m fp\u001b[39m.\u001b[39;49mwrite(chunk)\n", + "\u001b[1;31mPermissionError\u001b[0m: [Errno 13] Permission denied" ] } ], @@ -141,7 +160,7 @@ "# this may take awhile, especially if the file to download is large\n", "file.download(filepath)\n", "\n", - "print(f\"Downloaded file to {filepath}\")" + "print(f\"Downloaded file to {filepath}\")\n" ] }, { @@ -156,7 +175,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "1c42049e", "metadata": {}, "outputs": [ @@ -192,7 +211,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.10" + "version": "3.9.13" } }, "nbformat": 4, diff --git a/docs/basics/get_dandiset_metadata.ipynb b/docs/basics/get_dandiset_metadata.ipynb index 5b49c6e2..3b7ab9f8 100644 --- a/docs/basics/get_dandiset_metadata.ipynb +++ b/docs/basics/get_dandiset_metadata.ipynb @@ -81,6 +81,7 @@ "source": [ "dandiset_id = \"000248\"\n", "authenticate = True\n", + "# put your dandi api key here\n", "dandi_api_key = os.environ[\"DANDI_API_KEY\"]" ] }, From 2bb5ffd090bfb1a389433dc4a4a6fc7ac77d382f Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Thu, 8 Jun 2023 15:38:43 -0700 Subject: [PATCH 12/19] edited comment at top --- docs/basics/download_nwb.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/basics/download_nwb.ipynb b/docs/basics/download_nwb.ipynb index 00b0993d..e45ff0a0 100644 --- a/docs/basics/download_nwb.ipynb +++ b/docs/basics/download_nwb.ipynb @@ -61,10 +61,10 @@ "metadata": {}, "outputs": [], "source": [ + "# relative filepath\n", + "dandiset_id = \"000021\" \n", + "download_loc = \".\" \n", "\n", - "dandiset_id = \"000021\" #the set ID can be found under the title of the dandiset\n", - "download_loc = \".\" #a filepath specifies the location of a file relative to the current directory (not starting from the root directory)\n", - "#explain how to access the filepath?\n", "authenticate = False\n", "dandi_api_key = \"\"" ] From ab79f3bfe32cf18005ed87d43c48c51c3af313dc Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Thu, 8 Jun 2023 15:48:28 -0700 Subject: [PATCH 13/19] reworte part of the description for downloading NWB file --- docs/basics/use_nwbwidgets.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/basics/use_nwbwidgets.ipynb b/docs/basics/use_nwbwidgets.ipynb index 4b64afc0..444e0cbe 100644 --- a/docs/basics/use_nwbwidgets.ipynb +++ b/docs/basics/use_nwbwidgets.ipynb @@ -53,7 +53,7 @@ "metadata": {}, "source": [ "### Downloading an NWB File\n", - "To examine an NWB File locally, it must first be downloaded. `dandiset_id` and `dandi_filepath` may be changed to select a different file off of DANDI. If the file of interest already downloaded, you don't need to run the download cell again. When trying to download an embargoed file, refer to the code from the [Downloading an NWB File](./download_nwb.ipynb) notebook. The method `get_dandiset()` retrieves metadata from a specific DANDI dataset while the `get_asset_by_path()` method locates the asset." + "To examine an NWB File locally, it must first be downloaded. `dandiset_id` and `dandi_filepath` may be changed to select a different file off of DANDI. If the file of interest already downloaded, you don't need to run the download cell again. When trying to download an embargoed file, refer to the code from the [Downloading an NWB File](./download_nwb.ipynb) notebook. In the cells below, the DANDI API is used to faciliate the download. The `get_dandiset()` methods retrieves a specific dataset within DANDI while the `get_asset_by_path()` method retrieves a secific file within that dataset. " ] }, { From 2267847540394a6e98718098dee029c0d099aa5e Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Fri, 9 Jun 2023 10:12:36 -0700 Subject: [PATCH 14/19] enhanced description for where to find ID and moved comment placement --- docs/basics/download_nwb.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/basics/download_nwb.ipynb b/docs/basics/download_nwb.ipynb index e45ff0a0..8a86818d 100644 --- a/docs/basics/download_nwb.ipynb +++ b/docs/basics/download_nwb.ipynb @@ -51,7 +51,7 @@ "metadata": {}, "source": [ "### Download Configuration\n", - "Here you can configure the download. Browse the DANDI Archive for a dandiset you're interested in and use its ID in `dandiset_id`. Also set `download_loc` to the relative filepath of the directory you'd like to download to. If you're accessing an embargoed dandiset, you should set `authenticate` to True, and set `dandi_api_key` to your DANDI API Key, which can be found if you click on your profile icon in the top-right corner on the DANDI Archive website." + "Here you can configure the download. Browse the DANDI Archive for a dandiset you're interested in and use its ID in `dandiset_id`. The ID can be found just under the title of the dandiset you are interested in. Also set `download_loc` to the relative filepath of the directory you'd like to download to. If you're accessing an embargoed dandiset, you should set `authenticate` to True, and set `dandi_api_key` to your DANDI API Key, which can be found if you click on your profile icon in the top-right corner on the DANDI Archive website." ] }, { @@ -61,8 +61,8 @@ "metadata": {}, "outputs": [], "source": [ - "# relative filepath\n", "dandiset_id = \"000021\" \n", + "# relative filepath\n", "download_loc = \".\" \n", "\n", "authenticate = False\n", From 53f17e4df6f9124b6d93db664023503276340415 Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Fri, 9 Jun 2023 10:15:56 -0700 Subject: [PATCH 15/19] fixed spelling of specific --- docs/basics/use_nwbwidgets.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/basics/use_nwbwidgets.ipynb b/docs/basics/use_nwbwidgets.ipynb index 444e0cbe..b98783fc 100644 --- a/docs/basics/use_nwbwidgets.ipynb +++ b/docs/basics/use_nwbwidgets.ipynb @@ -53,7 +53,7 @@ "metadata": {}, "source": [ "### Downloading an NWB File\n", - "To examine an NWB File locally, it must first be downloaded. `dandiset_id` and `dandi_filepath` may be changed to select a different file off of DANDI. If the file of interest already downloaded, you don't need to run the download cell again. When trying to download an embargoed file, refer to the code from the [Downloading an NWB File](./download_nwb.ipynb) notebook. In the cells below, the DANDI API is used to faciliate the download. The `get_dandiset()` methods retrieves a specific dataset within DANDI while the `get_asset_by_path()` method retrieves a secific file within that dataset. " + "To examine an NWB File locally, it must first be downloaded. `dandiset_id` and `dandi_filepath` may be changed to select a different file off of DANDI. If the file of interest already downloaded, you don't need to run the download cell again. When trying to download an embargoed file, refer to the code from the [Downloading an NWB File](./download_nwb.ipynb) notebook. In the cells below, the DANDI API is used to faciliate the download. The `get_dandiset()` methods retrieves a specific dataset within DANDI while the `get_asset_by_path()` method retrieves a specific file within that dataset. " ] }, { From 8acaca6c22f74927653d25d63222270ce0a48d6b Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Wed, 14 Jun 2023 13:28:58 -0700 Subject: [PATCH 16/19] preliminary draft of intro nb to check progress --- docs/basics/intro_information.ipynb | 61 +++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 docs/basics/intro_information.ipynb diff --git a/docs/basics/intro_information.ipynb b/docs/basics/intro_information.ipynb new file mode 100644 index 00000000..0b5f4e08 --- /dev/null +++ b/docs/basics/intro_information.ipynb @@ -0,0 +1,61 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Preliminary Knowledge" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### DANDI\n", + "Throughout these notebooks, we utilize a platform called [DANDI](https://dandiarchive.org/) (Data Archive and Neurophysiology Imaging). DANDI is a platform that allows open-source data sharing and archiving add acts as a centralized repository where research can deposit data. While we have provided some pre-loaded data from DANDI in the notebooks, the purpose of this databooks is to take any dataset off DANDI and reproduce the analysis within these notebooks. You should familiarize youself with DANDI before running through the notebooks, and explore how Dandisets are organized on the website. \n", + "\n", + "One step that may be confusing when running through the notebooks for the first time is finding a filepath for a certain file within a Dandiset. These are the steps for accessing a filepath you can try out yourself: \n", + "1) Click [here](https://dandiarchive.org/dandiset/000535?search=allen%20institute%202%20photon&pos=2) to access a Dandiset uploaded by researchers at the Allen Institute. \n", + "2) On the right side of the page, click the \"files\" tab.\n", + "3) You will now see a list of folders. Click on any folder. \n", + "4) Once you have entered the folder, you will see a list of files with 4 blue buttons to the right of each file name. Select any file you would like and click the \"i\" icon in the blue circle. \n", + "5) This will pull up a new tab with a bunch of red code. At the top of the code, you will see `\"id\" :`, `\"path\" :`, and `\"access\":`. Copy the code to the right of `\"path\" :`. It will look like this `\"sub-460654/sub-460654_ses-20190611T181840_behavior+ophys.nwb\"`. This is the filepath you will insert in various notebooks when it asks for `dandi_filepath`. \n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### NWB FILES\n", + "NWB (Neurodata Without Borders) files utilize a standardized format for storing and sharing neurophysiology data. Their purpose is to address the need for a universal data format that makes analysis accessible across different experimental techniques. NWB files contain raw data, processed data, analysis results, and metadata all organized in a uniform manner across different research projects. It would be useful to understand the format of these files before running through the notebooks because we will be accessing many different modules within various files to retreive data. Click [here](https://nwb-schema.readthedocs.io/en/latest/) to explore NWB format specification." + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Understanding Data Colletion Techniques\n", + "In this databook, we will be analyzing data from two different types of experimental techniques: optical imagine (ophys) and extracellular electrophysiology (ecephys). To truly grasp what is happening during the analysis process, you should familiarize youself with these experimental modalities. \n", + "\n", + "Resouces for ophys:\n", + "1) [this paper](https://www.pnas.org/doi/epdf/10.1073/pnas.1232232100) will provide an introduction to two-photon calcium imaging. \n", + "\n", + "Resources for ecephys:\n", + "1) [this paper](https://www.nature.com/articles/s41586-020-03171-x) from the Allen Institute will provide an introduction to ecephys and the use of neuropixel probes. \n", + "2) [here](https://portal.brain-map.org/explore/circuits/visual-coding-neuropixels) is a visualization of the neuropixel probes that may come in handy when trying to visualualize how the data is collected from the probe itself." + ] + } + ], + "metadata": { + "language_info": { + "name": "python" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +} From d5955d9555c3cc96dda68c584a711e0eabba2b65 Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Wed, 14 Jun 2023 15:35:52 -0700 Subject: [PATCH 17/19] set dandi_api_key to None --- docs/first-order/optotagging.ipynb | 73 ++++++++++++++---------------- 1 file changed, 33 insertions(+), 40 deletions(-) diff --git a/docs/first-order/optotagging.ipynb b/docs/first-order/optotagging.ipynb index 412c2fba..97305808 100644 --- a/docs/first-order/optotagging.ipynb +++ b/docs/first-order/optotagging.ipynb @@ -21,7 +21,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 47, "id": "12291e3d", "metadata": {}, "outputs": [], @@ -36,7 +36,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 48, "id": "31757169", "metadata": {}, "outputs": [], @@ -68,7 +68,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 49, "id": "0ac9cf76", "metadata": {}, "outputs": [], @@ -81,17 +81,10 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 50, "id": "986c3dd5", "metadata": {}, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "A newer version (0.54.0) of dandi/dandi-cli is available. You are using 0.46.6\n" - ] - }, { "name": "stdout", "output_type": "stream", @@ -104,9 +97,9 @@ "name": "stderr", "output_type": "stream", "text": [ - "c:\\Users\\carter.peene\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'hdmf-common' version 1.1.3 because version 1.5.1 is already loaded.\n", + "c:\\Users\\katrina.ager\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'hdmf-common' version 1.1.3 because version 1.6.0 is already loaded.\n", " warn(\"Ignoring cached namespace '%s' version %s because version %s is already loaded.\"\n", - "c:\\Users\\carter.peene\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'core' version 2.2.2 because version 2.6.0-alpha is already loaded.\n", + "c:\\Users\\katrina.ager\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'core' version 2.2.2 because version 2.5.0 is already loaded.\n", " warn(\"Ignoring cached namespace '%s' version %s because version %s is already loaded.\"\n" ] } @@ -128,7 +121,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 51, "id": "6b01dfb4", "metadata": {}, "outputs": [], @@ -140,7 +133,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 52, "id": "2b8bc125", "metadata": { "scrolled": true, @@ -347,7 +340,7 @@ "9 [(9, 1, optotagging pynwb.base.TimeSeries at 0... " ] }, - "execution_count": 6, + "execution_count": 52, "metadata": {}, "output_type": "execute_result" } @@ -358,7 +351,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 53, "id": "d27e63ad", "metadata": {}, "outputs": [ @@ -368,7 +361,7 @@ "{0.0049999999991996455, 0.01000000000021828, 1.0}" ] }, - "execution_count": 7, + "execution_count": 53, "metadata": {}, "output_type": "execute_result" } @@ -379,7 +372,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 54, "id": "b658cb86", "metadata": { "scrolled": false, @@ -797,7 +790,7 @@ "[10 rows x 29 columns]" ] }, - "execution_count": 8, + "execution_count": 54, "metadata": {}, "output_type": "execute_result" } @@ -821,7 +814,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 55, "id": "1a8b91fe", "metadata": {}, "outputs": [], @@ -848,7 +841,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 56, "id": "8c31cdcb", "metadata": {}, "outputs": [], @@ -870,7 +863,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 57, "id": "dae01d0b", "metadata": {}, "outputs": [], @@ -894,7 +887,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 58, "id": "7d0c6cf9", "metadata": { "scrolled": false @@ -928,7 +921,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 59, "id": "b6b0880a", "metadata": {}, "outputs": [], @@ -966,7 +959,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 60, "id": "565354e0", "metadata": {}, "outputs": [ @@ -1013,7 +1006,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 61, "id": "6bf75044", "metadata": {}, "outputs": [], @@ -1030,7 +1023,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 62, "id": "23eb13db", "metadata": {}, "outputs": [ @@ -1065,7 +1058,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 63, "id": "eafbb240", "metadata": {}, "outputs": [], @@ -1077,7 +1070,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 64, "id": "3af896e5", "metadata": {}, "outputs": [ @@ -1112,7 +1105,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 65, "id": "353a6e31", "metadata": {}, "outputs": [ @@ -1150,7 +1143,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 66, "id": "2e3b1ed0", "metadata": {}, "outputs": [], @@ -1193,7 +1186,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 67, "id": "f693b440", "metadata": {}, "outputs": [], @@ -1231,7 +1224,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 68, "id": "70767ac3", "metadata": {}, "outputs": [ @@ -1239,11 +1232,11 @@ "name": "stderr", "output_type": "stream", "text": [ - "C:\\Users\\carter.peene\\AppData\\Roaming\\Python\\Python39\\site-packages\\scipy\\stats\\_stats_py.py:8057: RuntimeWarning: ks_2samp: Exact calculation unsuccessful. Switching to method=asymp.\n", + "c:\\Users\\katrina.ager\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\scipy\\stats\\_stats_py.py:8057: RuntimeWarning: ks_2samp: Exact calculation unsuccessful. Switching to method=asymp.\n", " return ks_2samp(xvals, yvals, alternative=alternative, method=method)\n", - "C:\\Users\\carter.peene\\AppData\\Roaming\\Python\\Python39\\site-packages\\numpy\\core\\fromnumeric.py:3474: RuntimeWarning: Mean of empty slice.\n", + "c:\\Users\\katrina.ager\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\numpy\\core\\fromnumeric.py:3474: RuntimeWarning: Mean of empty slice.\n", " return _methods._mean(a, axis=axis, dtype=dtype,\n", - "C:\\Users\\carter.peene\\AppData\\Roaming\\Python\\Python39\\site-packages\\numpy\\core\\_methods.py:189: RuntimeWarning: invalid value encountered in double_scalars\n", + "c:\\Users\\katrina.ager\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\numpy\\core\\_methods.py:189: RuntimeWarning: invalid value encountered in double_scalars\n", " ret = ret.dtype.type(ret / rcount)\n" ] } @@ -1275,7 +1268,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 69, "id": "8a1c3430", "metadata": { "tags": [ @@ -1447,7 +1440,7 @@ "[3232 rows x 6 columns]" ] }, - "execution_count": 23, + "execution_count": 69, "metadata": {}, "output_type": "execute_result" } @@ -1480,7 +1473,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.10" + "version": "3.9.13" } }, "nbformat": 4, From dafebd5b9f817ef1f5f96c5ce386194641661f4d Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Wed, 14 Jun 2023 16:12:21 -0700 Subject: [PATCH 18/19] reran without errors --- docs/basics/download_nwb.ipynb | 48 +++++++++++++--------------------- 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/docs/basics/download_nwb.ipynb b/docs/basics/download_nwb.ipynb index 8a86818d..9cf30bee 100644 --- a/docs/basics/download_nwb.ipynb +++ b/docs/basics/download_nwb.ipynb @@ -51,7 +51,7 @@ "metadata": {}, "source": [ "### Download Configuration\n", - "Here you can configure the download. Browse the DANDI Archive for a dandiset you're interested in and use its ID in `dandiset_id`. The ID can be found just under the title of the dandiset you are interested in. Also set `download_loc` to the relative filepath of the directory you'd like to download to. If you're accessing an embargoed dandiset, you should set `authenticate` to True, and set `dandi_api_key` to your DANDI API Key, which can be found if you click on your profile icon in the top-right corner on the DANDI Archive website." + "Here you can configure the download. Browse the DANDI Archive for a dandiset you're interested in and use its ID in `dandiset_id`. Also set `download_loc` to the relative filepath of the directory you'd like to download to. If you're accessing an embargoed dandiset, you should set `authenticate` to True, and set `dandi_api_key` to your DANDI API Key, which can be found if you click on your profile icon in the top-right corner on the DANDI Archive website." ] }, { @@ -61,10 +61,8 @@ "metadata": {}, "outputs": [], "source": [ - "dandiset_id = \"000021\" \n", - "# relative filepath\n", - "download_loc = \".\" \n", - "\n", + "dandiset_id = \"000021\"\n", + "download_loc = \".\"\n", "authenticate = False\n", "dandi_api_key = \"\"" ] @@ -75,6 +73,13 @@ "id": "a309c067", "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "A newer version (0.55.1) of dandi/dandi-cli is available. You are using 0.46.6\n" + ] + }, { "name": "stdout", "output_type": "stream", @@ -118,22 +123,10 @@ "execution_count": 6, "id": "c176c129", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "sub-699733573_ses-715093703.nwb\n", - "./sub-699733573_ses-715093703.nwb\n" - ] - } - ], + "outputs": [], "source": [ "filename = dandi_filepath.split(\"/\")[-1]\n", - "filepath = f\"{download_loc}/{filename}\"\n", - "\n", - "print(filename)\n", - "print(filepath)\n" + "filepath = f\"{download_loc}/{filename}\"" ] }, { @@ -143,15 +136,10 @@ "metadata": {}, "outputs": [ { - "ename": "PermissionError", - "evalue": "[Errno 13] Permission denied", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mPermissionError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[1;32mIn[7], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m file \u001b[39m=\u001b[39m my_dandiset\u001b[39m.\u001b[39mget_asset_by_path(dandi_filepath)\n\u001b[0;32m 2\u001b[0m \u001b[39m# this may take awhile, especially if the file to download is large\u001b[39;00m\n\u001b[1;32m----> 3\u001b[0m file\u001b[39m.\u001b[39;49mdownload(filepath)\n\u001b[0;32m 5\u001b[0m \u001b[39mprint\u001b[39m(\u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mDownloaded file to \u001b[39m\u001b[39m{\u001b[39;00mfilepath\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m)\n\u001b[0;32m 7\u001b[0m \u001b[39m#this step took 30 min, is this a reasonable amount of time for this step?\u001b[39;00m\n", - "File \u001b[1;32mc:\\Users\\katrina.ager\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\dandi\\dandiapi.py:1451\u001b[0m, in \u001b[0;36mBaseRemoteAsset.download\u001b[1;34m(self, filepath, chunk_size)\u001b[0m\n\u001b[0;32m 1449\u001b[0m \u001b[39mwith\u001b[39;00m \u001b[39mopen\u001b[39m(filepath, \u001b[39m\"\u001b[39m\u001b[39mwb\u001b[39m\u001b[39m\"\u001b[39m) \u001b[39mas\u001b[39;00m fp:\n\u001b[0;32m 1450\u001b[0m \u001b[39mfor\u001b[39;00m chunk \u001b[39min\u001b[39;00m downloader(\u001b[39m0\u001b[39m):\n\u001b[1;32m-> 1451\u001b[0m fp\u001b[39m.\u001b[39;49mwrite(chunk)\n", - "\u001b[1;31mPermissionError\u001b[0m: [Errno 13] Permission denied" + "name": "stdout", + "output_type": "stream", + "text": [ + "Downloaded file to ./sub-699733573_ses-715093703.nwb\n" ] } ], @@ -160,7 +148,7 @@ "# this may take awhile, especially if the file to download is large\n", "file.download(filepath)\n", "\n", - "print(f\"Downloaded file to {filepath}\")\n" + "print(f\"Downloaded file to {filepath}\")" ] }, { @@ -175,7 +163,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "1c42049e", "metadata": {}, "outputs": [ From b27e99d143c8c4d5be72cdd2606b1cd8de154499 Mon Sep 17 00:00:00 2001 From: Katrina Ager Date: Thu, 15 Jun 2023 13:26:47 -0700 Subject: [PATCH 19/19] deleted spaces after comments --- docs/basics/read_nwb.ipynb | 39 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/docs/basics/read_nwb.ipynb b/docs/basics/read_nwb.ipynb index 73762702..9c938d72 100644 --- a/docs/basics/read_nwb.ipynb +++ b/docs/basics/read_nwb.ipynb @@ -71,19 +71,10 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 4, "id": "9da13c50", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "sub-699733573_ses-715093703.nwb\n", - "./sub-699733573_ses-715093703.nwb\n" - ] - } - ], + "outputs": [], "source": [ "filename = dandi_filepath.split(\"/\")[-1]\n", "filepath = f\"{download_loc}/{filename}\"\n", @@ -98,6 +89,13 @@ "id": "da61049a", "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "A newer version (0.53.0) of dandi/dandi-cli is available. You are using 0.46.6\n" + ] + }, { "name": "stdout", "output_type": "stream", @@ -136,9 +134,9 @@ "name": "stderr", "output_type": "stream", "text": [ - "c:\\Users\\katrina.ager\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'hdmf-common' version 1.1.3 because version 1.6.0 is already loaded.\n", + "c:\\Users\\carter.peene\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'hdmf-common' version 1.1.3 because version 1.5.1 is already loaded.\n", " warn(\"Ignoring cached namespace '%s' version %s because version %s is already loaded.\"\n", - "c:\\Users\\katrina.ager\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'core' version 2.2.2 because version 2.5.0 is already loaded.\n", + "c:\\Users\\carter.peene\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\hdmf\\spec\\namespace.py:531: UserWarning: Ignoring cached namespace 'core' version 2.2.2 because version 2.6.0-alpha is already loaded.\n", " warn(\"Ignoring cached namespace '%s' version %s because version %s is already loaded.\"\n" ] }, @@ -146,7 +144,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "root pynwb.file.NWBFile at 0x2749370276352\n", + "root pynwb.file.NWBFile at 0x1716049481344\n", "Fields:\n", " acquisition: {\n", " raw_running_wheel_rotation ,\n", @@ -195,7 +193,7 @@ " session_id: 715093703\n", " session_start_time: 2019-01-19 00:54:18-08:00\n", " stimulus_notes: brain_observatory_1.1\n", - " subject: subject abc.EcephysSpecimen at 0x2749369366752\n", + " subject: subject abc.EcephysSpecimen at 0x1716049229424\n", "Fields:\n", " age: P118D\n", " age_in_days: 118.0\n", @@ -220,19 +218,20 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 7, "id": "2598de2f", "metadata": {}, "outputs": [], "source": [ "### uncomment these to view aspects of the file\n", + "\n", "### not all of these exist for all NWB files (Key Errors will arise if the fields don't exist for this file)\n", "\n", "# nwb.identifier\n", "# nwb.processing\n", - "# nwb.acquisition[\"events\"] \n", - "# nwb.intervals[\"trials\"] \n", - "# nwb.stimulus[\"StimulusPresentation\"] \n", + "# nwb.acquisition[\"events\"]\n", + "# nwb.intervals[\"trials\"]\n", + "# nwb.stimulus[\"StimulusPresentation\"]\n", "# nwb.electrodes" ] }, @@ -256,7 +255,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "C:\\Users\\katrina.ager\\AppData\\Local\\Temp\\ipykernel_11288\\3249629881.py:4: FutureWarning: Passing a negative integer is deprecated in version 1.0 and will not be supported in future version. Instead, use None to not limit the column width.\n", + "C:\\Users\\carter.peene\\AppData\\Local\\Temp\\ipykernel_16628\\3249629881.py:4: FutureWarning: Passing a negative integer is deprecated in version 1.0 and will not be supported in future version. Instead, use None to not limit the column width.\n", " pd.set_option('display.max_colwidth', -1)\n" ] }