<jupyter_start><jupyter_text>Model from Givon et al., 2017<jupyter_code>import cxcircuits.cx as cxlib
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
client = fbl.get_client()
for i in fbl.widget_manager.widgets:
    if fbl.widget_manager.widgets[i].widget_id not in fbl.client_manager.clients[fbl.widget_manager.widgets[i].client_id]['widgets']:
        fbl.client_manager.clients[fbl.widget_manager.widgets[i].client_id]['widgets'].append(fbl.widget_manager.widgets[i].widget_id)<jupyter_output><empty_output><jupyter_text>Loading CX model data from NeuroArch database.<jupyter_code>cx = cxlib.CX_Constructor(client, 'Givon_frontiers17')<jupyter_output>[FBL Client NLP 2020-12-15 05:11:52] Received a message.
[FBL Client NLP 2020-12-15 05:11:57] Received a message.
[FBL Client NLP 2020-12-15 05:11:58] Received a message.
[FBL Client NLP 2020-12-15 05:11:58] Received a message.<jupyter_text>Neuron/Synapses can be easily disabled by clicking on the diagram or using API, such as the code below.<jupyter_code>cx.initialize_diagram_config()<jupyter_output>sending circuit configuration to GFX<jupyter_text>A Family of neurons can also be removed quickly using API.<jupyter_code># cx.disable_all()
cx.disable_neuron_families(['PB-FB-NO', 'PB-FB-LAL', 'FB-local'])
res = cx.remove_components()<jupyter_output>[FBL Client NLP 2020-12-15 05:12:33] Received a message.
[FBL Client NLP 2020-12-15 05:12:37] Received a message.<jupyter_text>Configuring inputs to each neuropil and what to record<jupyter_code>import itertools
shape = (200, 360)
dt = 1e-4
dur = 35.0
steps = int(dur/dt)
video_type = 'moving_bar_test'
bar_width = 20
BU_video_config = {'type': video_type,
                   'bar_width': bar_width,
                   'stop': dur,
                   'record': None}
BU_rf_config = {'sigma': 0.05}
bu_video_config = {'type': video_type,
                'bar_width': bar_width,
                'stop': dur-0.1,
                'record': None}
bu_rf_config = {'sigma': 0.05}
PB_video_config = {'type': video_type,
                   'bar_width': bar_width,
                   'stop': dur,
                   'record': None
                   #'record': 'video.h5',
                   #'record_interval': 100 #record every 100 steps of input video
                  }
PB_rf_config = {'num_glomeruli': 8}

BU_rid = cx.rid_dict['Neuropil']['BU']
BU_models = [cx.find_models(neuron)[0] for neuron in cx.owns(BU_rid, 'Neuron')]
BU_neurons = {rid: cx.data.nodes[rid] for rid in BU_models}

bu_rid = cx.rid_dict['Neuropil']['bu']
bu_models = [cx.find_models(neuron)[0] for neuron in cx.owns(bu_rid, 'Neuron')]
bu_neurons = {rid: cx.data.nodes[rid] for rid in bu_models}

PB_subregions = ['PB/L{}'.format(i) for i in range(1,10)] + \
                ['PB/R{}'.format(i) for i in range(1,10)]
PB_rids = list(itertools.chain.from_iterable([cx.neuron_uid_by_family('PB-EB-LAL', k) for k in PB_subregions])) +\
          list(itertools.chain.from_iterable([cx.neuron_uid_by_family('PB-EB-NO', k) for k in PB_subregions if k.split('/')[1][1]!='9']))
#           list(itertools.chain.from_iterable([cx.neuron_uid_by_family('PB-FB-NO', k) for k in PB_subregions]))+\
#           list(itertools.chain.from_iterable([cx.neuron_uid_by_family('PB-FB-LAL', k) for k in PB_subregions]))
PB_neurons = {rid: cx.data.nodes[rid] for rid in PB_rids}

# Since the PB-EB-LAL neuron is a PB neuron, it will be executed in the PB LPU.
# So we first create an entry for PB in the input_processors dict,
# with name "PB_InputProcessor" (See cx_fbl.cx_input).
# All the parameters should be spelt out in the dict.
# Additional input processors can be specified by extending the list.
# We do the same for 'BU' and 'bu' with "BU_InputProcessor".
input_processors = {'PB': [{'class': 'PB_InputProcessor',
                            'name': 'PB',
                            'module': 'cxcircuits.cx_input', # this is where PB_InputProcessor should be imported from
                            'shape': shape,
                            'dt': dt,
                            'dur': dur,
                            'video_config': PB_video_config,
                            'rf_config': PB_rf_config,
                            'neurons': PB_neurons,
                            'scale': 24.0,
                            'record_file': 'PB_input.h5',
                            'record_interval': 10000}],
                    'BU': [{'class': 'BU_InputProcessor', 
                            'name': 'BUr',
                            'module': 'cxcircuits.cx_input', # this is where BU_InputProcessor should be imported from
                            'shape': shape,
                            'dt': dt,
                            'dur': dur,
                            'scale': 2.0,
                            'video_config': BU_video_config,
                            'rf_config': BU_rf_config,
                            'neurons': BU_neurons,
                            'record_file': 'BU_input.h5',
                            'record_interval': 10000}],
                    'bu': [{'class': 'BU_InputProcessor',
                            'name': 'bul',
                            'module': 'cxcircuits.cx_input',
                            'shape': shape,
                            'dt': dt,
                            'dur': dur,
                            'scale': 2.0,
                            'video_config': bu_video_config,
                            'rf_config': bu_rf_config,
                            'neurons': bu_neurons,
                            'record_file': 'bu_input.h5',
                            'record_interval': 10000}]
                   }

# Specify an output processor that is to record all nodes with an output of 'V' or 'spike_state'.
# The sample interval for voltage is every 10 steps. Spikes will be returned with spike time.
output_processors = {'PB': [{'class': 'Record',
                             'uid_dict': {#'V': {'uids': None},
                                          'spike_state': {'uids': None},
                                          'g': {'uids': None}
                                          },
                             'sample_interval': 100}
                           ],
                     'EB': [{'class': 'Record',
                            'uid_dict': {#'V': {'uids': None},
                                         'spike_state': {'uids': None},
                                         },
                           'sample_interval': 100}
                          ],
                     'BU': [{'class': 'Record',
                             'uid_dict': {'spike_state': {'uids': None},
                                         },
                             'sample_interval': 100}
                            ],
                     'bu': [{'class': 'Record',
                             'uid_dict': {'spike_state': {'uids': None},
                                         },
                             'sample_interval': 100}
                            ]
                    }<jupyter_output><empty_output><jupyter_text>Execute the circuit<jupyter_code>cx.execute(input_processors = input_processors,
           output_processors = output_processors,
           steps = steps, dt = dt)
result = cx.get_result()
wedge_response = cx.show_EB_response(dur, dt, vmax = 400)
cx.show_EB_response_at_step(wedge_response, 100000, vmax = 400)<jupyter_output>/home/ffbo/ffbo/cx_fbl/cx_fbl/cx_lib.py:1464: matplotlib.cbook.deprecation.MatplotlibDeprecationWarning: shading='flat' when X and Y have the same dimensions as C is deprecated since 3.3.  Either specify the corners of the quadrilaterals with X and Y, or pass shading='auto', 'nearest' or 'gouraud', or set rcParams['pcolor.shading'].  This will become an error two minor releases later.
{'fraction_non_alphanumeric': 0.11780438104941417, 'fraction_numerical': 0.02381558838512481, 'mean_word_length': 1.8350180505415163, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '562721', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 2518, 'n_tokens_neox': 2311, 'n_words': 568, 'path': 'notebooks/elife20/Givon_frontiers17.ipynb', 'repo_name': 'FlyBrainLab/CXcircuits', 'size': '7852'}