Skip to content
Open
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
154 changes: 154 additions & 0 deletions doc/tutorials/gui_api_workflow.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "Tz8s2dRrU0P6"
},
"source": [
"# Using and Importing Saved Neocortical Models in HNN\n",
"\n",
"This tutorial explains how to move between the HNN Graphical User Interface (GUI)\n",
"and the Python API. It is intended for users who begin exploring networks in the GUI\n",
"and later want to continue their work programmatically.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "aNymN5TZcPgF"
},
"source": [
"## Step 1: Creating a Network in the GUI\n",
"\n",
"1. Launch the HNN GUI\n",
"2. Configure the network parameters\n",
"3. Run a simulation\n",
"4. Save the network configuration using the GUI\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "5uyMJpE-cTBB"
},
"source": [
"## Step 2: Loading the Saved Network in Python\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "zNItz6kackJT"
},
"outputs": [],
"source": [
"from hnn_core import read_network_configuration\n",
"\n",
"net = read_network_configuration(\"my_network.json\")\n",
"print(net)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ga6CLxLwcX75"
},
"outputs": [],
"source": [
"### Common Error: Missing Filename"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "1I-EJQHucVSV"
},
"outputs": [],
"source": [
"read_network_configuration()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "UEHPEI1vcoFG"
},
"source": [
"This raises a TypeError because the function cannot guess which network file to load.\n",
"You must always provide the path to a saved configuration file.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "mvDRJdtTcos5"
},
"outputs": [],
"source": [
"# inspect network\n",
"print(net.cell_types)\n",
"\n",
"# run simulation\n",
"dpl = net.simulate()\n",
"\n",
"# plot results\n",
"dpl.plot()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "9k3bfEsIcu_5"
},
"source": [
"## Step 3: Returning to the GUI\n",
"\n",
"Networks modified in Python can be saved and reloaded in the GUI,\n",
"allowing users to visually inspect or further interact with the model.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "nd83IKHVczCk"
},
"source": [
"## Summary\n",
"\n",
"- Use the GUI for interactive exploration\n",
"- Save the network configuration\n",
"- Load it in Python using `read_network_configuration`\n",
"- Continue analysis using the API\n",
"- Optionally return to the GUI\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "1dqTg32RctHr"
},
"outputs": [],
"source": []
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
19 changes: 18 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from setuptools import setup, find_packages, Command
from setuptools.command.build_py import build_py
from setuptools.command.install import install


descr = """Code for biophysical simulation of a cortical column using Neuron"""

Expand Down Expand Up @@ -72,6 +74,16 @@ def run(self):
shutil.copytree(mod_path, build_dir)

build_py.run(self)


class PostInstallCommand(install):
"""Post-installation message."""
def run(self):
install.run(self)
print("\nThank you for installing hnn-core! 🎉")
print("Please consider filling out our short user survey:")
print("👉 https://hnn.brown.edu/survey\n")



if __name__ == "__main__":
Expand Down Expand Up @@ -129,6 +141,11 @@ def run(self):
package_data={'hnn_core': [
'param/*.json',
'gui/*.ipynb']},
cmdclass={'build_py': build_py_mod, 'build_mod': BuildMod},
cmdclass={
'build_py': build_py_mod,
'build_mod': BuildMod,
'install': PostInstallCommand,
},

entry_points={'console_scripts': ['hnn-gui=hnn_core.gui.gui:launch']}
)