### Install Software with Ansible Playbook Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/config/cluster-user/README.md These commands demonstrate how to activate a virtual environment and run the `site.yaml` Ansible playbook to install required software on the cluster. This process should be executed from the cluster-user directory. ```shell source ./venv-ansible/bin/activate ansible-playbook site.yaml ``` -------------------------------- ### Start ipyparallel Controller and Engines Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/BluePyOpt-ipyparallel.md Demonstrates how to start the ipyparallel controller and multiple engines, which are the worker processes. This setup is necessary for distributing tasks across multiple cores or machines. ```bash # Activate the virtualenv $ source venv-ipyparellel/bin/activate # Run the ipcontroller (venv-ipyparellel)$ ipcontroller # In another terminal, activate the virtualenv $ source venv-ipyparellel/bin/activate # Start two ipengines (more can be started) (venv-ipyparellel)$ ipengine &; ipengine & ``` -------------------------------- ### Get Latest eFEL and Compile Modl Files Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/README.md This snippet outlines the steps to clone the eFEL repository and then compile its modl files using a specific NEURON nrnivmodl executable. This is part of the optimization example setup for eFEL. ```bash # Get latest eFEL $ git clone https://github.com/BlueBrain/eFEL.git # Compile the modl files with the nrnivmodl located in ~/workspace/install/. (for instance here ~/workspace/install/nrnpython/x86_64/bin/nrnivmodl) $ cd ~/eFEL/examples/deap/GranuleCell1 $ ~/workspace/install/nrnpython/x86_64/bin/nrnivmodl mechanisms ``` -------------------------------- ### Boot Vagrant Machines Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/config/vagrant/README.md Launches the virtual machines defined in the Vagrantfile. This command reads the Vagrantfile, creates the specified number of machines with their respective network configurations, and boots them up. It's essential for starting the development environment. ```bash $ vagrant up ``` -------------------------------- ### Configure AWS Cloud with Ansible Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/config/amazon/README.md Applies the main Ansible playbook (`site.yaml`) to configure the launched AWS instances after initial setup. This step assumes the necessary configuration files have been generated. ```bash ansible-playbook site.yaml ``` -------------------------------- ### Launch AWS Cloud with Ansible Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/config/amazon/README.md Executes the Ansible playbook to create and launch the AWS infrastructure defined in `create_instance.yaml`. Requires the virtual environment to be activated and AWS credentials to be exported. ```bash source ./venv-ansible/activate ansible-playbook create_instance.yaml ``` -------------------------------- ### Install AWS Python Libraries with pip Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/config/amazon/README.md Installs necessary Python libraries (boto, boto3, awscli) for Ansible to interact with AWS services like EC2. Ensure you are within your Ansible virtual environment. ```bash source ./venv-ansible/activate pip install boto boto3 awscli ``` -------------------------------- ### Print cell model description Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/metaparameters/metaparameters.ipynb Displays a summary of the created 'simple_cell' model, including its morphology, mechanisms, and parameters. This is useful for verifying the cell setup. ```python print(simple_cell) ``` -------------------------------- ### Install BluePyOpt using Pip Source: https://github.com/openbraininstitute/bluepyopt/blob/master/README.rst This command installs the BluePyOpt library using pip, the Python package installer. It ensures that the latest version of BluePyOpt and its dependencies are downloaded and installed on your system. This is the primary method for installing BluePyOpt. ```bash pip install bluepyopt ``` -------------------------------- ### Install BluePyOpt with NeuroML Support Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/neuroml/neuroml.ipynb Installs the bluepyopt library with the necessary neuroml extra dependencies. This is a prerequisite for exporting cells to the neuroml format. ```bash pip install bluepyopt[neuroml] ``` -------------------------------- ### Ansible Playbook Configuration for AWS Instance Creation Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/config/amazon/README.md Defines parameters for launching AWS EC2 instances using an Ansible playbook. Specifies region, AMI image, instance type, and the number of worker instances. Ensure the AMI is compatible with the chosen region. ```yaml region: us-west-2 ami_image: ami-187c9978 # http://cloud-images.ubuntu.com/trusty/current/ instance_type: t2.nano worker_instances: 2 ``` -------------------------------- ### AWS CLI Command to Describe EC2 Instances Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/config/amazon/README.md Uses the AWS Command Line Interface (CLI) to list details of all running EC2 instances in the configured region. Useful for monitoring the status and properties of your cloud resources. ```bash aws ec2 describe-instances ``` -------------------------------- ### Install matplotlib using pip Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/metaparameters/metaparameters.ipynb This code snippet installs the matplotlib library, which is necessary for plotting and visualization within the BluePyOpt environment. The '-q' flag ensures a quiet installation process. ```python !pip install -q matplotlib ``` -------------------------------- ### Set Up Cell Evaluator in BluePyOpt (Python) Source: https://context7.com/openbraininstitute/bluepyopt/llms.txt This code shows how to initialize a cell evaluator in BluePyOpt for model assessment. It demonstrates the initialization of the NEURON simulator and provides a commented-out example for initializing the Arbor simulator, which are necessary components for running simulations and evaluating model fitness against objectives. ```python import bluepyopt.ephys as ephys # Initialize NEURON simulator nrn_sim = ephys.simulators.NrnSimulator() # Or use Arbor simulator # arb_sim = ephys.simulators.ArbSimulator() ``` -------------------------------- ### Add Ubuntu Trusty64 Vagrant Box Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/config/vagrant/README.md Adds the 'ubuntu/trusty64' box to your local Vagrant environment. This box serves as the base image for provisioning new virtual machines. Ensure Vagrant is installed before running this command. ```bash $ vagrant box add ubuntu/trusty64 ``` -------------------------------- ### Launch DEAP example with scoop Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/README.md This command launches the modified DEAP onemax_island_scoop.py script using scoop for parallel execution. It specifies the Python executable within a virtual environment, the scoop module, the host file, and the script name. The output will be available in 'output.dat'. ```bash cd workspace virtualenv/bin/python -m scoop --hostfile ~/scoop_workers onemax_island_scoop.py look at the output in 'output.dat' ``` -------------------------------- ### Start ipyparallel Cluster using ipcluster Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/BluePyOpt-ipyparallel.md Uses the `ipcluster` command to simplify the startup of an ipyparallel cluster, including the controller and engines. This is a more convenient way to manage the parallel environment. ```bash # start an ipyparellel cluster with 1 head node, and as many processors as the current machine has (venv-ipyparellel)$ ipcluster start ``` -------------------------------- ### Install Ansible with Pip in a Virtualenv Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/README.md This snippet demonstrates how to create a virtual environment for Ansible and install it using pip. This isolates Ansible from the system's Python packages. It requires a Python interpreter and pip to be available. ```bash $ virtualenv venv-ansible $ ./venv-ansible/bin/pip install ansible ``` -------------------------------- ### Activate Ansible Virtual Environment and Run Playbook Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/config/vagrant/README.md Activates a Python virtual environment for Ansible and then executes the main Ansible playbook ('site.yaml'). This step assumes you have set up a virtual environment named 'venv-ansible' and have Ansible installed within it. The playbook will configure the provisioned Vagrant machines. ```bash $ source ./venv-ansible/activate $ ansible-playbook site.yaml ``` -------------------------------- ### Install ipyparallel using pip Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/BluePyOpt-ipyparallel.md Installs the ipyparallel library using pip within a virtual environment. This is a prerequisite for using ipyparallel for distributed computing. ```bash venv venv-ipyparellel; source venv-ipyparellel/bin/activate (venv-ipyparellel)$ pip install ipyparallel ``` -------------------------------- ### Activate Ansible Virtualenv and Check Version Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/README.md This snippet shows how to activate the previously created Ansible virtual environment and verify the Ansible installation by checking its version. This ensures Ansible is ready for use within the isolated environment. ```bash $ source ./venv-ansible/bin/activate $ ansible-playbook --version ``` -------------------------------- ### Start ipengines cluster Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/BluePyOpt-ipyparallel.md This command starts a cluster of ipengines, which are required for distributed computing with ipyparallel. Ensure this command is run in a separate terminal window before launching the optimization script. ```bash (gecco2017)$ ipcluster start ``` -------------------------------- ### Generate AWS Instance Configuration Files Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/config/amazon/README.md Runs a Python script to gather configuration details for the created AWS instances, likely to generate `hosts` and `amazon_ssh_config` files needed for subsequent Ansible plays. The `--dry-run` argument can be used to preview the output. ```bash # Note: this can be run with the --dry-run argument to see the output first python gather_config.py ``` -------------------------------- ### Run Protocols and Get Voltage Recordings Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/l5pc_lfpy/L5PC_LFPy.ipynb This code executes the defined fitness protocols on the cell model using the configured evaluator and retrieves the simulation responses, specifically the voltage recordings at the soma. This is a key step in evaluating the model's response to stimuli. ```python from generate_extra_features import release_params release_responses = evaluator.run_protocols(protocols=fitness_protocols.values(), param_values=release_params) ``` -------------------------------- ### Launch scoop script on head node Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/README.md This command launches a Python script using scoop for parallel execution on a cluster. It specifies the Python executable, scoop module, verbosity level, host file, and the main script to run. ```bash /home/neuron/workspace/venv/bin/python -m scoop -vvv --hostfile ~/scoop_workers GranuleCellDeap1-scoop.py ``` -------------------------------- ### Install Matplotlib for BluePyOpt Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/simplecell/simplecell_arbor.ipynb Installs the matplotlib library, which is often used for plotting and visualization in scientific computing and may be a dependency for BluePyOpt's visualization features. ```python # Install matplotlib if needed !pip install matplotlib ``` -------------------------------- ### Import and Define Protocols for LEMS Simulation (Python) Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/neuroml/neuroml.ipynb Imports necessary modules to define simulation protocols. It retrieves protocols from the bluepyopt l5pc example and selects a specific protocol ('Step3') for the simulation. ```python import l5pc_evaluator protocols = l5pc_evaluator.define_protocols() protocol_name = "Step3" bpo_test_protocol = protocols[protocol_name] ``` -------------------------------- ### Load and Initialize BluePyOpt Modules and Environment Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/l5pc/L5PC.ipynb This snippet loads the necessary BluePyOpt Python modules, specifically the core library and the ephys submodule, along with autoreload functionality and environment setup for plotting. It also compiles NRN mechanisms required for the simulation. ```python %load_ext autoreload %autoreload !nrnivmodl mechanisms import bluepyopt as bpopt import bluepyopt.ephys as ephys import pprint pp = pprint.PrettyPrinter(indent=2) %matplotlib notebook import matplotlib.pyplot as plt ``` -------------------------------- ### Define Stimulation and Recording Protocols in BluePyOpt (Python) Source: https://context7.com/openbraininstitute/bluepyopt/llms.txt This code defines stimulus and recording protocols for evaluating neuronal models in BluePyOpt. It includes creating a square pulse stimulus and a somatic voltage recording, then combining them into a SweepProtocol. It also shows an example of a NetStim stimulus for synaptic stimulation. ```python import bluepyopt.ephys as ephys # Define recording location soma_loc = ephys.locations.NrnSeclistCompLocation( name='soma', seclist_name='somatic', sec_index=0, comp_x=0.5 ) # Create square pulse current injection stim = ephys.stimuli.NrnSquarePulse( step_amplitude=0.01, # nA step_delay=100, # ms step_duration=50, # ms location=soma_loc, total_duration=200 # ms ) # Create voltage recording rec = ephys.recordings.CompRecording( name='Step1.soma.v', location=soma_loc, variable='v' ) # Create protocol combining stimulus and recording protocol = ephys.protocols.SweepProtocol( 'Step1', stimuli=[stim], recordings=[rec] ) # For synaptic stimulation netstim = ephys.stimuli.NrnNetStimStimulus( total_duration=200, number=5, # Number of spikes interval=5, # ms between spikes start=20, # ms weight=5e-4, # Synaptic weight locations=[synapse_loc] ) ``` -------------------------------- ### Python Setup for Cell Model and Evaluator in BluePyOpt Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/thalamocortical-cell/thalamocortical-cell_opt.ipynb This snippet shows how to import necessary libraries and scripts to set up a cell model and cell evaluator using BluePyOpt. It highlights that a cell evaluator is created by specifying an electrical type, and a cell model is built from morphology, mechanisms, and parameter bounds. ```python %matplotlib inline import matplotlib.pyplot as plt import bluepyopt import os import pprint pp = pprint.PrettyPrinter(indent=2) # Import scripts for setting up the cell model and cell evaluator import CellEvalSetup ``` -------------------------------- ### Define Features and Objectives for Optimization in BluePyOpt (Python) Source: https://context7.com/openbraininstitute/bluepyopt/llms.txt This snippet illustrates how to define electrophysiological features using the eFEL library and convert them into optimization objectives within BluePyOpt. It shows creating a SingletonObjective for 'Spikecount' and an example for 'AP_amplitude', along with setting up an ObjectivesCalculator for multiple objectives. ```python import bluepyopt.ephys as ephys # Define eFEL feature to extract feature = ephys.efeatures.eFELFeature( name='Step1.Spikecount', efel_feature_name='Spikecount', recording_names={'': 'Step1.soma.v'}, stim_start=100, # ms stim_end=150, # ms exp_mean=5.0, # Target value exp_std=0.5 # Standard deviation ) # Create objective from feature objective = ephys.objectives.SingletonObjective( 'Step1.Spikecount', feature ) # Multiple objectives example ap_amplitude_feature = ephys.efeatures.eFELFeature( name='Step1.AP_amplitude', efel_feature_name='AP_amplitude', recording_names={'': 'Step1.soma.v'}, stim_start=100, stim_end=150, exp_mean=80.0, # mV exp_std=5.0 ) ap_amplitude_obj = ephys.objectives.SingletonObjective( 'Step1.AP_amplitude', ap_amplitude_feature ) # Calculate objectives from features score_calc = ephys.objectivescalculators.ObjectivesCalculator( [objective, ap_amplitude_obj] ) ``` -------------------------------- ### Run Protocol on Cell with NrnSimulator Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/metaparameters/metaparameters.ipynb Demonstrates how to initialize a NrnSimulator and run a protocol on a cell model with specified parameters. It also shows how to plot the resulting voltage traces. ```python nrn = ephys.simulators.NrnSimulator() default_params = {'cm_meta': 1.0} responses = twostep_protocol.run(cell_model=simple_cell, param_values=default_params, sim=nrn) def plot_responses(responses): plt.subplot(1,1,1) plt.plot(responses['step1.soma.v']['time'], responses['step1.soma.v']['voltage'], label='step1') plt.legend() plt.tight_layout() plot_responses(responses) ``` -------------------------------- ### Run Electrophysiology Protocols with NrnSimulator Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/simplecell/simplecell.ipynb Illustrates how to run an electrophysiology protocol on a cell model using BluePyOpt's NrnSimulator. It shows the creation of the simulator object and the execution of the `run` method with specified cell model and parameter values. The output responses can then be plotted. ```python nrn = ephys.simulators.NrnSimulator() def plot_responses(responses): plt.subplot(2,1,1) plt.plot(responses['step1.soma.v']['time'], responses['step1.soma.v']['voltage'], label='step1') plt.legend() plt.subplot(2,1,2) plt.plot(responses['step2.soma.v']['time'], responses['step2.soma.v']['voltage'], label='step2') plt.legend() plt.tight_layout() default_params = {'gnabar_hh': 0.1, 'gkbar_hh': 0.03} responses = twostep_protocol.run(cell_model=simple_cell, param_values=default_params, sim=nrn) plot_responses(responses) other_params = {'gnabar_hh': 0.05, 'gkbar_hh': 0.05} plot_responses(twostep_protocol.run(cell_model=simple_cell, param_values=other_params, sim=nrn)) ``` -------------------------------- ### Modify DEAP example for output Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/README.md This Python code snippet modifies the DEAP onemax_island_scoop.py example to write its output to a file named 'output.dat'. It captures the result of the main function and writes its string representation to the file. ```python islands = main() with open('output.dat', 'w') as fd: fd.write(str(islands)) fd.write('\n') ``` -------------------------------- ### Import BluePyOpt modules Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/metaparameters/metaparameters.ipynb Imports the core BluePyOpt library and its electrophysiology module. These are essential for creating and manipulating electrophysiological cell models and simulations. ```python import bluepyopt as bpop import bluepyopt.ephys as ephys ``` -------------------------------- ### Destroy Vagrant Machines Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/config/vagrant/README.md Removes and destroys all virtual machines and associated resources created by Vagrant. This command is useful for cleaning up the environment or starting from a completely fresh state before running 'vagrant up' again. ```bash $ vagrant destroy ``` -------------------------------- ### Create Electrophysiology Protocols with BluePyOpt Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/simplecell/simplecell.ipynb Demonstrates the creation of electrophysiology protocols using BluePyOpt. It involves defining cell locations, stimuli (square pulses), and recordings (membrane potential). Multiple protocols are combined into a sequence for simulating a two-step stimulation experiment. ```python soma_loc = ephys.locations.NrnSeclistCompLocation( name='soma', seclist_name='somatic', sec_index=0, comp_x=0.5) sweep_protocols = [] for protocol_name, amplitude in [('step1', 0.01), ('step2', 0.05)]: stim = ephys.stimuli.NrnSquarePulse( step_amplitude=amplitude, step_delay=100, step_duration=50, location=soma_loc, total_duration=200) rec = ephys.recordings.CompRecording( name='%s.soma.v' % protocol_name, location=soma_loc, variable='v') protocol = ephys.protocols.SweepProtocol(protocol_name, [stim], [rec]) sweep_protocols.append(protocol) twostep_protocol = ephys.protocols.SequenceProtocol('twostep', protocols=sweep_protocols) ``` -------------------------------- ### AWS CLI Command to List Elastic IP Addresses Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/config/amazon/README.md Uses the AWS CLI to list all Elastic IP addresses associated with your AWS account. This can help in identifying and managing public IP addresses assigned to your instances. ```bash aws ec2 describe-addresses ``` -------------------------------- ### Configure Ansible Hosts File Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/config/cluster-user/README.md This snippet shows the required content for the `hosts` file to specify the cluster head node for Ansible. Ensure `dns.name.of.head.node` is replaced with the actual DNS name of your cluster's head node. ```text [neuron-optimizer-worker] dns.name.of.head.node ``` -------------------------------- ### Run Protocols on a Cell Model and Plot Responses (Python) Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/simplecell/simplecell-paperfig.ipynb This code demonstrates how to initialize the NrnSimulator and run a defined protocol on a cell model with specific parameter values. It also includes a utility function to plot the voltage responses recorded during the protocol execution. The responses are plotted using matplotlib. ```python nrn = ephys.simulators.NrnSimulator() def plot_responses(responses): plt.subplot(2,1,1) plt.plot(responses['step1.soma.v']['time'], responses['step1.soma.v']['voltage'], label='step1') plt.legend() plt.subplot(2,1,2) plt.plot(responses['step2.soma.v']['time'], responses['step2.soma.v']['voltage'], label='step2') plt.legend() plt.tight_layout() default_params = {'gnabar_hh': 0.1, 'gkbar_hh': 0.03} responses = twostep_protocol.run(cell_model=simple_cell, param_values=default_params, sim=nrn) plot_responses(responses) plt.show() other_params = {'gnabar_hh': 0.11, 'gkbar_hh': 0.04} plot_responses(twostep_protocol.run(cell_model=simple_cell, param_values=other_params, sim=nrn)) ``` -------------------------------- ### Import BluePyOpt and Supporting Libraries Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/graupnerbrunelstdp/graupnerbrunelstdp.ipynb Imports necessary libraries for BluePyOpt optimization, including the main library, evaluation utilities, standard deviation utilities, NumPy for numerical operations, and a run_fit module for plotting. ```python %matplotlib inline import bluepyopt as bpop import gbevaluator import stdputil import numpy as np import run_fit ``` -------------------------------- ### Set AWS Credentials and Region Environment Variables Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/config/amazon/README.md Exports AWS access key ID, secret access key, and default region to the terminal environment. These variables are required for AWS infrastructure to authenticate the client when running Ansible playbooks. ```bash export AWS_ACCESS_KEY_ID= replace with access id export AWS_SECRET_ACCESS_KEY= replace with access key export AWS_REGION= replace with default AWS region ``` -------------------------------- ### Set up Recording and Protocol in BluePyOpt Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/expsyn/ExpSyn.ipynb This code configures a CompRecording to capture the membrane potential ('v') at the soma center and defines a SweepProtocol that uses the NetStim stimulus and the soma recording. This prepares the simulation environment for data acquisition. ```python rec = ephys.recordings.CompRecording( name='soma.v', location=somacenter_loc, variable='v') protocol = ephys.protocols.SweepProtocol('netstim_protocol', [netstim], [rec]) ``` -------------------------------- ### Run Optimization and retrieve results in BluePyOpt Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/metaparameters/metaparameters.ipynb This code shows how to execute the optimization process defined by the 'optimisation' object for a maximum number of generations. It returns the final population, hall of fame, statistical logs, and history of the optimization. ```python final_pop, hall_of_fame, logs, hist = optimisation.run(max_ngen=5) ``` -------------------------------- ### Run Protocol on Cell Model with BluePyOpt Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/simplecell/simplecell_arbor.ipynb This code demonstrates how to run a defined protocol on a cell model with specific parameter values using a simulator. The `run()` method of a protocol object takes the cell model, parameter values, and the simulator as arguments, returning the recorded responses. ```python default_params = {'gnabar_hh': 0.1, 'gkbar_hh': 0.03} responses = twostep_protocol.run(cell_model=simple_cell, param_values=default_params, sim=sim) ``` -------------------------------- ### Configure NEURON Simulator and Morphology Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/expsyn/ExpSyn.ipynb Initializes the NEURON simulator and defines a single-compartment morphology using an NRN file. Sets up location objects for the 'somatic' sectionlist and the center of the soma. ```python # NEURON simulator nrn_sim = ephys.simulators.NrnSimulator() # Single compartment morph = ephys.morphologies.NrnFileMorphology('simple.swc') # Object that points to sectionlist somatic somatic_loc = ephys.locations.NrnSeclistLocation('somatic',seclist_name='somatic') # Object that points to the center of the soma somacenter_loc = ephys.locations.NrnSeclistCompLocation( name='somacenter', seclist_name='somatic', sec_index=0, comp_x=0.5) ``` -------------------------------- ### Install Matplotlib using Pip Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/cma_strategy/cma.ipynb Installs the matplotlib library, a common dependency for plotting in Python. This command is typically run in a Jupyter Notebook or a similar environment. ```shell !pip install matplotlib ``` -------------------------------- ### Load and Visualize Neuron Morphology with NeuroM Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/thalamocortical-cell/thalamocortical-cell_opt.ipynb This snippet demonstrates loading a specific neuron morphology and visualizing it using the NeuroM library. It requires the 'neurom' library and assumes a 'CellEvalSetup' object is available to provide the morphology path. ```python import neurom # https://github.com/BlueBrain/NeuroM import neurom.viewer etype = "cAD_ltb" # or cNAD_ltb evaluator = CellEvalSetup.evaluator.create(etype) neurom.viewer.draw(neurom.load_neuron(evaluator.cell_model.morphology.morphology_path)) print(evaluator.cell_model) ``` -------------------------------- ### Initialize Simulator with BluePyOpt Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/simplecell/simplecell_arbor.ipynb This snippet shows the initialization of a simulator object using `ephys.simulators.ArbSimulator`. This simulator is essential for running protocols on cell models within the BluePyOpt framework. ```python sim = ephys.simulators.ArbSimulator() ``` -------------------------------- ### Initialize LFPy Simulator in BluePyOpt Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/l5pc_lfpy/L5PC_LFPy.ipynb This code snippet initializes the LFPy simulator within the BluePyOpt framework. It specifies whether the CVODE solver should be active. This is a prerequisite for running LFP simulations. ```python lfpy_sim = ephys.simulators.LFPySimulator(cvode_active=True) ``` -------------------------------- ### Visualize Cell Morphology with Neurom Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/l5pc/L5PC_arbor.ipynb This snippet demonstrates how to install the Neurom library, load a neuron morphology from an ASC file, and visualize it using Neurom's viewer. It requires the neurom library to be installed. ```python !pip install neurom --upgrade import neurom.viewer neurom.viewer.draw(neurom.load_neuron('morphology/C060114A7.asc')); ``` -------------------------------- ### Define cell evaluator protocols Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/metaparameters/metaparameters.ipynb Sets up the experimental protocols for the cell evaluator. This involves defining stimuli (square pulses) and recordings (membrane potential 'v' in the soma) for a specific protocol named 'step1', and then combining them into a sequence protocol 'twostep'. ```python soma_loc = ephys.locations.NrnSeclistCompLocation( name='soma', seclist_name='somatic', sec_index=0, comp_x=0.5) sweep_protocols = [] for protocol_name, amplitude in [('step1', 0.05)]: stim = ephys.stimuli.NrnSquarePulse( step_amplitude=amplitude, step_delay=100, step_duration=50, location=soma_loc, total_duration=200) rec = ephys.recordings.CompRecording( name='%s.soma.v' % protocol_name, location=soma_loc, variable='v') protocol = ephys.protocols.SweepProtocol(protocol_name, [stim], [rec]) sweep_protocols.append(protocol) twostep_protocol = ephys.protocols.SequenceProtocol('twostep', protocols=sweep_protocols) ``` -------------------------------- ### Set NEURON_HOME Environment Variable (Jupyter) Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/neuroml/neuroml.ipynb Sets the NEURON_HOME environment variable within the Jupyter kernel. This variable is crucial for the NEURON simulator to locate its installation directory. Users must update 'path/to/neuron/home' to their specific NEURON installation path. ```python %env NEURON_HOME=path/to/neuron/home ``` -------------------------------- ### Activate Conda Environment and Import Neuron Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/BluePyOpt-ipyparallel.md Activates the 'gecco2017' Conda environment and verifies the installation by importing the 'neuron' library. This confirms that the environment is set up correctly for BluePyOpt and NEURON usage. ```bash source activate gecco2017 python >>> import neuron ``` -------------------------------- ### Restart CMA Optimization with Centroid and Sigma Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/cma_strategy/cma.ipynb Re-runs the CMA optimization, but initializes the search distribution using a specified centroid (starting point) and sigma (initial standard deviation). This is useful for fine-tuning or continuing previous optimizations. ```python optimisation = optimiser(centroids=[list(hof[0])], sigma=0.01, evaluator=evaluator, seed=2) pop, hof, log, hist = optimisation.run(max_ngen=10) ``` -------------------------------- ### Import bluepyopt core modules Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/simplecell/simplecell-paperfig.ipynb Imports necessary libraries for plotting and the bluepyopt library, including its electrophysiology module. It also sets up plotting configurations and enables automatic reloading of modules. ```python %matplotlib notebook import matplotlib import matplotlib.pyplot as plt plt.rcParams['lines.linewidth'] = 2 %load_ext autoreload %autoreload import os import bluepyopt as bpop import bluepyopt.ephys as ephys ``` -------------------------------- ### Connect Client and Run Remote Function with ipyparallel Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/BluePyOpt-ipyparallel.md Connects a Python client to the running ipyparallel controller and executes a function (socket.gethostname) on all available worker engines. This verifies the parallel execution setup. ```python from ipyparallel import Client c = Client() # creates a connection to the server view = c[:] # creates a 'view' of all the workers import socket view.apply_sync(socket.gethostname) # run the function gethostname on all ipengines ``` -------------------------------- ### Import BluePyOpt and Ephys Modules Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/expsyn/ExpSyn.ipynb Imports necessary modules from BluePyOpt for NEURON simulation and ephys analysis. Includes standard Python libraries for plotting and environment management. ```python %matplotlib inline import matplotlib.pyplot as plt %reload_ext autoreload %autoreload import os import bluepyopt as bpopt import bluepyopt.ephys as ephys ``` -------------------------------- ### Ansible Connectivity Test Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/README.md This command tests the connectivity between the Ansible control machine and all managed hosts defined in the inventory. It's a fundamental step to ensure Ansible can communicate with the target systems before running playbooks. ```bash ansible -m ping all ``` -------------------------------- ### Configure logging level (optional) Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/metaparameters/metaparameters.ipynb This is an optional code block for debugging. It allows setting the logging level to 'debug' to get detailed information about the internal workings of BluePyOpt. The lines are commented out by default. ```python # import logging # logger = logging.getLogger() # logger.setLevel(logging.DEBUG) ``` -------------------------------- ### Initialize Arbor Simulator and Define Morphology with BluePyOpt Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/expsyn/ExpSyn_arbor.ipynb Initializes the Arbor simulator and defines a single-compartment morphology using a SWC file. It also sets up location objects for the 'somatic' sectionlist and the center of the soma, which are essential for defining synapse locations. ```python %matplotlib inline import matplotlib.pyplot as plt %reload_ext autoreload %autoreload import os import bluepyopt as bpopt import bluepyopt.ephys as ephys # Arbor simulator arb_sim = ephys.simulators.ArbSimulator() # Single compartment morph = ephys.morphologies.NrnFileMorphology('simple.swc') # Object that points to sectionlist somatic somatic_loc = ephys.locations.NrnSeclistLocation('somatic',seclist_name='somatic') # Object that points to the center of the soma somacenter_loc = ephys.locations.ArbLocsetLocation( name='somacenter', locset='(location 0 0.5)') ``` -------------------------------- ### Create LEMS Simulation File (Python) Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/neuroml/neuroml.ipynb Generates the LEMS simulation file using the defined network filename, protocol, timestep, cell name, and LEMS filename. This function integrates components required for simulation setup. ```python simulation.create_neuroml_simulation( network_filename, bpo_test_protocol, dt, l5pc_cell.name, lems_filename ) ``` -------------------------------- ### Compile Neuron Mechanisms and Import BluePyOpt (Shell & Python) Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/l5pc/l5pc_validate_neuron_arbor.ipynb This snippet first compiles Neuron mechanisms using the 'nrnivmodl' command in a shell environment, which is necessary for running simulations with specific ionic models. It then imports the BluePyOpt library and its ephys module in Python for electrophysiological modeling. ```shell !nrnivmodl mechanisms ``` ```python import bluepyopt as bpop import bluepyopt.ephys as ephys ``` -------------------------------- ### Distribute script to worker nodes Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/README.md This bash script iterates through a list of worker hostnames specified in '~/scoop_workers' and uses scp to copy the 'onemax_island_scoop.py' script to the 'workspace' directory on each remote host. This is necessary if the worker nodes do not share a filesystem. ```bash cd workspace for host in `cat ~/scoop_workers`; do scp onemax_island_scoop.py $i:workspace; done ``` -------------------------------- ### Plot Responses with Best Parameters Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/simplecell/simplecell.ipynb Visualises the responses of the cell model when simulated with the parameters of the best individual found during optimisation. This function requires the protocol, cell model, best individual's parameters, and the simulation environment. ```python plot_responses(twostep_protocol.run(cell_model=simple_cell, param_values=best_ind_dict, sim=nrn)) ``` -------------------------------- ### Create NetStim Stimulus for Synaptic Input Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/expsyn/ExpSyn_arbor.ipynb Generates a NetStim stimulus to simulate presynaptic events at a specified location. This defines the timing (start, number, interval), weight, and total duration of the simulated synaptic input. It uses the 'ephys' library. ```python stim_start = 20 number = 5 interval = 5 netstim = ephys.stimuli.NrnNetStimStimulus( total_duration=200, number=5, interval=5, start=stim_start, weight=5e-4, locations=[expsyn_loc]) stim_end = stim_start + interval * number ``` -------------------------------- ### Compile NEURON Mechanisms and Run Optimisation Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/thalamocortical-cell/thalamocortical-cell_opt.ipynb Prepares the environment for optimisation by compiling NEURON model mechanisms and creating a checkpoint directory. It then executes the optimisation run using the configured optimiser with specified generation and offspring sizes. ```python !nrnivmodl mechanisms # Compile NEURON .mod files stored in the "mechanisms" folder if not os.path.exists('checkpoints'): os.mkdir('checkpoints') final_pop, halloffame, log, hist, = opt.run(max_ngen=2, offspring_size=2, cp_filename='checkpoints/checkpoint.pkl'); ``` -------------------------------- ### Define eFeatures and Objectives for Fitness Calculation Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/metaparameters/metaparameters.ipynb Illustrates how to define electrophysiological features (eFeatures) from protocol responses and combine them into objectives for optimization algorithms. It specifies feature names, recording targets, stimulation times, and expected mean/standard deviation. ```python efel_feature_means = {'step1': {'Spikecount': 4}} objectives = [] for protocol in sweep_protocols: stim_start = protocol.stimuli[0].step_delay stim_end = stim_start + protocol.stimuli[0].step_duration for efel_feature_name, mean in efel_feature_means[protocol.name].items(): feature_name = '%s.%s' % (protocol.name, efel_feature_name) feature = ephys.efeatures.eFELFeature( feature_name, efel_feature_name=efel_feature_name, recording_names={'': '%s.soma.v' % protocol.name}, stim_start=stim_start, stim_end=stim_end, exp_mean=mean, exp_std=0.05 * mean) objective = ephys.objectives.SingletonObjective( feature_name, feature) objectives.append(objective) ``` -------------------------------- ### Initialize Graupner-Brunel Evaluator Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/graupnerbrunelstdp/graupnerbrunelstdp.ipynb Initializes the Graupner-Brunel evaluator, which is likely used to assess the performance or fitness of different model parameters. ```python evaluator = gbevaluator.GraupnerBrunelEvaluator() ``` -------------------------------- ### Evaluate Best Individual and Get Parameter Dictionary in BluePyOpt Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/metaparameters/metaparameters.ipynb This snippet demonstrates how to convert the best individual found during optimization into a dictionary of parameters using the cell_evaluator. It then evaluates this parameter dictionary to obtain the corresponding results, which should match the fitness values. ```python best_ind_dict = cell_evaluator.param_dict(best_ind) print(cell_evaluator.evaluate_with_dicts(best_ind_dict)) ``` -------------------------------- ### Initialize DEAP Optimiser in BluePyOpt Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/thalamocortical-cell/thalamocortical-cell_opt.ipynb Initializes the DEAPOptimisation object from the bluepyopt library. This setup includes defining the evaluator, specifying a map function for parallelization, and setting initial parameters for the optimisation algorithm like seed, eta, mutpb, and cxpb. ```python seed = 0 # Number to initialize the pseudorandom number generator opt = bluepyopt.optimisations.DEAPOptimisation( evaluator=evaluator, map_function=map, # The map function can be used to parallelize the optimisation seed=seed, eta=10., mutpb=1.0, cxpb=1.0) ``` -------------------------------- ### Initialize NEURON Simulator with BluePyOpt Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/l5pc/L5PC.ipynb Initializes the NEURON simulator using the NrnSimulator class from BluePyOpt. This is a prerequisite for running electrophysiological simulations. ```python sim = ephys.simulators.NrnSimulator() ``` -------------------------------- ### Evaluate Cell Model with Default Parameter Values Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/expsyn/ExpSyn_arbor.ipynb Runs the CellEvaluator with a specific set of parameter values to obtain the fitness score. This example demonstrates how to evaluate the model with a decay time constant of 10.0 and prints the resulting maximum voltage. Requires 'ephys'. ```python default_param_values = {'expsyn_tau': 10.0} print(cell_evaluator.evaluate_with_dicts(default_param_values)) ``` -------------------------------- ### Compare In Vitro and In Silico Amplitudes (Python) Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/tsodyksmarkramstp/tsodyksmarkramstp_multiplefreqs.ipynb Generates synaptic amplitudes using the best-fitted Tsodyks-Markram model parameters and compares them with the original in vitro data. It plots both experimental and simulated amplitudes for each stimulation frequency. Requires the 'evaluator' and 'best' parameters from the previous optimization step. ```python # Get amps (and optionally U, R state vars) for best model at every freqs. model_amps = OrderedDict() for freq, vals in data.items(): amps, _ = evaluator.generate_model(freq, best) model_amps[freq] = amps fig = plt.figure(figsize=(14, 4)) for i, (freq, tmp) in enumerate(data.items()): ax = fig.add_subplot(1, 3, i+1) ax.scatter(tmp["t_spikes"], tmp["amps"], c="red", label="in vitro") ax.scatter(tmp["t_spikes"], model_amps[freq], c="blue", label="in silico") if i == 0: ax.set_ylabel("Normalized (PSC) amplitudes") ax.set_xlabel("Time (ms)") ax.set_title(freq) ax.legend(loc=0) fig.tight_layout() ``` -------------------------------- ### Create and Evaluate CellEvaluator Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/metaparameters/metaparameters.ipynb Shows the process of creating a ScoreCalculator from defined objectives and then initializing a CellEvaluator. The CellEvaluator orchestrates the simulation, objective calculation, and parameter fitting. It also demonstrates how to evaluate the cell model with specific parameter values. ```python score_calc = ephys.objectivescalculators.ObjectivesCalculator(objectives) cell_evaluator = ephys.evaluators.CellEvaluator( cell_model=simple_cell, param_names=['cm_meta'], fitness_protocols={twostep_protocol.name: twostep_protocol}, fitness_calculator=score_calc, sim=nrn) print(cell_evaluator.evaluate_with_dicts(default_params)) ``` -------------------------------- ### Define NetStimulus for ExpSyn in BluePyOpt Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/expsyn/ExpSyn.ipynb This snippet defines a NetStim stimulus to activate the ExpSyn synapse multiple times. It specifies the total duration, number of stimuli, interval between stimuli, start time, weight, and the location of stimulation. This is crucial for setting up the simulation protocol. ```python netstim = ephys.stimuli.NrnNetStimStimulus( total_duration=200, number=5, interval=5, start=stim_start, weight=5e-4, locations=[expsyn_loc]) ``` -------------------------------- ### Load NevianSakmann Protocols and Data Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/graupnerbrunelstdp/graupnerbrunelstdp.ipynb Loads experimental protocols and associated data (sg, stderr) using stdputil. It also extracts the time step (dt) from the protocol IDs. ```python protocols, sg, _, stderr = stdputil.load_neviansakmann() dt = np.array([float(p.prot_id[:3]) for p in protocols]) ``` -------------------------------- ### Define Neuron Locations for Stimuli and Recordings (Python) Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/l5pc/l5pc_validate_neuron_arbor.ipynb This code defines locations for stimuli and recordings within the Neuron simulation environment, using `NrnSeclistCompLocation`. It maps these locations to specific sections and compartments within the 'somatic' seclist, mirroring the experimental setup for cross-validation. ```python nrn_locations = dict( stim_loc=ephys.locations.NrnSeclistCompLocation( name='soma', seclist_name='somatic', sec_index=0, comp_x=0.5), probe_loc=ephys.locations.NrnSeclistCompLocation( name='probe', seclist_name='somatic', sec_index=0, comp_x=0.75) ) ``` -------------------------------- ### Ansible Dry-Run Check Source: https://github.com/openbraininstitute/bluepyopt/blob/master/cloud-config/README.md This command executes an Ansible playbook in check mode. It simulates the playbook's actions without making any actual changes to the target systems, allowing for review of intended modifications. Adding `--diff` shows the specific changes that would be made. ```bash ansible-playbook site.yml --check ``` -------------------------------- ### Run Optimization and Retrieve Results Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/graupnerbrunelstdp/graupnerbrunelstdp.ipynb Executes the optimization process for a maximum number of generations (max_ngen). It returns the population, the hall of fame (hof) containing the best individuals, a logbook (log), and a history object (hst). ```python , hof, log, hst = opt.run(max_ngen=200) ``` -------------------------------- ### Load BluePyOpt and Ephys Modules in Python Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/l5pc/L5PC_arbor.ipynb Loads the necessary BluePyOpt Python module and its ephys submodule, along with utilities for pretty printing and plotting. Requires the autoreload extension to be enabled for dynamic code reloading during development. This setup is crucial for utilizing BluePyOpt's optimization capabilities. ```python %load_ext autoreload %autoreload import bluepyopt as bpopt import bluepyopt.ephys as ephys import pprint pp = pprint.PrettyPrinter(indent=2) %matplotlib inline import matplotlib.pyplot as plt ``` -------------------------------- ### Load and Plot In Vitro Trace (Python) Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/tsodyksmarkramstp/tsodyksmarkramstp.ipynb Loads a pickled in vitro voltage trace and plots it. It uses libraries like pickle for data loading and matplotlib for plotting. The data is expected to be in a dictionary with 't' and 'v' keys. ```python %matplotlib nbagg import seaborn as sns import matplotlib.pyplot as plt import multiprocessing import pickle import tmevaluator import bluepyopt as bpop import numpy as np # Set plotting context and style sns.set_context('talk') sns.set_style('whitegrid') # Load and display in vitro trace with open('trace.pkl', 'rb') as f: u = pickle._Unpickler(f) u.encoding = 'latin1' trace = u.load() fig, ax = plt.subplots() ax.plot(trace['t'], trace['v'], label='in vitro') ax.legend(loc=0) ax.set_xlabel('time (s)') ax.set_ylabel('soma voltage (V)') ``` -------------------------------- ### Load Optimization Results from Checkpoint Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/simplecell/simplecell-paperfig.ipynb Loads optimization results, including population, hall of fame, statistical logs, and history, from a checkpoint file using the pickle module. This allows resuming or analyzing a previous optimization run. ```python import pickle # pickle.dump(results, open('results.pkl', 'w')) # results = pickle.load(open('results.pkl') cp = pickle.load(open('checkpoints/checkpoint.pkl')) results = (cp['population'], cp['halloffame'], cp['logbook'], cp['history']) pop, hall_of_fame, logs, hist = results ``` -------------------------------- ### Optimization with Arbor Simulator in BluePyOpt Source: https://context7.com/openbraininstitute/bluepyopt/llms.txt Configures and runs optimizations using the Arbor simulator within the BluePyOpt framework. This involves initializing the Arbor simulator, defining Arbor-specific locations and protocols, and creating a CellEvaluator compatible with Arbor. ```python import bluepyopt.ephys as ephys # Initialize Arbor simulator arb_sim = ephys.simulators.ArbSimulator() # Use Arbor-compatible location somacenter_loc = ephys.locations.ArbLocsetLocation( name='somacenter', locset='(location 0 0.5)' ) # Create Arbor-specific protocol protocol = ephys.protocols.ArbSweepProtocol( 'Step1', stimuli=[stim], recordings=[rec] ) # Create evaluator with Arbor cell_evaluator = ephys.evaluators.CellEvaluator( cell_model=cell_model, param_names=['gnabar_hh', 'gkbar_hh'], fitness_protocols={'Step1': protocol}, fitness_calculator=score_calc, sim=arb_sim ) # Run optimization (same API as NEURON) optimisation = bpopt.optimisations.DEAPOptimisation( evaluator=cell_evaluator, offspring_size=50 ) final_pop, hof, logs, hist = optimisation.run(max_ngen=100) ``` -------------------------------- ### Compile Mechanisms for NeuroML Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/neuroml/neuroml.ipynb Compiles the NEURON mechanisms located in the specified directory using `nrnivmodl`. This step is necessary for the neuroml module to correctly utilize the cell's biophysical properties. ```bash os.system("nrnivmodl ../l5pc/mechanisms/") ``` -------------------------------- ### Evaluate and Plot Best Individual Responses Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/simplecell/simplecell-paperfig.ipynb Evaluates the top individuals from the optimization, converts their parameters to a dictionary format, and runs protocols to obtain responses. It then plots the voltage responses over time for visualization. ```python for best_ind in best_inds[:10]: best_ind_dict = cell_evaluator.param_dict(best_ind) print(cell_evaluator.evaluate_with_dicts(best_ind_dict), best_ind) plot_responses(twostep_protocol.run(cell_model=simple_cell, param_values=best_ind_dict, sim=nrn)) ``` -------------------------------- ### Load Simulation Protocols from JSON Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/l5pc/L5PC_arbor.ipynb This Python code demonstrates how to load simulation protocol configurations from a JSON file. It uses the `json` library to parse the 'config/protocols.json' file and prints the loaded configurations to the console. This is useful for setting up and running simulations with predefined protocols. ```python import json proto_configs = json.load(open('config/protocols.json')) print(proto_configs) ``` -------------------------------- ### Initialize DEAPOptimisation in BluePyOpt Source: https://github.com/openbraininstitute/bluepyopt/blob/master/examples/metaparameters/metaparameters.ipynb This snippet demonstrates how to initialize the DEAPOptimisation class from the BluePyOpt library. It requires an evaluator object and specifies the offspring size for the optimization process. ```python optimisation = bpop.optimisations.DEAPOptimisation( evaluator=cell_evaluator, offspring_size = 10) ```