### Example Output of Fitness Configuration Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/edit_fitness_calculator_configuration.ipynb Presents a sample output of the fitness calculator configuration, detailing the structure of defined protocols. This includes parameters like name, stimuli, recordings, validation status, protocol type, and stochasticity settings. ```text Fitness Calculator Configuration: Protocols: {'name': 'IDrest_130', 'stimuli': [{'delay': 700.5, 'amp': 0.4508745591995102, 'thresh_perc': 136.24160437248662, 'duration': 2000.25, 'totduration': 3000.0, 'holding_current': -0.09770833142101765}], 'recordings_from_config': [{'type': 'CompRecording', 'name': 'IDrest_130.soma.v', 'location': 'soma', 'variable': 'v'}], 'validation': False, 'protocol_type': 'ThresholdBasedProtocol', 'stochasticity': False} {'name': 'IDrest_200', 'stimuli': [{'delay': 700.5, 'amp': 0.6552015231929614, 'thresh_perc': 197.9834632177735, 'duration': 2000.25, 'totduration': 3000.0, 'holding_current': -0.09765624813735485}], 'recordings_from_config': [{'type': 'CompRecording', 'name': 'IDrest_200.soma.v', 'location': 'soma', 'variable': 'v'}], 'validation': False, 'protocol_type': 'ThresholdBasedProtocol', 'stochasticity': False} {'name': 'IV_0', 'stimuli': [{'delay': 20.0, 'amp': 0.00016210680283757512, 'thresh_perc': 0.048984114201291125, 'duration': 1000.0, 'totduration': 1320.0, 'holding_current': -0.09769097136126624}], 'recordings_from_config': [{'type': 'CompRecording', 'name': 'IV_0.soma.v', 'location': 'soma', 'variable': 'v'}], 'validation': False, 'protocol_type': 'ThresholdBasedProtocol', 'stochasticity': False} ``` -------------------------------- ### Test ICSelector Tool with Shell Script Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/others/README.rst This example provides a bash script to test the ICSelector tool. ICSelector helps in selecting ion channel models based on gene sets and assigning parameter bounds. The script requires gene/ion channel mapping files for testing. ```bash sh ./icselector/test_icselector.sh ``` -------------------------------- ### Monitor Pipeline with Web UI Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/README.md Starts a web-based user interface for monitoring the Luigi pipeline's progress. Returns a URL that should be opened in a web browser. ```bash bbp-workflow webui -o ``` -------------------------------- ### Setup Virtual Environment Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/README.md Commands to initialize and activate a virtual environment for the project. Ensure Python 3.10 or higher is used as required by bbp-workflow. This step is crucial for managing project dependencies. ```bash kinit ./create_venv.sh source myvenv/bin/activate ``` -------------------------------- ### Create and Activate Virtual Environment Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/L5PC/README.rst Creates a Python virtual environment named 'myvenv' and installs BluePyEModel within it. This isolates project dependencies. ```shell ./create_venv.sh ``` -------------------------------- ### Modify and Upload MEModel using Python Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/others/README.rst This example shows how to create an MEModel, modify its morphology, run simulations, perform plot analysis, and upload the modified MEModel. Users need to edit the `memodel.py` script to specify the MEModel ID before running. ```python python ./memodel/memodel.py ``` -------------------------------- ### Install BluePyEModel with all dependencies Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/doc/source/index.md This command installs the BluePyEModel package along with all its optional dependencies, providing a full-featured environment for electrical neuron modeling. Ensure Python 3.11+ is installed. ```bash pip install bluepyemodel[all] ``` -------------------------------- ### Install BluePyEModel with specific dependencies Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/doc/source/index.md This command allows for a modular installation of BluePyEModel, enabling users to install only the specific dependencies they require. Dependencies can be listed within the brackets, separated by commas. Available options include 'luigi', 'nexus', and 'all'. ```bash pip install bluepyemodel[luigi,nexus] ``` -------------------------------- ### Run EModel Simulation with BlueCelluLab Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/others/README.rst Demonstrates how to run an EModel simulation stored on Nexus using BlueCelluLab to analyze single-cell behavior. It requires specifying the EModel and simulation parameters. Refer to the README for detailed instructions. -------------------------------- ### Define and Add a New Protocol Configuration Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/edit_fitness_calculator_configuration.ipynb Demonstrates how to define a new experimental protocol, 'Step_1000', including its stimuli and recording configurations. The protocol is then appended to the global fitness configuration for use in simulations. ```python protocol_name = "Step_1000" stimuli = [{ "amp": None, "delay": 700, "duration": 4, "holding_current": None, "thresh_perc": 1000, "totduration": 1000 }] recordings = [ { "type": "CompRecording", "location": "soma", "name": f"{protocol_name}.soma.v", "variable": "v" }, ] protocol_config = ProtocolConfiguration( name=protocol_name, stimuli=stimuli, recordings=recordings, validation=False ) fitness_config.protocols.append(protocol_config) ``` -------------------------------- ### Set Initial Optimization Parameters in Bluepyemodel Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/doc/source/_autosummary/bluepyemodel.emodel_pipeline.emodel_settings.md Specifies the initial values for model parameters when starting an optimization process from a previously optimized model. This is useful for multi-step optimizations, allowing you to build upon existing results. The dictionary requires 'emodel', 'etype', and 'iteration_tag'. ```python start_from_emodel = { "emodel": "bNAC", "etype": "bNAC", "iteration_tag": "mytest" } ``` -------------------------------- ### Setup and Run Parameter Optimization Source: https://context7.com/openbraininstitute/bluepyemodel/llms.txt Configures and executes the parameter optimization process using evolutionary algorithms. It requires an access point to simulation data and a multiprocessing mapper for distributed computation. Outputs include optimization checkpoints and best parameter sets. ```python from bluepyemodel.optimisation.optimisation import setup_and_run_optimisation, store_best_model from bluepyemodel.tools.multiprocessing import get_mapper # Get parallel mapper for distributed evaluation mapper = get_mapper(backend="ipyparallel") # Run optimization (typically 100-200 generations) # This creates a checkpoint file tracking optimization progress # Assuming 'pipeline' object is defined elsewhere setup_and_run_optimisation( access_point=pipeline.access_point, seed=1, mapper=mapper, preselect_for_validation=True ) # After optimization completes, extract and store best models store_best_model( access_point=pipeline.access_point, seed=1, checkpoint_path=None, # Auto-detected only_validated=False ) # Output: checkpoint.pkl containing population history # Output: final.json containing best parameter sets ``` -------------------------------- ### Run Simulation and Get Voltage Data Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/others/run_emodel/run_emodel.ipynb This Python code executes the simulation for a specified duration and retrieves the voltage data from the soma. It initializes a `Simulation` object, adds the configured cell to it, and runs the simulation. The `get_time` and `get_soma_voltage` methods are used to obtain the simulation time and voltage traces, respectively. ```python # Run the simulation max_time = 200 sim = Simulation() sim.add_cell(cell) sim.run(max_time, cvode=False) time, voltage = cell.get_time(), cell.get_soma_voltage() ``` -------------------------------- ### Store Fitness Calculator Configuration (Python) Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/edit_fitness_calculator_configuration.ipynb Stores a fitness calculator configuration object using the access_point's store_fitness_calculator_configuration method. This function is essential for saving the state of a fitness calculation setup. ```python access_point.store_fitness_calculator_configuration(fitness_config) ``` -------------------------------- ### Launch Luigi Pipeline Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/README.md Executes the main Luigi pipeline. Requires setting environment variables in launch_luigi.sh to match Nexus resource configurations. Includes steps for environment activation, Nexus authentication, and pipeline execution. ```bash source myvenv/bin/activate kinit ./launch_luigi.sh ``` -------------------------------- ### Initialize Git Repository Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/L5PC/README.rst Initializes a new Git repository in the current directory. This is a prerequisite for versioning simulation runs. ```shell git init . ``` -------------------------------- ### Install bluepyemodel using pip Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/others/run_emodel/README.rst Installs the bluepyemodel package using pip. This is a prerequisite for running emodel simulations. ```shell pip install bluepyemodel ``` -------------------------------- ### Import necessary libraries for emodel pipeline Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/run_pipeline.ipynb Imports core libraries for the emodel pipeline, including ModelConfigurator, EModel_pipeline, EModelPipelineSettings, and TargetsConfigurator. These are essential for setting up and running the pipeline. ```python import logging from bluepyemodel.model.model_configurator import ModelConfigurator from bluepyemodel.emodel_pipeline.emodel_pipeline import EModel_pipeline from bluepyemodel.emodel_pipeline.emodel_settings import EModelPipelineSettings from bluepyemodel.efeatures_extraction.targets_configurator import TargetsConfigurator ``` -------------------------------- ### Install bluecellulab using pip Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/others/run_emodel/README.rst Installs the bluecellulab package using pip. This package is required for running emodel simulations on BlueCelluLab. ```shell pip install bluecellulab ``` -------------------------------- ### Initialize logging for the pipeline Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/run_pipeline.ipynb Sets up the Python logging system to display information during pipeline execution. This helps in monitoring the progress and debugging any issues. ```python logger = logging.getLogger() logging.basicConfig( level=logging.INFO, handlers=[logging.StreamHandler()], ) ``` -------------------------------- ### Get Protocol List from Protocol Name Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/doc/source/_autosummary/bluepyemodel.tools.multiprotocols_efeatures_utils.md Reconstructs a list of protocols from a given protocol name. ```APIDOC ## GET /bluepyemodel/tools/multiprotocols_efeatures_utils/get_protocol_list_from_protocol_name ### Description Reconstruct protocol list from protocol name. ### Method GET ### Endpoint /bluepyemodel/tools/multiprotocols_efeatures_utils/get_protocol_list_from_protocol_name #### Query Parameters - **prot_name** (string) - Required - The name of the protocol. ### Response #### Success Response (200) - **protocol_list** (list of strings) - A list of reconstructed protocol names. #### Response Example ```json { "protocol_list": ["protocolA", "protocolB"] } ``` ``` -------------------------------- ### Configure Nexus and Forge settings Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/run_pipeline.ipynb Specifies settings for Nexus integration and Forge, including project, organization, endpoint, and paths to configuration files. These are crucial for data access and model loading. ```python # Nexus settings nexus_project = "" # specify the nexus project nexus_organisation = "" # specify the nexus organisation nexus_endpoint = "prod" forge_path = "./forge.yml" forge_ontology_path = "./nsg.yml" legacy_conf_json_file = "./../L5PC/config/params/pyr.json" # specify the path to the json file containing the model configuration if the model is not configured from gene data ``` -------------------------------- ### Get Distances from Recording Name Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/doc/source/_autosummary/bluepyemodel.tools.multiprotocols_efeatures_utils.md Retrieves apical distances based on the provided recording name. ```APIDOC ## GET /bluepyemodel/tools/multiprotocols_efeatures_utils/get_distances_from_recording_name ### Description Get apical distances from recording name. ### Method GET ### Endpoint /bluepyemodel/tools/multiprotocols_efeatures_utils/get_distances_from_recording_name #### Query Parameters - **rec_name** (string) - Required - The name of the recording. ### Response #### Success Response (200) - **distances** (list of float) - A list of apical distances. #### Response Example ```json { "distances": [10.5, 20.2, 30.0] } ``` ``` -------------------------------- ### Configure targets for feature extraction Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/run_pipeline.ipynb Initializes and configures the TargetsConfigurator using data from 'targets.py'. It prepares the necessary metadata, target definitions, and protocol configurations for feature extraction. ```python from targets import filenames, ecodes_metadata, targets, protocols_rheobase files_metadata = [] for filename in filenames: files_metadata.append({"cell_name": filename, "ecodes": ecodes_metadata}) targets_formated = [] for ecode in targets: for amplitude in targets[ecode]["amplitudes"]: for efeature in targets[ecode]["efeatures"]: targets_formated.append( { "efeature": efeature, "protocol": ecode, "amplitude": amplitude, "tolerance": 10.0, } ) configurator = TargetsConfigurator(pipeline.access_point) configurator.new_configuration(files_metadata, targets_formated, protocols_rheobase) configurator.save_configuration() print(configurator.configuration.as_dict()) ``` -------------------------------- ### Get Soma Protocol from Protocol Name Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/doc/source/_autosummary/bluepyemodel.tools.multiprotocols_efeatures_utils.md Retrieves the recording name at the soma from multi-location protocols' names. ```APIDOC ## GET /bluepyemodel/tools/multiprotocols_efeatures_utils/get_soma_protocol_from_protocol_name ### Description Get recording name at soma from multi-locations protocols' name. ### Method GET ### Endpoint /bluepyemodel/tools/multiprotocols_efeatures_utils/get_soma_protocol_from_protocol_name #### Query Parameters - **prot_name** (string) - Required - The protocol name. - **amplitude** (integer) - Required - The amplitude value. ### Response #### Success Response (200) - **soma_recording_name** (string) - The recording name at the soma. #### Response Example ```json { "soma_recording_name": "soma_recording_1" } ``` ``` -------------------------------- ### BluePyEModel Configuration Parameters Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/doc/source/_autosummary/bluepyemodel.emodel_pipeline.emodel_settings.md This section describes the parameters used for configuring electrophysiological models and their optimization within the BluePyEModel framework. ```APIDOC ## BluePyEModel Configuration Parameters ### Description This section describes the parameters used for configuring electrophysiological models and their optimization within the BluePyEModel framework. ### Method N/A (Configuration parameters) ### Endpoint N/A (Configuration parameters) ### Parameters #### Query Parameters - **default_std_value** (float) - Optional - At the end of e-features extraction, all features presenting a standard deviation of 0, will see their standard deviation replaced by the present value. - **bound_max_std** (bool) - Optional - If set to True, the std from extraction will be set to the mean value from extraction if it goes above it. - **efel_settings** (dict) - Optional - EFEL settings in the form {setting_name: setting_value} to be used during extraction. If settings are also informed in the targets on a per efeature basis, the latter will have priority. - **minimum_protocol_delay** (float) - Optional - During optimisation, if a protocol has an initial delay shorter than this value, the delay will be set to minimum_protocol_delay. - **stochasticity** (bool or list of str) - Optional - Should channels behave stochastically if they can. If True, the mechanisms will be stochastic for all protocols. If a list of protocol names is provided, the mechanisms will be stochastic only for these protocols. - **morph_modifiers** (list of str or list of list) - Optional - Modifiers to apply to the morphology. If str, name of the morph modifier to use from bluepyemodel.evaluation.modifiers. If List of morphology modifiers, each modifier is defined by a list that includes the path to the file, the name of the function, and optionally a hoc_string. If None, the default modifier will replace the axon with a tappered axon. If you do not wish to use any modifier, set to []. If ["bluepyopt_replace_axon"], the replace_axon function from bluepyopt.ephys.morphologies.NrnFileMorphology will be used and no other morph modifiers will be used. - **threshold_based_evaluator** (bool) - Optional - Not used. To be deprecated. - **start_from_emodel** (dict) - Optional - If informed, the optimisation for the present e-model will be instantiated using as values for the model parameters the ones from the e-model specified in the present dict. Example: {"emodel": "bNAC", "etype": "bNAC", "iteration_tag": "mytest"}. - **optimiser** (str) - Optional - Name of the algorithm used for optimisation, can be 'IBEA', 'SO-CMA' or 'MO-CMA'. - **optimizer** (str) - Optional - Here for backward compatibility. Use optimiser instead. - **optimisation_params** (dict) - Optional - Parameters for the optimisation process. Keys have to match the call of the optimiser. Possible options and default values for IBEA, SO-CMA, MO-CMA are provided in the documentation. - **optimisation_timeout** (float) - Optional - Duration (in seconds) after which the evaluation will time out. ### Request Example ```json { "default_std_value": 0.1, "bound_max_std": true, "efel_settings": { "t_start": 0, "t_stop": 100 }, "minimum_protocol_delay": 5.0, "stochasticity": true, "morph_modifiers": [["path/to/module", "function_name", "hoc_string"]], "start_from_emodel": { "emodel": "bNAC", "etype": "bNAC", "iteration_tag": "mytest" }, "optimiser": "IBEA", "optimisation_params": { "offspring_size": 100 }, "optimisation_timeout": 3600.0 } ``` ### Response #### Success Response (200) - **message** (str) - Indicates successful configuration or operation. #### Response Example ```json { "message": "Configuration updated successfully." } ``` ``` -------------------------------- ### Get Protocol List from Recording Name Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/doc/source/_autosummary/bluepyemodel.tools.multiprotocols_efeatures_utils.md Reconstructs a list of protocols based on the provided recording name. ```APIDOC ## GET /bluepyemodel/tools/multiprotocols_efeatures_utils/get_protocol_list_from_recording_name ### Description Reconstruct recording list from recording name. ### Method GET ### Endpoint /bluepyemodel/tools/multiprotocols_efeatures_utils/get_protocol_list_from_recording_name #### Query Parameters - **rec_name** (string) - Required - The name of the recording. ### Response #### Success Response (200) - **protocol_list** (list of strings) - A list of reconstructed protocol names associated with the recording. #### Response Example ```json { "protocol_list": ["protocolX", "protocolY"] } ``` ``` -------------------------------- ### Execute BluePyEModel Pipeline Steps Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/L5PC/README.rst Runs the main steps of the BluePyEModel pipeline in sequence: extraction, optimisation, analysis, and HOC export. Requires prior configuration of variables and SBATCH directives. ```shell ./extract.sh ./optimisation.sh ./analysis.sh ./export_hoc.sh ``` -------------------------------- ### get_hotspot_location Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/doc/source/_autosummary/bluepyemodel.model.morphology_utils.md Identifies the start and end points of a calcium hotspot in terms of soma distance along the apical dendrite. ```APIDOC ## GET /bluepyemodel/model/morphology_utils/get_hotspot_location ### Description Get hot spot begin and end in terms of soma distance. Calcium hot spot should be in distal apical trunk, and in primary and secondary tufts, i.e. around apical point, according to Larkum and Zhu, 2002. Attention! Apical point detection is not always accurate. ### Method GET ### Endpoint /bluepyemodel/model/morphology_utils/get_hotspot_location ### Parameters #### Query Parameters - **morph_path** (string) - Required - Path to the morphology file. - **hotspot_percent** (float) - Optional - Percentage of the radial apical distance that is in the hot spot. Defaults to 20.0. ### Response #### Success Response (200) - **hotspot_begin_distance** (float) - The soma distance to the beginning of the hotspot. - **hotspot_end_distance** (float) - The soma distance to the end of the hotspot. #### Response Example ```json { "hotspot_begin_distance": 130.0, "hotspot_end_distance": 170.0 } ``` ``` -------------------------------- ### Get Soma Protocol from Recording Name Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/doc/source/_autosummary/bluepyemodel.tools.multiprotocols_efeatures_utils.md Retrieves the recording name at the soma from multi-location protocols' names based on the recording name. ```APIDOC ## GET /bluepyemodel/tools/multiprotocols_efeatures_utils/get_soma_protocol_from_recording_name ### Description Get recording name at soma from multi-locations protocols' name. ### Method GET ### Endpoint /bluepyemodel/tools/multiprotocols_efeatures_utils/get_soma_protocol_from_recording_name #### Query Parameters - **rec_name** (string) - Required - The recording name. - **amplitude** (integer) - Required - The amplitude value. ### Response #### Success Response (200) - **soma_recording_name** (string) - The recording name at the soma. #### Response Example ```json { "soma_recording_name": "soma_recording_2" } ``` ``` -------------------------------- ### Configure the model using gene data Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/run_pipeline.ipynb Configures the model for the pipeline by specifying the morphology and format, and indicates that gene data should be used for configuration. This step prepares the model structure. ```python pipeline.configure_model(morphology_name=morphology, morphology_format=morphology_format, use_gene_data=True) ``` -------------------------------- ### Load and Print recipes.json Configuration Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/simplecell/simplecell.ipynb Loads the 'recipes.json' configuration file and prints its content in a formatted JSON string. This file contains key settings for the e-model building pipeline stages. ```python import json recipes_path = "./config/recipes.json" with open(recipes_path, 'r') as file: recipe = json.load(file) print(json.dumps(recipe, indent=4)) ``` -------------------------------- ### Add EFeatureConfiguration for a New Protocol Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/edit_fitness_calculator_configuration.ipynb Illustrates how to define and add an EFeatureConfiguration, 'Spikecount', associated with the previously defined 'Step_1000' protocol. This configuration specifies the feature to be extracted and its parameters. ```python efeature_def = EFeatureConfiguration( efel_feature_name="Spikecount", protocol_name=protocol_name, recording_name="soma.v", mean=1.0, std=0.1, efel_settings={"strict_stiminterval": False}, threshold_efeature_std=None, ) fitness_config.efeatures.append(efeature_def) print(fitness_config) ``` -------------------------------- ### Initialize EModel_pipeline with Nexus access Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/run_pipeline.ipynb Instantiates the EModel_pipeline class, configuring it with Nexus settings, model parameters, and enabling parallel processing options. This object is central to running the simulation. ```python pipeline = EModel_pipeline( emodel=emodel, etype=etype, mtype=mtype, ttype=ttype, iteration_tag=iteration, species=species, brain_region=brain_region, forge_path=forge_path, forge_ontology_path=forge_ontology_path, nexus_organisation=nexus_organisation, nexus_project=nexus_project, nexus_endpoint=nexus_endpoint, use_ipyparallel=True, use_multiprocessing=False, data_access_point="nexus", ) ``` -------------------------------- ### Extracting Adaptation Index Features (Python) Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/edit_fitness_calculator_configuration.ipynb This snippet illustrates the extraction of the 'adaptation_index' feature, quantifying the decrease in firing frequency over time. The analysis is performed under the 'IDrest_130' protocol. ```python { 'efel_feature_name': 'adaptation_index', 'protocol_name': 'IDrest_130', 'recording_name': 'soma.v', 'threshold_efeature_std': 0.1, 'default_std_value': 0.001, 'mean': 0.021810381821812972, 'original_std': 0.025904931541217195, 'sample_size': 6, 'efeature_name': 'adaptation_index', 'weight': 1.0, 'efel_settings': { 'strict_stiminterval': True, 'Threshold': -20, 'interp_step': 0.025 } } ``` -------------------------------- ### Load Model Components and Run Simulation (Python) Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/others/run_emodel/run_emodel.ipynb Loads the HOC and morphology files for a model, retrieves holding and threshold currents, and then configures and runs a simulation. It utilizes 'bluecellulab' for cell and simulation management. Inputs include directory paths and model configuration details. Outputs are simulation time and voltage traces. ```python # Load the hoc and morphology hoc_file = Path(directory_path) / "model.hoc" morph_file = nap.download_morphology(model_configuration.morphology.name, model_configuration.morphology.format, model_configuration.morphology.id) holding_current, threshold_current = getHoldingThreshCurrent(forge, r) ``` ```python from bluecellulab import Cell, Simulation from bluecellulab.stimulus.circuit_stimulus_definitions import OrnsteinUhlenbeck, ShotNoise from bluecellulab.simulation.neuron_globals import NeuronGlobals from bluecellulab.circuit.circuit_access import EmodelProperties NeuronGlobals.get_instance().temperature = 34.0 NeuronGlobals.get_instance().v_init = -70 emodel_properties = EmodelProperties(threshold_current=threshold_current, holding_current=holding_current) emodel_properties ``` ```python # Define stimulus parameters start_time = 100.0 # Start time of the stimulus stop_time = 250.0 # Stop time of the stimulus level = threshold_current # Current level of the stimulus cell = Cell(hoc_file, morph_file, template_format="v6", emodel_properties=emodel_properties) icneurodamusobj = cell.add_step(start_time=start_time, stop_time=stop_time, level=level) ``` ```python import neuron iclamp_current = neuron.h.Vector() iclamp_current.record(icneurodamusobj.ic._ref_i) ``` ```python # Run the simulation max_time = 300 sim = Simulation() sim.add_cell(cell) sim.run(max_time, cvode=False) time, voltage = cell.get_time(), cell.get_soma_voltage() ``` ```python # Plot the simulation fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(7.5, 10)) ax1.plot(time, iclamp_current, drawstyle='steps-post') ax1.set_title("Stimulus") ax1.set_xlabel("Time (ms)") ax1.set_ylabel("Current (nA)") ax1.fill_between(time, 0, list(iclamp_current), step="post", color='gray', alpha=0.3) ax1.grid(True) ax2.plot(time, voltage) ax2.set_title("Response") ax2.set_xlabel("Time (ms)") ax2.set_ylabel("Voltage (mV)") ax2.grid(True) plt.suptitle("Step") plt.tight_layout() plt.show() ``` -------------------------------- ### Extracting Irregularity Index Features (Python) Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/edit_fitness_calculator_configuration.ipynb This snippet focuses on the 'irregularity_index' feature, which measures the variability in neuronal firing patterns. It provides statistical summaries for the 'IDrest_130' protocol. ```python { 'efel_feature_name': 'irregularity_index', 'protocol_name': 'IDrest_130', 'recording_name': 'soma.v', 'threshold_efeature_std': 0.1, 'default_std_value': 0.001, 'mean': 213.95798611189414, 'original_std': 278.960340993408, 'sample_size': 6, 'efeature_name': 'irregularity_index', 'weight': 1.0, 'efel_settings': { 'strict_stiminterval': True, 'Threshold': -20, 'interp_step': 0.025 } } ``` -------------------------------- ### Extracting Voltage Base Features (Python) Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/edit_fitness_calculator_configuration.ipynb This snippet demonstrates the extraction of 'voltage_base', representing the resting membrane potential or baseline voltage. It includes statistical analysis for the 'IDrest_200' protocol. ```python { 'efel_feature_name': 'voltage_base', 'protocol_name': 'IDrest_200', 'recording_name': 'soma.v', 'threshold_efeature_std': 0.1, 'default_std_value': 0.001, 'mean': -82.656065689877, 'original_std': 0.4123618296597106, 'sample_size': 6, 'efeature_name': 'voltage_base', 'weight': 1.0, 'efel_settings': { 'strict_stiminterval': True, 'Threshold': -20, 'interp_step': 0.025 } } ``` -------------------------------- ### Configure EModel from JSON using Python Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/README.md Sets up the EModelConfiguration (EMC) by parsing a legacy JSON file. The path to the JSON file should be updated in pipeline.py before execution. Requires specifying e-model name, iteration tag, and type parameters. ```bash python pipeline.py --step=configure_model_from_json --emodel=EMODEL_NAME --iteration_tag=ITERATION_TAG --etype=ETYPE --mtype=MTYPE --ttype=TTYPE ``` -------------------------------- ### Extracting Mean Frequency Features (Python) Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/edit_fitness_calculator_configuration.ipynb This snippet shows the extraction of 'mean_frequency', representing the average firing rate of the neuron over a specified period. Data is presented for the 'IDrest_200' protocol. ```python { 'efel_feature_name': 'mean_frequency', 'protocol_name': 'IDrest_200', 'recording_name': 'soma.v', 'threshold_efeature_std': 0.1, 'default_std_value': 0.001, 'mean': 10.189637299220186, 'original_std': 1.778840871822643, 'sample_size': 6, 'efeature_name': 'mean_frequency', 'weight': 1.0, 'efel_settings': { 'strict_stiminterval': True, 'Threshold': -20, 'interp_step': 0.025 } } ``` -------------------------------- ### Configure Nexus Resources using Python Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/README.md Registers EModelPipelineSettings (EMPS) and ExtractionTargetsConfiguration (ETC) on the Nexus project. Requires specifying e-model name, iteration tag, and type parameters. The iteration tag is crucial for matching resources and pipeline execution. ```bash python pipeline.py --step=configure_nexus --emodel=EMODEL_NAME --iteration_tag=ITERATION_TAG --etype=ETYPE --mtype=MTYPE --ttype=TTYPE ``` -------------------------------- ### Instantiate EModel Pipeline with Configuration Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/simplecell/simplecell.ipynb Instantiates the EModel_pipeline class, which loads the recipes.json file and configures the pipeline. Requires minimal parameters like e-model name, electrical type, species, brain region, morphology, and morphology format. ```python emodel = "simplecell" etype = "cADpyr" species = "rat" brain_region = "SSCX" morphology = "simple" morphology_format = "swc" pipeline = EModel_pipeline( emodel=emodel, etype=etype, species=species, brain_region=brain_region, recipes_path=recipes_path, data_access_point="local", ) ``` -------------------------------- ### Display Nexus ID Image Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/others/run_emodel/run_emodel.ipynb Uses IPython.display to show an image that visually guides the user on how to find and specify the Nexus ID for an e-model. This is a visual aid for input. ```python from IPython.display import display, Image display(Image(filename="./../../nexus/img_nexus_id.png")) ``` -------------------------------- ### Import Core Libraries for Nexus Access Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/others/run_emodel/run_emodel.ipynb Imports essential Python libraries for interacting with Nexus, managing knowledge graphs, handling credentials, and file system operations. These are foundational for accessing and processing e-model data. ```python from kgforge.core import KnowledgeGraphForge import getpass from bluepyemodel.access_point.nexus import NexusAccessPoint import os import shutil from pathlib import Path ``` -------------------------------- ### Configure Nexus Connection Parameters Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/others/run_emodel/run_emodel.ipynb Sets up variables for the e-model ID, Nexus organization, project, endpoint URL, and the path to the Nexus forge configuration file. These parameters are crucial for connecting to Nexus and retrieving data. ```python emodel_id="" # paste the id here ORG = "" # paste the Nexus organization here PROJECT = "" # paste the Nexus project here endpoint = "" # replace with the Nexus endpoint url forge_path = ( "https://raw.githubusercontent.com/BlueBrain/nexus-forge/" + "master/examples/notebooks/use-cases/prod-forge-nexus.yml" ) ``` -------------------------------- ### Import BluePyEModel Configuration Classes Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/edit_fitness_calculator_configuration.ipynb Imports the necessary classes for defining E(lectrophysiological) Features and Protocol Configurations within BluePyEModel. These classes are fundamental for setting up simulation evaluation parameters. ```python from bluepyemodel.evaluation.efeature_configuration import EFeatureConfiguration from bluepyemodel.evaluation.protocol_configuration import ProtocolConfiguration ``` -------------------------------- ### Extracting Time to First Spike Features (Python) Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/edit_fitness_calculator_configuration.ipynb This snippet details the extraction of 'time_to_first_spike', measuring the latency from stimulus onset to the first action potential. Statistics are provided for the 'IDrest_200' protocol. ```python { 'efel_feature_name': 'time_to_first_spike', 'protocol_name': 'IDrest_200', 'recording_name': 'soma.v', 'threshold_efeature_std': 0.1, 'default_std_value': 0.001, 'mean': 16.58333333295502, 'original_std': 3.72677996249626, 'sample_size': 6, 'efeature_name': 'time_to_first_spike', 'weight': 1.0, 'efel_settings': { 'strict_stiminterval': True, 'Threshold': -20, 'interp_step': 0.025 } } ``` -------------------------------- ### Set pipeline optimization and validation parameters Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/run_pipeline.ipynb Creates an EModelPipelineSettings object to define various optimization and validation parameters for the pipeline, including stochasticity, optimizer choice, and plotting preferences. ```python pipeline_settings = EModelPipelineSettings( stochasticity=False, optimiser="SO-CMA", optimisation_params={"offspring_size": 20}, optimisation_timeout=600.0, threshold_efeature_std=0.1, max_ngen=100, validation_threshold=10.0, plot_extraction=True, plot_optimisation=True, compile_mechanisms=True, name_Rin_protocol="IV_-40", name_rmp_protocol="IV_0", efel_settings={ "strict_stiminterval": True, "Threshold": -20, "interp_step": 0.025, }, strict_holding_bounds=True, validation_protocols=["IDhyperpol_150"], morph_modifiers=[], n_model=3, optimisation_batch_size=3, max_n_batch=5, name_gene_map="Mouse_met_types_ion_channel_expression", ) pipeline.access_point.store_pipeline_settings(pipeline_settings) ``` -------------------------------- ### Import necessary libraries for E-Model pipeline Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/simplecell/simplecell.ipynb Imports the EModel_pipeline and TargetsConfigurator classes from the bluepyemodel library. These are essential for setting up and running the e-model optimization pipeline. ```python import json from bluepyemodel.emodel_pipeline.emodel_pipeline import EModel_pipeline from bluepyemodel.efeatures_extraction.targets_configurator import TargetsConfigurator ``` -------------------------------- ### Extracting Doublet ISI Features (Python) Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/examples/nexus/edit_fitness_calculator_configuration.ipynb This snippet covers the extraction of 'doublet_ISI', which likely refers to the inter-spike interval between spikes within a doublet. Statistical measures are provided for the 'IDrest_200' protocol. ```python { 'efel_feature_name': 'doublet_ISI', 'protocol_name': 'IDrest_200', 'recording_name': 'soma.v', 'threshold_efeature_std': 0.1, 'default_std_value': 0.001, 'mean': 44.208333333293126, 'original_std': 9.628967436268557, 'sample_size': 6, 'efeature_name': 'doublet_ISI', 'weight': 1.0, 'efel_settings': { 'strict_stiminterval': True, 'Threshold': -20, 'interp_step': 0.025 } } ``` -------------------------------- ### EModel Figure Generation API Source: https://github.com/openbraininstitute/bluepyemodel/blob/main/doc/source/_autosummary/bluepyemodel.tools.search_pdfs.md This API provides functions to get the path to PDF files representing various features and fits of an EModel, such as EPSP, ISI_CV, bAP, currentscapes, optimization convergence, parameter distributions, and traces. ```APIDOC ## EModel Figure Generation API Endpoints ### Description Provides functions to retrieve paths to PDF files representing various EModel figures. ### Endpoints **figure_emodel_EPSP** * **Description**: Get path for the pdf representing the EPSP of an emodel. * **Parameters**: * `emodel_metadata` (any) - Required - Metadata for the emodel. * `seed` (int) - Required - The seed used for the simulation. * `use_allen_notation` (bool) - Optional - Whether to use Allen notation. **figure_emodel_ISI_CV** * **Description**: Get path for the pdf representing the ISI_CV fit of an emodel. * **Parameters**: * `emodel_metadata` (any) - Required - Metadata for the emodel. * `seed` (int) - Required - The seed used for the simulation. * `use_allen_notation` (bool) - Optional - Whether to use Allen notation. **figure_emodel_bAP** * **Description**: Get path for the pdf representing the bAP of an emodel. * **Parameters**: * `emodel_metadata` (any) - Required - Metadata for the emodel. * `seed` (int) - Required - The seed used for the simulation. * `use_allen_notation` (bool) - Optional - Whether to use Allen notation. **figure_emodel_currentscapes** * **Description**: Get path for the pdfs representing the currentscapes of an emodel. * **Parameters**: * `emodel_metadata` (any) - Required - Metadata for the emodel. * `seed` (int) - Required - The seed used for the simulation. * `use_allen_notation` (bool) - Optional - Whether to use Allen notation. **figure_emodel_optimisation** * **Description**: Get path for the pdf representing the convergence of the optimisation. * **Parameters**: * `emodel_metadata` (any) - Required - Metadata for the emodel. * `seed` (int) - Required - The seed used for the simulation. * `use_allen_notation` (bool) - Optional - Whether to use Allen notation. **figure_emodel_parameters** * **Description**: Get path for the pdf representing the distribution of the parameters of an emodel. * **Parameters**: * `emodel_metadata` (any) - Required - Metadata for the emodel. * `seed` (int, optional) - The seed used for the simulation. Defaults to None. * `use_allen_notation` (bool) - Optional - Whether to use Allen notation. **figure_emodel_parameters_evolution** * **Description**: Get path for the pdf representing the evolution of the parameters of an emodel. * **Parameters**: * `emodel_metadata` (any) - Required - Metadata for the emodel. * `seed` (int, optional) - The seed used for the simulation. Defaults to None. * `use_allen_notation` (bool) - Optional - Whether to use Allen notation. **figure_emodel_rheobase** * **Description**: Get path for the pdf representing the rheobase fit of an emodel. * **Parameters**: * `emodel_metadata` (any) - Required - Metadata for the emodel. * `seed` (int) - Required - The seed used for the simulation. * `use_allen_notation` (bool) - Optional - Whether to use Allen notation. **figure_emodel_score** * **Description**: Get path for the pdf representing the scores of an emodel. * **Parameters**: * `emodel_metadata` (any) - Required - Metadata for the emodel. * `seed` (int) - Required - The seed used for the simulation. * `use_allen_notation` (bool) - Optional - Whether to use Allen notation. **figure_emodel_thumbnail** * **Description**: Get path for the pdf representing the thumbnail of an emodel. * **Parameters**: * `emodel_metadata` (any) - Required - Metadata for the emodel. * `seed` (int) - Required - The seed used for the simulation. * `use_allen_notation` (bool) - Optional - Whether to use Allen notation. **figure_emodel_traces** * **Description**: Get path for the pdf representing the traces of an emodel. * **Parameters**: * `emodel_metadata` (any) - Required - Metadata for the emodel. * `seed` (int) - Required - The seed used for the simulation. * `use_allen_notation` (bool) - Optional - Whether to use Allen notation. **figure_efeatures** * **Description**: Get path to pdf representing the efeature extracted from ephys recordings. * **Parameters**: * `emodel` (any) - Required - The emodel object. * `protocol_name` (str) - Required - The name of the protocol. * `efeature` (str) - Required - The efeature to get the path for. ```