Last active
March 28, 2024 07:37
-
-
Save rly/661181bb3e87c325408604418c48f133 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"id": "b7ad12b5-62d9-4d7d-8da4-761b5e7dcc26", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import lindi\n", | |
"from pynwb import NWBHDF5IO\n", | |
"from pynwb.testing.mock.ecephys import mock_ElectricalSeries\n", | |
"from pynwb.testing.mock.file import mock_NWBFile\n", | |
"import numpy as np\n", | |
"import json\n", | |
"import warnings\n", | |
"\n", | |
"warnings.simplefilter(\"always\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"id": "a7cb5cfc", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"es_data = np.arange(50).reshape(10, 5)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"id": "b3ab778e-72a1-4f37-8a1e-d443c94cf1ac", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"nwb_file_path = \"example.nwb\"\n", | |
"nwbfile = mock_NWBFile()\n", | |
"es = mock_ElectricalSeries(\n", | |
" name=\"ElectricalSeries\",\n", | |
" timestamps=np.arange(10.),\n", | |
" rate=None,\n", | |
" nwbfile=nwbfile,\n", | |
" data=es_data,\n", | |
" conversion=10.,\n", | |
" offset=1.,\n", | |
")\n", | |
"# mock data has shape (10, 5) and is all ones\n", | |
"\n", | |
"with NWBHDF5IO(nwb_file_path, \"w\") as io:\n", | |
" io.write(nwbfile)\n", | |
"\n", | |
"# Create a read-only Zarr store as a wrapper for the h5 file\n", | |
"# Set url to the local file reference for local read\n", | |
"store = lindi.LindiH5ZarrStore.from_file(nwb_file_path, url=nwb_file_path)\n", | |
"\n", | |
"# Generate a reference file system\n", | |
"rfs = store.to_reference_file_system()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"id": "5dd8cc3f-8f8c-4a84-a581-8257d37881af", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"with NWBHDF5IO(nwb_file_path, \"r\") as io:\n", | |
" nwbfile = io.read()\n", | |
" data = nwbfile.acquisition[\"ElectricalSeries\"].data" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"id": "d5065a57-f012-4423-bee7-6bf8bfdf422b", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def adjust_array(rfs, dset_name, dims):\n", | |
" # TODO handle consolidated metadata\n", | |
" zattrs = json.loads(rfs[\"refs\"][f\"{dset_name}/.zattrs\"])\n", | |
" # write special xarray attributes for automatic scaling and units\n", | |
" if \"unit\" in zattrs:\n", | |
" zattrs[\"units\"] = zattrs[\"unit\"]\n", | |
" if \"conversion\" in zattrs:\n", | |
" zattrs[\"scale_factor\"] = zattrs[\"conversion\"]\n", | |
" if \"offset\" in zattrs:\n", | |
" zattrs[\"add_offset\"] = zattrs[\"offset\"]\n", | |
" zattrs[\"_ARRAY_DIMENSIONS\"] = dims\n", | |
" rfs[\"refs\"][f\"{dset_name}/.zattrs\"] = json.dumps(zattrs)\n", | |
" \n", | |
" zarray = json.loads(rfs[\"refs\"][f\"{dset_name}/.zarray\"])\n", | |
" # workaround for https://github.com/pydata/xarray/issues/5475\n", | |
" # to use scale_factor and add_offset without converting all\n", | |
" # values that equal fill_value to NaN\n", | |
" if zarray[\"fill_value\"] in (0, 0.0, False):\n", | |
" zarray[\"fill_value\"] = None\n", | |
" rfs[\"refs\"][f\"{dset_name}/.zarray\"] = json.dumps(zarray)\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"id": "df58686c-e2df-418a-8621-496c935d90c2", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"{\n", | |
" \"version\": 1,\n", | |
" \"refs\": {\n", | |
" \".zgroup\": \"{\\\"zarr_format\\\":2}\",\n", | |
" \".zattrs\": \"{\\\"comments\\\":\\\"no comments\\\",\\\"description\\\":\\\"description\\\",\\\"filtering\\\":\\\"filtering\\\",\\\"namespace\\\":\\\"core\\\",\\\"neurodata_type\\\":\\\"ElectricalSeries\\\",\\\"object_id\\\":\\\"f7696ed3-2c80-4fb4-b284-5469e2c11a6c\\\"}\",\n", | |
" \"data/.zattrs\": \"{\\\"conversion\\\": 10.0, \\\"offset\\\": 1.0, \\\"resolution\\\": -1.0, \\\"unit\\\": \\\"volts\\\", \\\"units\\\": \\\"volts\\\", \\\"scale_factor\\\": 10.0, \\\"add_offset\\\": 1.0, \\\"_ARRAY_DIMENSIONS\\\": [\\\"timestamps\\\", \\\"electrodes\\\"]}\",\n", | |
" \"data/.zarray\": \"{\\\"chunks\\\": [10, 5], \\\"compressor\\\": null, \\\"dtype\\\": \\\"<i8\\\", \\\"fill_value\\\": null, \\\"filters\\\": null, \\\"order\\\": \\\"C\\\", \\\"shape\\\": [10, 5], \\\"zarr_format\\\": 2}\",\n", | |
" \"data/0.0\": [\n", | |
" \"example.nwb\",\n", | |
" 3464,\n", | |
" 400\n", | |
" ],\n", | |
" \"electrodes/.zattrs\": \"{\\\"description\\\": \\\"the first and third electrodes\\\", \\\"namespace\\\": \\\"hdmf-common\\\", \\\"neurodata_type\\\": \\\"DynamicTableRegion\\\", \\\"object_id\\\": \\\"65b98b43-3cfc-4774-bf05-ca342c9c624a\\\", \\\"table\\\": {\\\"_REFERENCE\\\": {\\\"object_id\\\": \\\"5307b610-47dc-43cb-b6b4-02dbfb98bcf0\\\", \\\"path\\\": \\\"/general/extracellular_ephys/electrodes\\\", \\\"source\\\": \\\".\\\", \\\"source_object_id\\\": \\\"fe8ec11f-9737-4368-b87b-6fcf24c256f6\\\"}}, \\\"_ARRAY_DIMENSIONS\\\": [\\\"electrodes\\\"]}\",\n", | |
" \"electrodes/.zarray\": \"{\\\"chunks\\\": [5], \\\"compressor\\\": null, \\\"dtype\\\": \\\"<i8\\\", \\\"fill_value\\\": null, \\\"filters\\\": null, \\\"order\\\": \\\"C\\\", \\\"shape\\\": [5], \\\"zarr_format\\\": 2}\",\n", | |
" \"electrodes/0\": [\n", | |
" \"example.nwb\",\n", | |
" 10008,\n", | |
" 40\n", | |
" ],\n", | |
" \"timestamps/.zattrs\": \"{\\\"interval\\\": 1, \\\"unit\\\": \\\"seconds\\\", \\\"units\\\": \\\"seconds\\\", \\\"_ARRAY_DIMENSIONS\\\": [\\\"timestamps\\\"]}\",\n", | |
" \"timestamps/.zarray\": \"{\\\"chunks\\\": [10], \\\"compressor\\\": null, \\\"dtype\\\": \\\"<f8\\\", \\\"fill_value\\\": null, \\\"filters\\\": null, \\\"order\\\": \\\"C\\\", \\\"shape\\\": [10], \\\"zarr_format\\\": 2}\",\n", | |
" \"timestamps/0\": [\n", | |
" \"example.nwb\",\n", | |
" 10048,\n", | |
" 80\n", | |
" ]\n", | |
" }\n", | |
"}\n" | |
] | |
} | |
], | |
"source": [ | |
"# create a new RFS JSON that contains only datasets in acquisition/ElectricalSeries\n", | |
"new_refs = {k.replace(\"acquisition/ElectricalSeries/\", \"\"): v for k, v in rfs[\"refs\"].items() if k.startswith('acquisition/ElectricalSeries/')}\n", | |
"rfs_electrical_series_only = {\n", | |
" 'version': 1,\n", | |
" 'refs': {\n", | |
" '.zgroup': '{\"zarr_format\":2}',\n", | |
" }\n", | |
"}\n", | |
"rfs_electrical_series_only[\"refs\"].update(new_refs)\n", | |
"\n", | |
"adjust_array(rfs_electrical_series_only, \"data\", [\"timestamps\", \"electrodes\"])\n", | |
"adjust_array(rfs_electrical_series_only, \"timestamps\", [\"timestamps\"])\n", | |
"adjust_array(rfs_electrical_series_only, \"electrodes\", [\"electrodes\"])\n", | |
"print(json.dumps(rfs_electrical_series_only, indent=2))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"id": "677c3999-92ac-49b3-b300-ebe03dd7a357", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import xarray as xr\n", | |
"def read_xarray_from_zarr_metadata(zm: dict, remote_protocol: str = \"file\"):\n", | |
" ds = xr.open_dataset(\n", | |
" \"reference://\",\n", | |
" engine=\"zarr\",\n", | |
" backend_kwargs={\n", | |
" \"storage_options\": dict(\n", | |
" fo=zm,\n", | |
" remote_protocol=remote_protocol,\n", | |
" ),\n", | |
" \"consolidated\": False\n", | |
" },\n", | |
" # decode_cf=False,\n", | |
" # mask_and_scale=False,\n", | |
" )\n", | |
" return ds\n", | |
"\n", | |
"dset = read_xarray_from_zarr_metadata(rfs_electrical_series_only)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"id": "f98f557d-b082-4d50-b6dc-b6d69c2f0e84", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n", | |
"<defs>\n", | |
"<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n", | |
"<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n", | |
"<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n", | |
"<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n", | |
"</symbol>\n", | |
"<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n", | |
"<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n", | |
"<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n", | |
"<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n", | |
"<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n", | |
"</symbol>\n", | |
"</defs>\n", | |
"</svg>\n", | |
"<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n", | |
" *\n", | |
" */\n", | |
"\n", | |
":root {\n", | |
" --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n", | |
" --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n", | |
" --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n", | |
" --xr-border-color: var(--jp-border-color2, #e0e0e0);\n", | |
" --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n", | |
" --xr-background-color: var(--jp-layout-color0, white);\n", | |
" --xr-background-color-row-even: var(--jp-layout-color1, white);\n", | |
" --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n", | |
"}\n", | |
"\n", | |
"html[theme=dark],\n", | |
"body[data-theme=dark],\n", | |
"body.vscode-dark {\n", | |
" --xr-font-color0: rgba(255, 255, 255, 1);\n", | |
" --xr-font-color2: rgba(255, 255, 255, 0.54);\n", | |
" --xr-font-color3: rgba(255, 255, 255, 0.38);\n", | |
" --xr-border-color: #1F1F1F;\n", | |
" --xr-disabled-color: #515151;\n", | |
" --xr-background-color: #111111;\n", | |
" --xr-background-color-row-even: #111111;\n", | |
" --xr-background-color-row-odd: #313131;\n", | |
"}\n", | |
"\n", | |
".xr-wrap {\n", | |
" display: block !important;\n", | |
" min-width: 300px;\n", | |
" max-width: 700px;\n", | |
"}\n", | |
"\n", | |
".xr-text-repr-fallback {\n", | |
" /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n", | |
" display: none;\n", | |
"}\n", | |
"\n", | |
".xr-header {\n", | |
" padding-top: 6px;\n", | |
" padding-bottom: 6px;\n", | |
" margin-bottom: 4px;\n", | |
" border-bottom: solid 1px var(--xr-border-color);\n", | |
"}\n", | |
"\n", | |
".xr-header > div,\n", | |
".xr-header > ul {\n", | |
" display: inline;\n", | |
" margin-top: 0;\n", | |
" margin-bottom: 0;\n", | |
"}\n", | |
"\n", | |
".xr-obj-type,\n", | |
".xr-array-name {\n", | |
" margin-left: 2px;\n", | |
" margin-right: 10px;\n", | |
"}\n", | |
"\n", | |
".xr-obj-type {\n", | |
" color: var(--xr-font-color2);\n", | |
"}\n", | |
"\n", | |
".xr-sections {\n", | |
" padding-left: 0 !important;\n", | |
" display: grid;\n", | |
" grid-template-columns: 150px auto auto 1fr 20px 20px;\n", | |
"}\n", | |
"\n", | |
".xr-section-item {\n", | |
" display: contents;\n", | |
"}\n", | |
"\n", | |
".xr-section-item input {\n", | |
" display: none;\n", | |
"}\n", | |
"\n", | |
".xr-section-item input + label {\n", | |
" color: var(--xr-disabled-color);\n", | |
"}\n", | |
"\n", | |
".xr-section-item input:enabled + label {\n", | |
" cursor: pointer;\n", | |
" color: var(--xr-font-color2);\n", | |
"}\n", | |
"\n", | |
".xr-section-item input:enabled + label:hover {\n", | |
" color: var(--xr-font-color0);\n", | |
"}\n", | |
"\n", | |
".xr-section-summary {\n", | |
" grid-column: 1;\n", | |
" color: var(--xr-font-color2);\n", | |
" font-weight: 500;\n", | |
"}\n", | |
"\n", | |
".xr-section-summary > span {\n", | |
" display: inline-block;\n", | |
" padding-left: 0.5em;\n", | |
"}\n", | |
"\n", | |
".xr-section-summary-in:disabled + label {\n", | |
" color: var(--xr-font-color2);\n", | |
"}\n", | |
"\n", | |
".xr-section-summary-in + label:before {\n", | |
" display: inline-block;\n", | |
" content: '►';\n", | |
" font-size: 11px;\n", | |
" width: 15px;\n", | |
" text-align: center;\n", | |
"}\n", | |
"\n", | |
".xr-section-summary-in:disabled + label:before {\n", | |
" color: var(--xr-disabled-color);\n", | |
"}\n", | |
"\n", | |
".xr-section-summary-in:checked + label:before {\n", | |
" content: '▼';\n", | |
"}\n", | |
"\n", | |
".xr-section-summary-in:checked + label > span {\n", | |
" display: none;\n", | |
"}\n", | |
"\n", | |
".xr-section-summary,\n", | |
".xr-section-inline-details {\n", | |
" padding-top: 4px;\n", | |
" padding-bottom: 4px;\n", | |
"}\n", | |
"\n", | |
".xr-section-inline-details {\n", | |
" grid-column: 2 / -1;\n", | |
"}\n", | |
"\n", | |
".xr-section-details {\n", | |
" display: none;\n", | |
" grid-column: 1 / -1;\n", | |
" margin-bottom: 5px;\n", | |
"}\n", | |
"\n", | |
".xr-section-summary-in:checked ~ .xr-section-details {\n", | |
" display: contents;\n", | |
"}\n", | |
"\n", | |
".xr-array-wrap {\n", | |
" grid-column: 1 / -1;\n", | |
" display: grid;\n", | |
" grid-template-columns: 20px auto;\n", | |
"}\n", | |
"\n", | |
".xr-array-wrap > label {\n", | |
" grid-column: 1;\n", | |
" vertical-align: top;\n", | |
"}\n", | |
"\n", | |
".xr-preview {\n", | |
" color: var(--xr-font-color3);\n", | |
"}\n", | |
"\n", | |
".xr-array-preview,\n", | |
".xr-array-data {\n", | |
" padding: 0 5px !important;\n", | |
" grid-column: 2;\n", | |
"}\n", | |
"\n", | |
".xr-array-data,\n", | |
".xr-array-in:checked ~ .xr-array-preview {\n", | |
" display: none;\n", | |
"}\n", | |
"\n", | |
".xr-array-in:checked ~ .xr-array-data,\n", | |
".xr-array-preview {\n", | |
" display: inline-block;\n", | |
"}\n", | |
"\n", | |
".xr-dim-list {\n", | |
" display: inline-block !important;\n", | |
" list-style: none;\n", | |
" padding: 0 !important;\n", | |
" margin: 0;\n", | |
"}\n", | |
"\n", | |
".xr-dim-list li {\n", | |
" display: inline-block;\n", | |
" padding: 0;\n", | |
" margin: 0;\n", | |
"}\n", | |
"\n", | |
".xr-dim-list:before {\n", | |
" content: '(';\n", | |
"}\n", | |
"\n", | |
".xr-dim-list:after {\n", | |
" content: ')';\n", | |
"}\n", | |
"\n", | |
".xr-dim-list li:not(:last-child):after {\n", | |
" content: ',';\n", | |
" padding-right: 5px;\n", | |
"}\n", | |
"\n", | |
".xr-has-index {\n", | |
" font-weight: bold;\n", | |
"}\n", | |
"\n", | |
".xr-var-list,\n", | |
".xr-var-item {\n", | |
" display: contents;\n", | |
"}\n", | |
"\n", | |
".xr-var-item > div,\n", | |
".xr-var-item label,\n", | |
".xr-var-item > .xr-var-name span {\n", | |
" background-color: var(--xr-background-color-row-even);\n", | |
" margin-bottom: 0;\n", | |
"}\n", | |
"\n", | |
".xr-var-item > .xr-var-name:hover span {\n", | |
" padding-right: 5px;\n", | |
"}\n", | |
"\n", | |
".xr-var-list > li:nth-child(odd) > div,\n", | |
".xr-var-list > li:nth-child(odd) > label,\n", | |
".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n", | |
" background-color: var(--xr-background-color-row-odd);\n", | |
"}\n", | |
"\n", | |
".xr-var-name {\n", | |
" grid-column: 1;\n", | |
"}\n", | |
"\n", | |
".xr-var-dims {\n", | |
" grid-column: 2;\n", | |
"}\n", | |
"\n", | |
".xr-var-dtype {\n", | |
" grid-column: 3;\n", | |
" text-align: right;\n", | |
" color: var(--xr-font-color2);\n", | |
"}\n", | |
"\n", | |
".xr-var-preview {\n", | |
" grid-column: 4;\n", | |
"}\n", | |
"\n", | |
".xr-index-preview {\n", | |
" grid-column: 2 / 5;\n", | |
" color: var(--xr-font-color2);\n", | |
"}\n", | |
"\n", | |
".xr-var-name,\n", | |
".xr-var-dims,\n", | |
".xr-var-dtype,\n", | |
".xr-preview,\n", | |
".xr-attrs dt {\n", | |
" white-space: nowrap;\n", | |
" overflow: hidden;\n", | |
" text-overflow: ellipsis;\n", | |
" padding-right: 10px;\n", | |
"}\n", | |
"\n", | |
".xr-var-name:hover,\n", | |
".xr-var-dims:hover,\n", | |
".xr-var-dtype:hover,\n", | |
".xr-attrs dt:hover {\n", | |
" overflow: visible;\n", | |
" width: auto;\n", | |
" z-index: 1;\n", | |
"}\n", | |
"\n", | |
".xr-var-attrs,\n", | |
".xr-var-data,\n", | |
".xr-index-data {\n", | |
" display: none;\n", | |
" background-color: var(--xr-background-color) !important;\n", | |
" padding-bottom: 5px !important;\n", | |
"}\n", | |
"\n", | |
".xr-var-attrs-in:checked ~ .xr-var-attrs,\n", | |
".xr-var-data-in:checked ~ .xr-var-data,\n", | |
".xr-index-data-in:checked ~ .xr-index-data {\n", | |
" display: block;\n", | |
"}\n", | |
"\n", | |
".xr-var-data > table {\n", | |
" float: right;\n", | |
"}\n", | |
"\n", | |
".xr-var-name span,\n", | |
".xr-var-data,\n", | |
".xr-index-name div,\n", | |
".xr-index-data,\n", | |
".xr-attrs {\n", | |
" padding-left: 25px !important;\n", | |
"}\n", | |
"\n", | |
".xr-attrs,\n", | |
".xr-var-attrs,\n", | |
".xr-var-data,\n", | |
".xr-index-data {\n", | |
" grid-column: 1 / -1;\n", | |
"}\n", | |
"\n", | |
"dl.xr-attrs {\n", | |
" padding: 0;\n", | |
" margin: 0;\n", | |
" display: grid;\n", | |
" grid-template-columns: 125px auto;\n", | |
"}\n", | |
"\n", | |
".xr-attrs dt,\n", | |
".xr-attrs dd {\n", | |
" padding: 0;\n", | |
" margin: 0;\n", | |
" float: left;\n", | |
" padding-right: 10px;\n", | |
" width: auto;\n", | |
"}\n", | |
"\n", | |
".xr-attrs dt {\n", | |
" font-weight: normal;\n", | |
" grid-column: 1;\n", | |
"}\n", | |
"\n", | |
".xr-attrs dt:hover span {\n", | |
" display: inline-block;\n", | |
" background: var(--xr-background-color);\n", | |
" padding-right: 10px;\n", | |
"}\n", | |
"\n", | |
".xr-attrs dd {\n", | |
" grid-column: 2;\n", | |
" white-space: pre-wrap;\n", | |
" word-break: break-all;\n", | |
"}\n", | |
"\n", | |
".xr-icon-database,\n", | |
".xr-icon-file-text2,\n", | |
".xr-no-icon {\n", | |
" display: inline-block;\n", | |
" vertical-align: middle;\n", | |
" width: 1em;\n", | |
" height: 1.5em !important;\n", | |
" stroke-width: 0;\n", | |
" stroke: currentColor;\n", | |
" fill: currentColor;\n", | |
"}\n", | |
"</style><pre class='xr-text-repr-fallback'><xarray.Dataset> Size: 520B\n", | |
"Dimensions: (timestamps: 10, electrodes: 5)\n", | |
"Coordinates:\n", | |
" * electrodes (electrodes) int64 40B 0 1 2 3 4\n", | |
" * timestamps (timestamps) timedelta64[ns] 80B 00:00:00 00:00:01 ... 00:00:09\n", | |
"Data variables:\n", | |
" data (timestamps, electrodes) float64 400B ...\n", | |
"Attributes:\n", | |
" comments: no comments\n", | |
" description: description\n", | |
" filtering: filtering\n", | |
" namespace: core\n", | |
" neurodata_type: ElectricalSeries\n", | |
" object_id: f7696ed3-2c80-4fb4-b284-5469e2c11a6c</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.Dataset</div></div><ul class='xr-sections'><li class='xr-section-item'><input id='section-d03e5f1a-dc53-4340-a842-67060ced9b29' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-d03e5f1a-dc53-4340-a842-67060ced9b29' class='xr-section-summary' title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span class='xr-has-index'>timestamps</span>: 10</li><li><span class='xr-has-index'>electrodes</span>: 5</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-f8538712-1a2d-4697-8b76-25c7fc8888cc' class='xr-section-summary-in' type='checkbox' checked><label for='section-f8538712-1a2d-4697-8b76-25c7fc8888cc' class='xr-section-summary' >Coordinates: <span>(2)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>electrodes</span></div><div class='xr-var-dims'>(electrodes)</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>0 1 2 3 4</div><input id='attrs-c861e7cb-6b0b-4582-89da-948367379172' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-c861e7cb-6b0b-4582-89da-948367379172' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-0d077244-9750-45b0-b509-6b7815850c19' class='xr-var-data-in' type='checkbox'><label for='data-0d077244-9750-45b0-b509-6b7815850c19' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>description :</span></dt><dd>the first and third electrodes</dd><dt><span>namespace :</span></dt><dd>hdmf-common</dd><dt><span>neurodata_type :</span></dt><dd>DynamicTableRegion</dd><dt><span>object_id :</span></dt><dd>65b98b43-3cfc-4774-bf05-ca342c9c624a</dd><dt><span>table :</span></dt><dd>{'_REFERENCE': {'object_id': '5307b610-47dc-43cb-b6b4-02dbfb98bcf0', 'path': '/general/extracellular_ephys/electrodes', 'source': '.', 'source_object_id': 'fe8ec11f-9737-4368-b87b-6fcf24c256f6'}}</dd></dl></div><div class='xr-var-data'><pre>array([0, 1, 2, 3, 4])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>timestamps</span></div><div class='xr-var-dims'>(timestamps)</div><div class='xr-var-dtype'>timedelta64[ns]</div><div class='xr-var-preview xr-preview'>00:00:00 00:00:01 ... 00:00:09</div><input id='attrs-e73c1e50-4bef-42e3-b075-b12f2598b0c0' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-e73c1e50-4bef-42e3-b075-b12f2598b0c0' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-66cfce00-4d8b-4c93-b6d9-6d4893e673e6' class='xr-var-data-in' type='checkbox'><label for='data-66cfce00-4d8b-4c93-b6d9-6d4893e673e6' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>interval :</span></dt><dd>1</dd><dt><span>unit :</span></dt><dd>seconds</dd></dl></div><div class='xr-var-data'><pre>array([ 0, 1000000000, 2000000000, 3000000000, 4000000000, 5000000000,\n", | |
" 6000000000, 7000000000, 8000000000, 9000000000], dtype='timedelta64[ns]')</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-82229590-eee1-4ca5-9809-8e88ff22eac4' class='xr-section-summary-in' type='checkbox' checked><label for='section-82229590-eee1-4ca5-9809-8e88ff22eac4' class='xr-section-summary' >Data variables: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span>data</span></div><div class='xr-var-dims'>(timestamps, electrodes)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>...</div><input id='attrs-c5194ea7-35a1-4d43-b0e5-c98777146ad6' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-c5194ea7-35a1-4d43-b0e5-c98777146ad6' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-771d3ea4-40b2-4e36-a971-afe14c2e7668' class='xr-var-data-in' type='checkbox'><label for='data-771d3ea4-40b2-4e36-a971-afe14c2e7668' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>conversion :</span></dt><dd>10.0</dd><dt><span>offset :</span></dt><dd>1.0</dd><dt><span>resolution :</span></dt><dd>-1.0</dd><dt><span>unit :</span></dt><dd>volts</dd><dt><span>units :</span></dt><dd>volts</dd></dl></div><div class='xr-var-data'><pre>[50 values with dtype=float64]</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-3fadf812-e364-43c9-ad6f-129eb5d3f879' class='xr-section-summary-in' type='checkbox' ><label for='section-3fadf812-e364-43c9-ad6f-129eb5d3f879' class='xr-section-summary' >Indexes: <span>(2)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-index-name'><div>electrodes</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-ddfdb7d3-c007-4c12-9484-76c8bea16107' class='xr-index-data-in' type='checkbox'/><label for='index-ddfdb7d3-c007-4c12-9484-76c8bea16107' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index([0, 1, 2, 3, 4], dtype='int64', name='electrodes'))</pre></div></li><li class='xr-var-item'><div class='xr-index-name'><div>timestamps</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-08c573a4-8276-4668-ad64-b447d27168b0' class='xr-index-data-in' type='checkbox'/><label for='index-08c573a4-8276-4668-ad64-b447d27168b0' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(TimedeltaIndex(['0 days 00:00:00', '0 days 00:00:01', '0 days 00:00:02',\n", | |
" '0 days 00:00:03', '0 days 00:00:04', '0 days 00:00:05',\n", | |
" '0 days 00:00:06', '0 days 00:00:07', '0 days 00:00:08',\n", | |
" '0 days 00:00:09'],\n", | |
" dtype='timedelta64[ns]', name='timestamps', freq=None))</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-52585101-a6c2-471f-8ffd-01a7a6419e07' class='xr-section-summary-in' type='checkbox' checked><label for='section-52585101-a6c2-471f-8ffd-01a7a6419e07' class='xr-section-summary' >Attributes: <span>(6)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>comments :</span></dt><dd>no comments</dd><dt><span>description :</span></dt><dd>description</dd><dt><span>filtering :</span></dt><dd>filtering</dd><dt><span>namespace :</span></dt><dd>core</dd><dt><span>neurodata_type :</span></dt><dd>ElectricalSeries</dd><dt><span>object_id :</span></dt><dd>f7696ed3-2c80-4fb4-b284-5469e2c11a6c</dd></dl></div></li></ul></div></div>" | |
], | |
"text/plain": [ | |
"<xarray.Dataset> Size: 520B\n", | |
"Dimensions: (timestamps: 10, electrodes: 5)\n", | |
"Coordinates:\n", | |
" * electrodes (electrodes) int64 40B 0 1 2 3 4\n", | |
" * timestamps (timestamps) timedelta64[ns] 80B 00:00:00 00:00:01 ... 00:00:09\n", | |
"Data variables:\n", | |
" data (timestamps, electrodes) float64 400B ...\n", | |
"Attributes:\n", | |
" comments: no comments\n", | |
" description: description\n", | |
" filtering: filtering\n", | |
" namespace: core\n", | |
" neurodata_type: ElectricalSeries\n", | |
" object_id: f7696ed3-2c80-4fb4-b284-5469e2c11a6c" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dset" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"id": "055a06b8-c3db-4199-8732-97ecd98841aa", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"{'chunks': (10, 5),\n", | |
" 'preferred_chunks': {'timestamps': 10, 'electrodes': 5},\n", | |
" 'compressor': None,\n", | |
" 'filters': None,\n", | |
" 'scale_factor': 10.0,\n", | |
" 'add_offset': 1.0,\n", | |
" 'dtype': dtype('int64')}" | |
] | |
}, | |
"execution_count": 9, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dset.data.encoding" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"id": "e2ea94c2-c0d5-4e37-88b6-513441e4dd32", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([[ 1., 11., 21., 31., 41.],\n", | |
" [ 51., 61., 71., 81., 91.],\n", | |
" [101., 111., 121., 131., 141.],\n", | |
" [151., 161., 171., 181., 191.],\n", | |
" [201., 211., 221., 231., 241.],\n", | |
" [251., 261., 271., 281., 291.],\n", | |
" [301., 311., 321., 331., 341.],\n", | |
" [351., 361., 371., 381., 391.],\n", | |
" [401., 411., 421., 431., 441.],\n", | |
" [451., 461., 471., 481., 491.]])" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dset.data.data" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"id": "5029b467", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([[ 1., 11., 21., 31., 41.],\n", | |
" [ 51., 61., 71., 81., 91.],\n", | |
" [101., 111., 121., 131., 141.],\n", | |
" [151., 161., 171., 181., 191.],\n", | |
" [201., 211., 221., 231., 241.],\n", | |
" [251., 261., 271., 281., 291.],\n", | |
" [301., 311., 321., 331., 341.],\n", | |
" [351., 361., 371., 381., 391.],\n", | |
" [401., 411., 421., 431., 441.],\n", | |
" [451., 461., 471., 481., 491.]])" | |
] | |
}, | |
"execution_count": 11, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"with NWBHDF5IO(nwb_file_path, \"r\") as io:\n", | |
" nwb = io.read()\n", | |
" es_data_read = nwb.acquisition[\"ElectricalSeries\"].get_data_in_units()\n", | |
"es_data_read" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"id": "733f4aaf", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([[ True, True, True, True, True],\n", | |
" [ True, True, True, True, True],\n", | |
" [ True, True, True, True, True],\n", | |
" [ True, True, True, True, True],\n", | |
" [ True, True, True, True, True],\n", | |
" [ True, True, True, True, True],\n", | |
" [ True, True, True, True, True],\n", | |
" [ True, True, True, True, True],\n", | |
" [ True, True, True, True, True],\n", | |
" [ True, True, True, True, True]])" | |
] | |
}, | |
"execution_count": 12, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dset.data.data == es_data_read" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"id": "41ad0abf-8d88-48db-b4e4-d2ebd098314e", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n", | |
"<defs>\n", | |
"<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n", | |
"<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n", | |
"<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n", | |
"<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n", | |
"</symbol>\n", | |
"<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n", | |
"<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n", | |
"<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n", | |
"<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n", | |
"<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n", | |
"</symbol>\n", | |
"</defs>\n", | |
"</svg>\n", | |
"<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n", | |
" *\n", | |
" */\n", | |
"\n", | |
":root {\n", | |
" --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n", | |
" --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n", | |
" --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n", | |
" --xr-border-color: var(--jp-border-color2, #e0e0e0);\n", | |
" --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n", | |
" --xr-background-color: var(--jp-layout-color0, white);\n", | |
" --xr-background-color-row-even: var(--jp-layout-color1, white);\n", | |
" --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n", | |
"}\n", | |
"\n", | |
"html[theme=dark],\n", | |
"body[data-theme=dark],\n", | |
"body.vscode-dark {\n", | |
" --xr-font-color0: rgba(255, 255, 255, 1);\n", | |
" --xr-font-color2: rgba(255, 255, 255, 0.54);\n", | |
" --xr-font-color3: rgba(255, 255, 255, 0.38);\n", | |
" --xr-border-color: #1F1F1F;\n", | |
" --xr-disabled-color: #515151;\n", | |
" --xr-background-color: #111111;\n", | |
" --xr-background-color-row-even: #111111;\n", | |
" --xr-background-color-row-odd: #313131;\n", | |
"}\n", | |
"\n", | |
".xr-wrap {\n", | |
" display: block !important;\n", | |
" min-width: 300px;\n", | |
" max-width: 700px;\n", | |
"}\n", | |
"\n", | |
".xr-text-repr-fallback {\n", | |
" /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n", | |
" display: none;\n", | |
"}\n", | |
"\n", | |
".xr-header {\n", | |
" padding-top: 6px;\n", | |
" padding-bottom: 6px;\n", | |
" margin-bottom: 4px;\n", | |
" border-bottom: solid 1px var(--xr-border-color);\n", | |
"}\n", | |
"\n", | |
".xr-header > div,\n", | |
".xr-header > ul {\n", | |
" display: inline;\n", | |
" margin-top: 0;\n", | |
" margin-bottom: 0;\n", | |
"}\n", | |
"\n", | |
".xr-obj-type,\n", | |
".xr-array-name {\n", | |
" margin-left: 2px;\n", | |
" margin-right: 10px;\n", | |
"}\n", | |
"\n", | |
".xr-obj-type {\n", | |
" color: var(--xr-font-color2);\n", | |
"}\n", | |
"\n", | |
".xr-sections {\n", | |
" padding-left: 0 !important;\n", | |
" display: grid;\n", | |
" grid-template-columns: 150px auto auto 1fr 20px 20px;\n", | |
"}\n", | |
"\n", | |
".xr-section-item {\n", | |
" display: contents;\n", | |
"}\n", | |
"\n", | |
".xr-section-item input {\n", | |
" display: none;\n", | |
"}\n", | |
"\n", | |
".xr-section-item input + label {\n", | |
" color: var(--xr-disabled-color);\n", | |
"}\n", | |
"\n", | |
".xr-section-item input:enabled + label {\n", | |
" cursor: pointer;\n", | |
" color: var(--xr-font-color2);\n", | |
"}\n", | |
"\n", | |
".xr-section-item input:enabled + label:hover {\n", | |
" color: var(--xr-font-color0);\n", | |
"}\n", | |
"\n", | |
".xr-section-summary {\n", | |
" grid-column: 1;\n", | |
" color: var(--xr-font-color2);\n", | |
" font-weight: 500;\n", | |
"}\n", | |
"\n", | |
".xr-section-summary > span {\n", | |
" display: inline-block;\n", | |
" padding-left: 0.5em;\n", | |
"}\n", | |
"\n", | |
".xr-section-summary-in:disabled + label {\n", | |
" color: var(--xr-font-color2);\n", | |
"}\n", | |
"\n", | |
".xr-section-summary-in + label:before {\n", | |
" display: inline-block;\n", | |
" content: '►';\n", | |
" font-size: 11px;\n", | |
" width: 15px;\n", | |
" text-align: center;\n", | |
"}\n", | |
"\n", | |
".xr-section-summary-in:disabled + label:before {\n", | |
" color: var(--xr-disabled-color);\n", | |
"}\n", | |
"\n", | |
".xr-section-summary-in:checked + label:before {\n", | |
" content: '▼';\n", | |
"}\n", | |
"\n", | |
".xr-section-summary-in:checked + label > span {\n", | |
" display: none;\n", | |
"}\n", | |
"\n", | |
".xr-section-summary,\n", | |
".xr-section-inline-details {\n", | |
" padding-top: 4px;\n", | |
" padding-bottom: 4px;\n", | |
"}\n", | |
"\n", | |
".xr-section-inline-details {\n", | |
" grid-column: 2 / -1;\n", | |
"}\n", | |
"\n", | |
".xr-section-details {\n", | |
" display: none;\n", | |
" grid-column: 1 / -1;\n", | |
" margin-bottom: 5px;\n", | |
"}\n", | |
"\n", | |
".xr-section-summary-in:checked ~ .xr-section-details {\n", | |
" display: contents;\n", | |
"}\n", | |
"\n", | |
".xr-array-wrap {\n", | |
" grid-column: 1 / -1;\n", | |
" display: grid;\n", | |
" grid-template-columns: 20px auto;\n", | |
"}\n", | |
"\n", | |
".xr-array-wrap > label {\n", | |
" grid-column: 1;\n", | |
" vertical-align: top;\n", | |
"}\n", | |
"\n", | |
".xr-preview {\n", | |
" color: var(--xr-font-color3);\n", | |
"}\n", | |
"\n", | |
".xr-array-preview,\n", | |
".xr-array-data {\n", | |
" padding: 0 5px !important;\n", | |
" grid-column: 2;\n", | |
"}\n", | |
"\n", | |
".xr-array-data,\n", | |
".xr-array-in:checked ~ .xr-array-preview {\n", | |
" display: none;\n", | |
"}\n", | |
"\n", | |
".xr-array-in:checked ~ .xr-array-data,\n", | |
".xr-array-preview {\n", | |
" display: inline-block;\n", | |
"}\n", | |
"\n", | |
".xr-dim-list {\n", | |
" display: inline-block !important;\n", | |
" list-style: none;\n", | |
" padding: 0 !important;\n", | |
" margin: 0;\n", | |
"}\n", | |
"\n", | |
".xr-dim-list li {\n", | |
" display: inline-block;\n", | |
" padding: 0;\n", | |
" margin: 0;\n", | |
"}\n", | |
"\n", | |
".xr-dim-list:before {\n", | |
" content: '(';\n", | |
"}\n", | |
"\n", | |
".xr-dim-list:after {\n", | |
" content: ')';\n", | |
"}\n", | |
"\n", | |
".xr-dim-list li:not(:last-child):after {\n", | |
" content: ',';\n", | |
" padding-right: 5px;\n", | |
"}\n", | |
"\n", | |
".xr-has-index {\n", | |
" font-weight: bold;\n", | |
"}\n", | |
"\n", | |
".xr-var-list,\n", | |
".xr-var-item {\n", | |
" display: contents;\n", | |
"}\n", | |
"\n", | |
".xr-var-item > div,\n", | |
".xr-var-item label,\n", | |
".xr-var-item > .xr-var-name span {\n", | |
" background-color: var(--xr-background-color-row-even);\n", | |
" margin-bottom: 0;\n", | |
"}\n", | |
"\n", | |
".xr-var-item > .xr-var-name:hover span {\n", | |
" padding-right: 5px;\n", | |
"}\n", | |
"\n", | |
".xr-var-list > li:nth-child(odd) > div,\n", | |
".xr-var-list > li:nth-child(odd) > label,\n", | |
".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n", | |
" background-color: var(--xr-background-color-row-odd);\n", | |
"}\n", | |
"\n", | |
".xr-var-name {\n", | |
" grid-column: 1;\n", | |
"}\n", | |
"\n", | |
".xr-var-dims {\n", | |
" grid-column: 2;\n", | |
"}\n", | |
"\n", | |
".xr-var-dtype {\n", | |
" grid-column: 3;\n", | |
" text-align: right;\n", | |
" color: var(--xr-font-color2);\n", | |
"}\n", | |
"\n", | |
".xr-var-preview {\n", | |
" grid-column: 4;\n", | |
"}\n", | |
"\n", | |
".xr-index-preview {\n", | |
" grid-column: 2 / 5;\n", | |
" color: var(--xr-font-color2);\n", | |
"}\n", | |
"\n", | |
".xr-var-name,\n", | |
".xr-var-dims,\n", | |
".xr-var-dtype,\n", | |
".xr-preview,\n", | |
".xr-attrs dt {\n", | |
" white-space: nowrap;\n", | |
" overflow: hidden;\n", | |
" text-overflow: ellipsis;\n", | |
" padding-right: 10px;\n", | |
"}\n", | |
"\n", | |
".xr-var-name:hover,\n", | |
".xr-var-dims:hover,\n", | |
".xr-var-dtype:hover,\n", | |
".xr-attrs dt:hover {\n", | |
" overflow: visible;\n", | |
" width: auto;\n", | |
" z-index: 1;\n", | |
"}\n", | |
"\n", | |
".xr-var-attrs,\n", | |
".xr-var-data,\n", | |
".xr-index-data {\n", | |
" display: none;\n", | |
" background-color: var(--xr-background-color) !important;\n", | |
" padding-bottom: 5px !important;\n", | |
"}\n", | |
"\n", | |
".xr-var-attrs-in:checked ~ .xr-var-attrs,\n", | |
".xr-var-data-in:checked ~ .xr-var-data,\n", | |
".xr-index-data-in:checked ~ .xr-index-data {\n", | |
" display: block;\n", | |
"}\n", | |
"\n", | |
".xr-var-data > table {\n", | |
" float: right;\n", | |
"}\n", | |
"\n", | |
".xr-var-name span,\n", | |
".xr-var-data,\n", | |
".xr-index-name div,\n", | |
".xr-index-data,\n", | |
".xr-attrs {\n", | |
" padding-left: 25px !important;\n", | |
"}\n", | |
"\n", | |
".xr-attrs,\n", | |
".xr-var-attrs,\n", | |
".xr-var-data,\n", | |
".xr-index-data {\n", | |
" grid-column: 1 / -1;\n", | |
"}\n", | |
"\n", | |
"dl.xr-attrs {\n", | |
" padding: 0;\n", | |
" margin: 0;\n", | |
" display: grid;\n", | |
" grid-template-columns: 125px auto;\n", | |
"}\n", | |
"\n", | |
".xr-attrs dt,\n", | |
".xr-attrs dd {\n", | |
" padding: 0;\n", | |
" margin: 0;\n", | |
" float: left;\n", | |
" padding-right: 10px;\n", | |
" width: auto;\n", | |
"}\n", | |
"\n", | |
".xr-attrs dt {\n", | |
" font-weight: normal;\n", | |
" grid-column: 1;\n", | |
"}\n", | |
"\n", | |
".xr-attrs dt:hover span {\n", | |
" display: inline-block;\n", | |
" background: var(--xr-background-color);\n", | |
" padding-right: 10px;\n", | |
"}\n", | |
"\n", | |
".xr-attrs dd {\n", | |
" grid-column: 2;\n", | |
" white-space: pre-wrap;\n", | |
" word-break: break-all;\n", | |
"}\n", | |
"\n", | |
".xr-icon-database,\n", | |
".xr-icon-file-text2,\n", | |
".xr-no-icon {\n", | |
" display: inline-block;\n", | |
" vertical-align: middle;\n", | |
" width: 1em;\n", | |
" height: 1.5em !important;\n", | |
" stroke-width: 0;\n", | |
" stroke: currentColor;\n", | |
" fill: currentColor;\n", | |
"}\n", | |
"</style><pre class='xr-text-repr-fallback'><xarray.DataArray 'electrodes' (electrodes: 5)> Size: 40B\n", | |
"array([0, 1, 2, 3, 4])\n", | |
"Coordinates:\n", | |
" * electrodes (electrodes) int64 40B 0 1 2 3 4\n", | |
"Attributes:\n", | |
" description: the first and third electrodes\n", | |
" namespace: hdmf-common\n", | |
" neurodata_type: DynamicTableRegion\n", | |
" object_id: 65b98b43-3cfc-4774-bf05-ca342c9c624a\n", | |
" table: {'_REFERENCE': {'object_id': '5307b610-47dc-43cb-b6b4-02...</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'>'electrodes'</div><ul class='xr-dim-list'><li><span class='xr-has-index'>electrodes</span>: 5</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-57313175-5b6c-43e4-a4b0-cf8d5427c75e' class='xr-array-in' type='checkbox' checked><label for='section-57313175-5b6c-43e4-a4b0-cf8d5427c75e' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>0 1 2 3 4</span></div><div class='xr-array-data'><pre>array([0, 1, 2, 3, 4])</pre></div></div></li><li class='xr-section-item'><input id='section-4619128f-5643-44e9-9f76-990507889445' class='xr-section-summary-in' type='checkbox' checked><label for='section-4619128f-5643-44e9-9f76-990507889445' class='xr-section-summary' >Coordinates: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>electrodes</span></div><div class='xr-var-dims'>(electrodes)</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>0 1 2 3 4</div><input id='attrs-7d1b1c24-e3d0-4398-b871-cffdcc1b38db' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-7d1b1c24-e3d0-4398-b871-cffdcc1b38db' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-a4050641-c3cd-4065-a73c-de83d000a04e' class='xr-var-data-in' type='checkbox'><label for='data-a4050641-c3cd-4065-a73c-de83d000a04e' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>description :</span></dt><dd>the first and third electrodes</dd><dt><span>namespace :</span></dt><dd>hdmf-common</dd><dt><span>neurodata_type :</span></dt><dd>DynamicTableRegion</dd><dt><span>object_id :</span></dt><dd>65b98b43-3cfc-4774-bf05-ca342c9c624a</dd><dt><span>table :</span></dt><dd>{'_REFERENCE': {'object_id': '5307b610-47dc-43cb-b6b4-02dbfb98bcf0', 'path': '/general/extracellular_ephys/electrodes', 'source': '.', 'source_object_id': 'fe8ec11f-9737-4368-b87b-6fcf24c256f6'}}</dd></dl></div><div class='xr-var-data'><pre>array([0, 1, 2, 3, 4])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-cd02c243-c6f4-42c0-8f55-6ea2a8c757ce' class='xr-section-summary-in' type='checkbox' ><label for='section-cd02c243-c6f4-42c0-8f55-6ea2a8c757ce' class='xr-section-summary' >Indexes: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-index-name'><div>electrodes</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-9933a363-bd7d-41fa-be9b-3de81e4d363c' class='xr-index-data-in' type='checkbox'/><label for='index-9933a363-bd7d-41fa-be9b-3de81e4d363c' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index([0, 1, 2, 3, 4], dtype='int64', name='electrodes'))</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-2e5b4129-0f72-46cd-b012-d685be84416a' class='xr-section-summary-in' type='checkbox' checked><label for='section-2e5b4129-0f72-46cd-b012-d685be84416a' class='xr-section-summary' >Attributes: <span>(5)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>description :</span></dt><dd>the first and third electrodes</dd><dt><span>namespace :</span></dt><dd>hdmf-common</dd><dt><span>neurodata_type :</span></dt><dd>DynamicTableRegion</dd><dt><span>object_id :</span></dt><dd>65b98b43-3cfc-4774-bf05-ca342c9c624a</dd><dt><span>table :</span></dt><dd>{'_REFERENCE': {'object_id': '5307b610-47dc-43cb-b6b4-02dbfb98bcf0', 'path': '/general/extracellular_ephys/electrodes', 'source': '.', 'source_object_id': 'fe8ec11f-9737-4368-b87b-6fcf24c256f6'}}</dd></dl></div></li></ul></div></div>" | |
], | |
"text/plain": [ | |
"<xarray.DataArray 'electrodes' (electrodes: 5)> Size: 40B\n", | |
"array([0, 1, 2, 3, 4])\n", | |
"Coordinates:\n", | |
" * electrodes (electrodes) int64 40B 0 1 2 3 4\n", | |
"Attributes:\n", | |
" description: the first and third electrodes\n", | |
" namespace: hdmf-common\n", | |
" neurodata_type: DynamicTableRegion\n", | |
" object_id: 65b98b43-3cfc-4774-bf05-ca342c9c624a\n", | |
" table: {'_REFERENCE': {'object_id': '5307b610-47dc-43cb-b6b4-02..." | |
] | |
}, | |
"execution_count": 13, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"dset.electrodes" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"id": "62fa724a-6a92-420c-82bc-3120d7a10c12", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([0, 1, 2, 3, 4])" | |
] | |
}, | |
"execution_count": 14, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"import zarr\n", | |
"storage_opts = {\n", | |
" \"fo\": rfs_electrical_series_only,\n", | |
"}\n", | |
"z = zarr.open(\"reference://\", storage_options=storage_opts)\n", | |
"z[\"electrodes\"][:]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "f7164d0f-d3c0-4cab-b3b5-631bc19fd30c", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3 (ipykernel)", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.11.8" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment