Skip to content

Commit

Permalink
Brunton brains (#141)
Browse files Browse the repository at this point in the history
* Fixed indexing error in brains module

Small indexing error when concatenating the electrode positions to plot them.

* Update to color electrodes by R2

Added code to color electrodes by R2.

* Simplify colors for grid location

Realized I already had the color array I needed for grid location coloring.

* Generalize coloring by any column in electrode table

Switched out radio button for dropdown menu that automatically populates using all the column names in the electrodes table.  Handles different data types and prints error message if column is selected that does not have a valid data type for coloring.

* Dynamically show legend of color bar

Show legend if visualizing a categorical value and color if visualizing a continuous variable.

* Notebook for binder testing / edits during mtg w/ Ben

* Setup postbuild for streaming nwb on binder

* Revert "Setup postbuild for streaming nwb on binder"

This reverts commit b3a80d0.

* Generalize electrode coloring to include 'bytes' datatype

* Fix widget control layout

* Fix layout for dashboard

Commented this line out because it was causing formatting issues in the Brunton dashboard

* Decrease fig size for Brunton dashboard

Decreasing electrical series trace fig size to fit in Brunton dashboard better

* Make traces same color

Update SeparateTraces widget to have same color across traces

Co-authored-by: Michael Scheid <[email protected]>
Co-authored-by: Ben Dichter <[email protected]>
  • Loading branch information
3 people authored Apr 9, 2021
1 parent 1ef766e commit fdb9016
Show file tree
Hide file tree
Showing 3 changed files with 388 additions and 33 deletions.
294 changes: 294 additions & 0 deletions brains_widget_BruntonLab.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"cd C:\\Users\\micha\\Dropbox\\Catalyst Neuro\\repos\\nwb-jupyter-widgets"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from pynwb import NWBHDF5IO\n",
"from nwbwidgets.brains import HumanElectrodesPlotlyWidget\n",
"from nwbwidgets.utils.timeseries import get_timeseries_tt\n",
"import numpy as np\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from datetime import datetime\n",
"from ndx_events import LabeledEvents, AnnotatedEventsTable, Events\n",
"\n",
"io = NWBHDF5IO(r'C:\\Users\\micha\\Desktop\\Brunton Lab Data\\H5\\subj_01_day_3.nwb', mode='r')\n",
"nwb = io.read()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ffeb489c5533482aa5df02ba564f494e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HumanElectrodesPlotlyWidget(children=(FigureWidget({\n",
" 'data': [{'color': 'lightgray',\n",
" 'hoveri…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"HumanElectrodesPlotlyWidget(nwb.electrodes)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 0\n"
]
}
],
"source": [
"for i, n in enumerate([0]):\n",
" print(i, n)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"a = np.array([x for x in range(3)])"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0, 1, 2])"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"b = np.array([1, 1, 1])"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0, 1, 2])"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a[b == 1]"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['x',\n",
" 'y',\n",
" 'z',\n",
" 'imp',\n",
" 'location',\n",
" 'filtering',\n",
" 'group',\n",
" 'group_name',\n",
" 'standard_deviation',\n",
" 'kurtosis',\n",
" 'median_deviation',\n",
" 'good',\n",
" 'low_freq_R2',\n",
" 'high_freq_R2']"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(nwb.electrodes.colnames)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([ True, True, True, True, True, True, True, True, True,\n",
" True, True, True, True, True, True, True, True, True,\n",
" True, True, True, True, True, True, True, True, True,\n",
" True, True, True, True, True, True, True, True, True,\n",
" True, True, True, True, True, True, True, True, True,\n",
" True, True, True, True, True, True, True, True, True,\n",
" True, True, True, True, True, True, True, True, True,\n",
" True, True, True, True, True, True, True, True, True,\n",
" True, True, True, True, True, True, True, True, True,\n",
" True, True, True, True, True, True, True, True, True,\n",
" True, True, True, True])"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"nwb.electrodes['good'][:]"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"numpy.bool_"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(nwb.electrodes['good'][0])"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"isinstance(nwb.electrodes['x'][0], np.float)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"numpy.float64"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(nwb.electrodes['z'][0])"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading

0 comments on commit fdb9016

Please sign in to comment.