Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.3 #120

Merged
merged 4 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions examples/Example_EEG_NYHead.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
"metadata": {},
"source": [
"# Example EEG signals from New York Head model\n",
"Demonstration of EEG predictions from single synaptic input, using a complex head model "
"Demonstration of EEG signal predictions using a complex head model, resulting from single synaptic input onto multicompartment neuron mode set up in LFPy (https://LFPy.readthedocs.io, https://github.com/LFPy/LFPy).\n",
"\n",
"The simulation is broken down in a few steps:\n",
"\n",
"1. Simulate the neuron model and record all transmembrane currents with LFPy\n",
"2. Compute the current dipole moment **P** from transmembrane currents using the `lfpykit.CurrentDipoleMoment` class\n",
"3. Position the dipole and compute the resulting extracellular potential on the scalp (EEG) from **P** using the `lfpykit.eegmegcalc.NYHeadModel` class"
]
},
{
Expand All @@ -25,8 +31,8 @@
"source": [
"## if running on mybinder or similar, uncomment and run the two following lines to install LFPy. \n",
"## Then restart the kernel.\n",
"#!conda install mpi4py -y\n",
"#!pip install -e git+https://github.com/LFPy/LFPy.git@master#egg=LFPy"
"# !conda install mpi4py -y\n",
"# !pip install -e git+https://github.com/LFPy/LFPy.git@master#egg=LFPy"
]
},
{
Expand Down Expand Up @@ -63,7 +69,7 @@
"cell.simulate(rec_imem=True)\n",
"\n",
"# calculate current dipole moment\n",
"cdm = CurrentDipoleMoment(cell=cell)\n",
"cdm = c(cell=cell)\n",
"p = cdm.get_transformation_matrix() @ cell.imem"
]
},
Expand Down Expand Up @@ -148,18 +154,7 @@
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"New York head model not found: /Users/ehagen/anaconda3/envs/lfpy/lib/python3.8/site-packages/lfpykit/sa_nyhead.mat\n",
"Should it be downloaded (710 MB)? [y/n]: y\n",
"Now downloading. This might take a while ...\n",
"Download done!\n"
]
}
],
"outputs": [],
"source": [
"nyhead = NYHeadModel()\n",
"\n",
Expand Down Expand Up @@ -187,7 +182,7 @@
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x13dbe4e50>]"
"[<matplotlib.lines.Line2D at 0x142128850>]"
]
},
"execution_count": 7,
Expand Down Expand Up @@ -316,7 +311,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.6"
"version": "3.9.1"
}
},
"nbformat": 4,
Expand Down
36 changes: 17 additions & 19 deletions examples/Example_LFPy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
"source": [
"# Example LFPy\n",
"Example utilizing the LFPy forward models module for predictions of\n",
"current dipole moment from a dendritic stick model set up in LFPy.\n",
"current dipole moment from a dendritic stick model set up in LFPy (https://LFPy.readthedocs.io, https://github.com/LFPy/LFPy).\n",
"The passive stick receives sinusoid synaptic current input at its terminal\n",
"segment."
"segment.\n",
"\n",
"This example is equivalent to the `Example_NEURON.ipynb` notebook. "
]
},
{
Expand All @@ -28,8 +30,8 @@
"source": [
"## if running on mybinder or similar, uncomment and run the two following lines to install LFPy. \n",
"## Then restart the kernel.\n",
"#!conda install mpi4py -y\n",
"#!pip install -e git+https://github.com/LFPy/LFPy.git@master#egg=LFPy"
"# !conda install mpi4py -y\n",
"# !pip install -e git+https://github.com/LFPy/LFPy.git@master#egg=LFPy"
]
},
{
Expand All @@ -43,21 +45,17 @@
"text": [
"/usr/bin/xcrun\n",
"/Users/ehagen/Repositories/LFPykit/examples\n",
"sinsyn.mod\n",
"sinsyn.mod\n",
"-n Mod files:\n",
"-n \"./sinsyn.mod\"\n",
"\n",
"\n",
"COBJS=''\n",
" -> \u001b[32mCompiling\u001b[0m mod_func.c\n",
"x86_64-apple-darwin13.4.0-clang -O2 -I. -I.. -I/Users/ehagen/anaconda3/envs/lfpy/lib/python3.8/site-packages/neuron/.data/include -I/usr/local/Cellar/open-mpi/4.0.4_1/include -fPIC -c mod_func.c -o mod_func.o\n",
" -> \u001b[32mNMODL\u001b[0m sinsyn.mod\n",
"MODLUNIT=/Users/ehagen/anaconda3/envs/lfpy/lib/python3.8/site-packages/neuron/.data/share/nrn/lib/nrnunits.lib \\\n",
"\t /Users/ehagen/anaconda3/envs/lfpy/lib/python3.8/site-packages/neuron/.data/bin/nocmodl sinsyn.mod\n",
"Translating sinsyn.mod into sinsyn.c\n",
"Thread Safe\n",
" -> \u001b[32mCompiling\u001b[0m x86_64/sinsyn.c\n",
"(cd .. ; x86_64-apple-darwin13.4.0-clang -O2 -I. -I.. -I/Users/ehagen/anaconda3/envs/lfpy/lib/python3.8/site-packages/neuron/.data/include -I/usr/local/Cellar/open-mpi/4.0.4_1/include -fPIC -c x86_64/sinsyn.c -o x86_64/sinsyn.o)\n",
" => \u001b[32mLINKING\u001b[0m library x86_64/libnrnmech.dylib Mod files: sinsyn.mod\n",
"(cd .. ; x86_64-apple-darwin13.4.0-clang++ -O2 -DVERSION_INFO='7.8.1.1' -std=c++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -fPIC -I /Users/ehagen/anaconda3/envs/lfpy/lib/python3.8/site-packages/neuron/.data/include -o x86_64/libnrnmech.dylib -Wl,-install_name,@rpath/libnrnmech.dylib \\\n",
"\t x86_64/mod_func.o x86_64/sinsyn.o -L/Users/ehagen/anaconda3/envs/lfpy/lib/python3.8/site-packages/neuron/.data/lib -lnrniv -Wl,-rpath,/Users/ehagen/anaconda3/envs/lfpy/lib/python3.8/site-packages/neuron/.data/lib -lreadline)\n",
"(cd .. ; rm -f x86_64/.libs/libnrnmech.so ; mkdir -p x86_64/.libs ; ln -s ../../x86_64/libnrnmech.dylib x86_64/.libs/libnrnmech.so)\n",
"x86_64-apple-darwin13.4.0-clang -O2 -I. -I/Users/ehagen/anaconda3/envs/lfpy/lib/python3.9/site-packages/neuron/.data/include -I/usr/local/Cellar/open-mpi/4.0.5/include -fPIC -c mod_func.c -o mod_func.o\n",
" => \u001b[32mLINKING\u001b[0m shared library ./libnrnmech.dylib\n",
"x86_64-apple-darwin13.4.0-clang++ -O2 -DVERSION_INFO='7.8.2' -std=c++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -fPIC -I /Users/ehagen/anaconda3/envs/lfpy/lib/python3.9/site-packages/neuron/.data/include -o ./libnrnmech.dylib -Wl,-install_name,@rpath/libnrnmech.dylib \\\n",
"\t ./mod_func.o ./sinsyn.o -L/Users/ehagen/anaconda3/envs/lfpy/lib/python3.9/site-packages/neuron/.data/lib -lnrniv -Wl,-rpath,/Users/ehagen/anaconda3/envs/lfpy/lib/python3.9/site-packages/neuron/.data/lib -lreadline\n",
"rm -f ./.libs/libnrnmech.so ; mkdir -p ./.libs ; cp ./libnrnmech.dylib ./.libs/libnrnmech.so\n",
"Successfully created x86_64/special\n"
]
}
Expand Down Expand Up @@ -315,7 +313,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.6"
"version": "3.9.1"
}
},
"nbformat": 4,
Expand Down
12 changes: 9 additions & 3 deletions examples/Example_LFPy_MEG.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
"metadata": {},
"source": [
"# Example LFPy MEG\n",
"Demonstrate magnetic field predictions in a single point from current dipole moment with LFPy"
"Demonstrate magnetic field predictions in a single point from current dipole moment with LFPy (https://LFPy.readthedocs.io, https://github.com/LFPy/LFPy). \n",
"\n",
"The simulation is broken down in a few steps:\n",
"\n",
"1. Simulate the neuron model and record all transmembrane currents with LFPy\n",
"2. Compute the current dipole moment **P** from transmembrane currents using the `lfpykit.CurrentDipoleMoment` class\n",
"3. Position the dipole and compute the resulting magnetic field (MEG) from **P** using the `lfpykit.eegmegcalc.MEG` class"
]
},
{
Expand Down Expand Up @@ -95,7 +101,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x117de94c0>"
"<matplotlib.legend.Legend at 0x141a659d0>"
]
},
"execution_count": 6,
Expand Down Expand Up @@ -176,7 +182,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.6"
"version": "3.9.1"
}
},
"nbformat": 4,
Expand Down
50 changes: 25 additions & 25 deletions examples/Example_LFPy_compare_forwardmodels.ipynb

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions examples/Example_LFPy_pt3d.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
"metadata": {},
"source": [
"# Example `LFPy.Cell(pt3d=True, **kwargs)`\n",
"Example utilizing the LFPy forward models module for predictions of\n",
"current dipole moment from a wiggly, variable diameter dendritic stick model set up in LFPy.\n",
"Example utilizing the LFPykit forward models module for predictions of\n",
"current dipole moment from a wiggly, variable diameter dendritic stick model set up in LFPy (https://LFPy.readthedocs.io, https://github.com/LFPy/LFPy).\n",
"\n",
"The passive stick receives sinusoid synaptic current input at its terminal\n",
"segment.\n",
"\n",
"The example is meant to demonstrate how pt3d information can be utilized for forward-model predictions. \n",
"The example is meant to demonstrate how pt3d information (for instance the full 3D geometry information present in neuronal reconstruction file formats such as `.swc`) can be utilized for forward-model predictions. \n",
"\n",
"Assumes an even number of pt3d points per electric segment!\n",
"NEURON pt3d info does not necessarily correspond with segment start and end points. "
"NEURON pt3d info does not necessarily correspond with segment start and end points depending on spatial discretization of the cable model"
]
},
{
Expand Down Expand Up @@ -344,7 +345,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.6"
"version": "3.9.1"
}
},
"nbformat": 4,
Expand Down
34 changes: 19 additions & 15 deletions examples/Example_NEURON.ipynb

Large diffs are not rendered by default.

66 changes: 30 additions & 36 deletions examples/LFPykit_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,9 @@
"metadata": {},
"source": [
"# Demonstration of LFPykit\n",
"\n",
"\n",
"## LFPy \n",
"- LFPy is for calculating brain signals (EAP, LFP, ECoG, EEG, MEG) from biophysically detailed neural simulations\n",
"- Built upon NEURON\n",
"- For both single cells and networks\n",
"- Is also a python wrapper around NEURON, to control simulations, insert synapses, etc.\n",
"\n",
"\n",
"## The problem\n",
"- There are other softwares for biohysically detailed neural simulations that might want to calculate some of the same brain signals\n",
"- If you have developed a network model outside of LFPy, it can be complicated to combine with methods from LFPy\n",
"\n",
"## Our solution\n",
"- Neural simulations and calculations of brain signals are done separatly\n",
" - Starting point for calculation of most brain signals are transmembrane currents and their locations\n",
"- Extract \"forward models\" from LFPy, and into new software independent of LFPy and NEURON \n",
" - LFPykit\n",
"- Transmembrane currents and cellular locations are given to a generic GeometryCell class\n",
"- Standadrized calculation of different brain signals"
"This example notebook demonstrates various use cases of the `LFPykit` Python package, \n",
"by setting up a biophysically detailed model of a Layer 5 pyramidal neuron with synaptic stimuli in LFPy (https://LFPy.readthedocs.io, https://github.com/LFPy/LFPy). \n",
"Then *in vivo* and *ex vivo* like extracellular potentials are predicted with the aid of `lfpykit` classes `PointSourcePotential`, `CurrentDipoleMoment` and `eegmegcalc.NYHeadModel`. "
]
},
{
Expand All @@ -33,7 +16,16 @@
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# import modules\n",
"import os\n",
"import sys\n",
"import numpy as np\n",
Expand All @@ -54,7 +46,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -66,7 +58,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -78,12 +70,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Fetch Hay et al. 2011 model files:"
"### Fetch Hay et al. 2011 model files:\n",
"Corresponding to the publication: \n",
"Hay E, Hill S, Schürmann F, Markram H, Segev I (2011) Models of Neocortical Layer 5b Pyramidal Cells Capturing a Wide Range of Dendritic and Perisomatic Active Properties. PLoS Comput Biol 7(7): e1002107. doi:10.1371/journal.pcbi.1002107"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -119,12 +113,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Set up simulation of transmembrane currents"
"### Set up simulation of transmembrane currents using LFPy"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -182,7 +176,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -212,16 +206,16 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x143f04220>"
"<matplotlib.legend.Legend at 0x13cc3bf70>"
]
},
"execution_count": 7,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
},
Expand Down Expand Up @@ -274,7 +268,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -297,16 +291,16 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x1483ac7f0>]"
"[<matplotlib.lines.Line2D at 0x140c53700>]"
]
},
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
},
Expand Down Expand Up @@ -429,7 +423,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.6"
"version": "3.9.1"
}
},
"nbformat": 4,
Expand Down
Loading