Skip to content

Core

Client

flybrainlab.Client.Client(
    ssl=False,
    debug=True,
    authentication=True,
    user="guest",
    secret="guestpass",
    custom_salt=None,
    url="wss://flycircuitdev.neuronlp.fruitflybrain.org/ws",
    realm="realm1",
    ca_cert_file="isrgrootx1.pem",
    intermediate_cert_file="letsencryptauthorityx3.pem",
    FFBOLabcomm=None,
    legacy=False,
    initialize_client=True,
    name=None,
    species="",
    use_config=False,
    custom_config=None,
    widgets=[],
    dataset="default",
)

FlyBrainLab Client class. This class communicates with JupyterLab frontend and connects to FFBO components.

Attributes:

FFBOLabcomm (obj): The communication object for sending and receiving data. circuit (obj): A Neuroballad circuit that enables local circuit execution and facilitates circuit modification. dataPath (str): Data path to be used. experimentInputs (list of dicts): Inputs as a list of dicts that can be parsed by the GFX component. compiled (bool): Circuits need to be compiled into networkx graphs before being sent for simulation. This is necessary as circuit compilation is a slow process. sendDataToGFX (bool): Whether the data received from the backend should be sent to the frontend. Useful for code-only projects.


init

Client.__init__(
    ssl=False,
    debug=True,
    authentication=True,
    user="guest",
    secret="guestpass",
    custom_salt=None,
    url="wss://flycircuitdev.neuronlp.fruitflybrain.org/ws",
    realm="realm1",
    ca_cert_file="isrgrootx1.pem",
    intermediate_cert_file="letsencryptauthorityx3.pem",
    FFBOLabcomm=None,
    legacy=False,
    initialize_client=True,
    name=None,
    species="",
    use_config=False,
    custom_config=None,
    widgets=[],
    dataset="default",
)

Initialization function for the FBL Client class.

Arguments

  • ssl (bool): Whether the FFBO server uses SSL.
  • debug (bool) : Whether debugging should be enabled.
  • authentication (bool): Whether authentication is enabled.
  • user (str): Username for establishing communication with FFBO components.
  • secret (str): Password for establishing communication with FFBO components.
  • url (str): URL of the WAMP server with the FFBO Processor component.
  • realm (str): Realm to be connected to.
  • ca_cert_file (str): Path to the certificate for establishing connection.
  • intermediate_cert_file (str): Path to the intermediate certificate for establishing connection.
  • FFBOLabcomm (obj): Communications object for the frontend.
  • legacy (bool): Whether the server uses the old FFBO server standard or not. Should be False for most cases. Defaults to False.
  • initialize_client (bool): Whether to connect to the database or not. Defaults to True.
  • name (str): Name for the client. String. Defaults to None.
  • use_config (bool): Whether to read the url from config instead of as arguments to the initializer. Defaults to False. False recommended for new users.
  • species (str): Name of the species to use for client information. Defaults to ''.
  • custom_config (str): A .ini file name to use to initiate a custom connection. Defaults to None. Used if provided.
  • widgets (list): List of widgets associated with this client. Optional.
  • dataset (str): Name of the dataset to use. Not used right now, but included for future compatibility.

tryComms

Client.tryComms(a)

Communication function to communicate with a JupyterLab frontend if one exists.

Arguments

  • a (obj): Arbitrarily formatted data to be sent via communication.

executeNLPquery

Client.executeNLPquery(query=None, language="en", uri=None, queryID=None, returnNAOutput=False)

Execute an NLP query.

Arguments

  • query (str): Query string.
  • language (str): Language to use.
  • uri (str): Currently not used; for future NLP extensions.
  • queryID (str): Query ID to be used. Generated automatically.
  • returnNAOutput (bool): Whether the corresponding NA query should not be executed.

Returns

dict: NA output or the NA query itself, depending on the returnNAOutput setting.


executeNAquery

Client.executeNAquery(res, language="en", uri=None, queryID=None, progressive=True, threshold=20)

Execute an NA query.

Arguments

  • res (dict): Neuroarch query.
  • language (str): Language to use.
  • uri (str): A custom FFBO query URI if desired.
  • queryID (str): Query ID to be used. Generated automatically.
  • progressive (bool): Whether the loading should be progressive. Needs to be true most of the time for the connection to be stable.
  • threshold (int): Data chunk size. Low threshold is required for the connection to be stable.

Returns

bool: Whether the process has been successful.


FICurveGenerator

Client.FICurveGenerator(model)

Sample library function showing how to do automated experimentation using FFBOLab's Notebook features. Takes a simple abstract neuron model and runs experiments on it.

Arguments

  • model (Neuroballad Model Object): The model object to test.

Returns

numpy array: A tuple of NumPy arrays corresponding to the X and Y of the FI curve.


FICurvePlotSimResults

Client.FICurvePlotSimResults()

Plots some result curves for the FI curve generator example.


GFXcall

Client.GFXcall(args)

Arbitrary call to a GFX procedure in the GFX component format.

Arguments

  • args (list): A list whose first element is the function name (str) and the following are the arguments.

Returns

dict OR string: The call result.


JSCall

Client.JSCall(messageType="getExperimentConfig", data={})

ablate_by_match

Client.ablate_by_match(res, neuron_list)

addByUname

Client.addByUname(uname, verb="add")

Adds some neurons by the uname.

Returns

bool: True.


addInput

Client.addInput(x)

Adds an input to the experiment settings. The input is a Neuroballad input object.

Arguments

  • x (Neuroballad Input Object): The input object to append to the list of inputs.

Returns

dict: The input object added to the experiment list.


alter

Client.alter(X)

Alters a set of models with specified Neuroballad models.

Arguments

  • X (list of lists): A list of lists. Elements are lists whose first element is the neuron ID (str) and the second is the Neuroballad object corresponding to the model.

autoLayout

Client.autoLayout()

Layout raw data from NeuroArch and save results as G_auto.*.


createTag

Client.createTag(tagName)

Creates a tag.

Returns

bool: True.


execute_multilpu

Client.execute_multilpu(name, inputProcessors={}, outputProcessors={}, steps=None, dt=None)

Executes a multilpu circuit. Requires a result dictionary.

Arguments

  • res (dict): The result dictionary to use for execution.

Returns

bool: A success indicator.


export_diagram_config

Client.export_diagram_config(res)

Exports a diagram configuration from Neuroarch data to GFX.

Arguments

  • res (dict): The result dictionary to use for export.

Returns

dict: The configuration to export.


fetchCircuit

Client.fetchCircuit(X, local=True)

Deprecated function that locally saves a circuit file via the backend. Deprecated because of connectivity issues with large files.


fetchExperiment

Client.fetchExperiment(X, local=True)

Deprecated function that locally saves an experiment file via the backend. Deprecated because of connectivity issues with large files.


fetchSVG

Client.fetchSVG(X, local=True)

Deprecated function that locally saves an SVG via the backend. Deprecated because of connectivity issues with large files.


findServerIDs

Client.findServerIDs(dataset=None)

Find server IDs to be used for the utility functions.


genNB

Client.genNB(
    nodes, edges, model="auto", config={}, default_neuron=HodgkinHuxley, default_synapse=AlphaSynapse
)

Processes the output of processConnectivity to generate a Neuroballad circuit.

Returns

tuple: A tuple of the Neuroballad circuit, and a dictionary that maps the neuron names to the uids.


getConnectivity

Client.getConnectivity()

Obtain the connectivity matrix of the current circuit in NetworkX format.

Returns

dict: The connectivity dictionary.


getConnectivityDendrogram

Client.getConnectivityDendrogram()

getConnectivityMatrix

Client.getConnectivityMatrix()

getExperimentConfig

Client.getExperimentConfig()

getInfo

Client.getInfo(dbid)

Get information on a neuron.

Arguments

  • dbid (str): Database ID of the neuron or node.

Returns

dict: NA information regarding the node.


getNeuropils

Client.getNeuropils()

Get the neuropils the neurons in the workspace reside in.

Returns

list of strings: Set of neuropils corresponding to neurons.


getPostsynapticNeurons

Client.getPostsynapticNeurons(presynapticNeuron)

Returns a dictionary of all postsynaptic neurons for a given presynaptic neuron.

Arguments

  • presynapticNeuron (str): The name of the presynaptic neuron.

Returns

dict: A dictionary whose keys are the presynaptic neurons and whose values are numbers of synapses for the given presynaptic neuron.


getPresynapticNeurons

Client.getPresynapticNeurons(postsynapticNeuron)

Returns a dictionary of all presynaptic neurons for a given postsynaptic neuron.

Arguments

  • postsynapticNeuron (str): The name of the postsynaptic neuron.

Returns

dict: A dictionary whose keys are the presynaptic neurons and whose values are numbers of synapses for the given postsynaptic neuron.


getSimData

Client.getSimData(url)

getSimResults

Client.getSimResults()

Computes the simulation results.

Returns

numpy array: A neurons-by-time array of results. list: A list of neuron names, sorted according to the data.


getSlowConnectivity

Client.getSlowConnectivity()

Obtain the connectivity matrix of the current circuit in a custom dictionary format. Necessary for large circuits.

Returns

dict: The connectivity dictionary.


getStats

Client.getStats(neuron_name)

getSynapses

Client.getSynapses(presynapticNeuron, postsynapticNeuron)

Returns the synapses between a given presynaptic neuron and a postsynaptic neuron.

Arguments

  • presynapticNeuron (str): The name of the presynaptic neuron.
  • postsynapticNeuron (str): The name of the postsynaptic neuron.

Returns

float: The number of synapses.


get_client_info

Client.get_client_info(fbl=None)

Receive client data for this client only.

Arguments

  • fbl (Object): MetaClient object. Optional. Gives us.

Returns

dict: dict of dicts with client name as key and widgets, name and species as keys of the value.


get_current_neurons

Client.get_current_neurons(res)

import_diagram_config

Client.import_diagram_config(res, newConfig)

Imports a diagram configuration from Neuroarch data.

Arguments

  • res (dict): The result dictionary to update.
  • newConfig (dict): The imported configuration from a diagram.

Returns

dict: The updated Neuroarch result dictionary.


init_client

Client.init_client(ssl, user, secret, custom_salt, url, ssl_con, legacy)

initiateExperiments

Client.initiateExperiments()

Initializes and executes experiments for different LPUs.


listInputs

Client.listInputs()

Sends the current experiment settings to the frontend for displaying in an editor.


loadCartridge

Client.loadCartridge(cartridgeIndex=100)

Sample library function for loading cartridges, showing how one can build libraries that work with flybrainlab.


loadExperimentConfig

Client.loadExperimentConfig(x)

Updates the simExperimentConfig attribute using input from the diagram.

Arguments

  • x (string): A JSON dictionary as a string.

Returns

bool: True.


loadSVG

Client.loadSVG(name)

Loads an SVG in the FBL fileserver.

Arguments

  • name (str): Name to use when loading the file.

loadSWC

Client.loadSWC(file_name, scale_factor=1.0, uname=None)

Loads a neuron skeleton stored in the .swc format.

Arguments

  • file_name (str): Database ID of the neuron or node.
  • scale_factor (float): A scale factor to scale the neuron's dimensions with. Defaults to 1.
  • uname (str): Unique name to use in the frontend. Defaults to the file_name.

loadTag

Client.loadTag(tagName)

Loads a tag.

Returns

bool: True.


load_retina_lamina

Client.load_retina_lamina(
    cartridgeIndex=11, removed_neurons=[], removed_labels=[], retrieval_format="nk"
)

Loads retina and lamina.

Arguments

  • cartridgeIndex (int): The cartridge to load. Optional.

Returns

dict: A result dict to use with the execute_lamina_retina function.

Example:

nm[0].getExperimentConfig() # In a different cell experiment_configuration = nm[0].load_retina_lamina(cartridgeIndex=126) experiment_configuration = experiment_configuration['success']['result'] nm[0].execute_multilpu(experiment_configuration)


parseSimResults

Client.parseSimResults()

Parses the simulation results. Deprecated.


plotExecResult

Client.plotExecResult(result_name, inputs=None, outputs=None)

plotSimResults

Client.plotSimResults(B, keys)

Plots the simulation results. A simple function to demonstrate result display.

Arguments

  • model (Neuroballad Model Object): The model object to test.

prepareCircuit

Client.prepareCircuit(model="auto")

Prepares the current circuit for the Neuroballad format.


processConnectivity

Client.processConnectivity(connectivity)

Processes a Neuroarch connectivity dictionary.

Returns

tuple: A tuple of nodes, edges and unique edges.


prune_retina_lamina

Client.prune_retina_lamina(removed_neurons=[], removed_labels=[], retrieval_format="nk")

Prunes the retina and lamina circuits.

Arguments

  • cartridgeIndex (int): The cartridge to load. Optional.

Returns

dict: A result dict to use with the execute_lamina_retina function.

Example:

res = nm[0].load_retina_lamina() nm[0].execute_multilpu(res)


removeByUname

Client.removeByUname(uname)

Removes some neurons by the uname.

Returns

bool: True.


runLayouting

Client.runLayouting(type="auto", model="auto")

Sends a request for the running of the layouting algorithm.

Returns

bool: True.


sendCircuit

Client.sendCircuit(name="temp")

Sends a circuit to the backend.

Arguments

  • name (str): The name of the circuit for the backend.

sendCircuitPrimitive

Client.sendCircuitPrimitive(C, args={"name": "temp"})

Sends a NetworkX graph to the backend.


sendExecuteReceiveResults

Client.sendExecuteReceiveResults(
    circuitName="temp", dt=1e-05, tmax=1.0, inputProcessors=[], compile=False
)

Compiles and sends a circuit for execution in the GFX backend.

Arguments

  • circuitName (str): The name of the circuit for the backend.
  • compile (bool): Whether to compile the circuit first.

Returns

bool: Whether the call was successful.


sendNeuropils

Client.sendNeuropils()

Pack the list of neuropils into a GFX message.

Returns

bool: Whether the messaging has been successful.


sendSVG

Client.sendSVG(name, file)

Sends an SVG to the FBL fileserver. Useful for storing data and using loadSVG.

Arguments

  • name (str): Name to use when saving the file; '_visual' gets automatically appended to it.
  • file (str): Path to the SVG file.

updateBackend

Client.updateBackend(type="Null", data="Null")

Updates variables in the backend using the data in the Editor.

Arguments

  • type (str): A string, either "WholeCircuit" or "SingleNeuron", specifying the type of the update.
  • data (str): A stringified JSON

Returns

bool: Whether the update was successful.


updateSimResultLabel

Client.updateSimResultLabel(result_name, label_dict)