diff --git a/src/Modules/General/callbacks.py b/src/Modules/General/callbacks.py index c3bdbf4af5777bed1626b165a1a276c64709e3d3..ffb730852d857089c469cba67b8c2f7b9e0a60df 100755 --- a/src/Modules/General/callbacks.py +++ b/src/Modules/General/callbacks.py @@ -513,8 +513,8 @@ class callbacks(callbacksOp): try: if(speedValue < 0.25): speedValue = 0.25 - if (speedValue > 5): - speedValue = 5 + if (speedValue > 120): + speedValue = 120 return [speedValue * 1000,speedValue] except Exception: @@ -577,8 +577,13 @@ class callbacks(callbacksOp): for layer in Layer2DViewFilter: #neurons = [[0 for j in range(g.nbrClasses)] for i in range(g.Layer_Neuron[layer])] - if spikes: - maxSpike = max([list(list(list(s.values())[0].values())[0].values())[0] for s in spikes if list(s.keys())[0] == layer]) + try: + layerSpikes = [list(list(list(s.values())[0].values())[0].values())[0] for s in spikes if list(s.keys())[0] == layer] + except Exception: + layerSpikes = [] + + if spikes and layerSpikes: + maxSpike = max(layerSpikes) for spike in spikes: if list(spike.keys())[0] == layer: # update the spikes neurons @@ -604,9 +609,9 @@ class callbacks(callbacksOp): matrix[layer] = [] indices[layer] = [] - heatmaps = [{"data":[go.Heatmap(z = matrix[layer], colorscale= 'Reds',showscale= False, customdata = indices[layer], hovertemplate=('Neuron: %{customdata} <br>Spikes: %{z} <extra></extra>'))],"layout":{"xaxis":dict(showgrid = False, zeroline = False),"yaxis":dict(autorange = 'reversed',scaleanchor = 'x',showgrid = False, zeroline = False),"margin":{'l': 0, 'r': 0, 't': 5, 'b': 0},"uirevision":'no reset of zoom', "hoverlabel_align": 'right'}} for layer in super.AccumulatedSpikes2D] + heatmaps = [{"data":[go.Heatmap(z = matrix[layer], colorscale= 'Reds', customdata = indices[layer], hovertemplate=('Neuron: %{customdata} <br>Spikes: %{z} <extra></extra>'))],"layout":{"xaxis":dict(showgrid = False, zeroline = False),"yaxis":dict(autorange = 'reversed',scaleanchor = 'x',showgrid = False, zeroline = False),"margin":{'l': 0, 'r': 0, 't': 5, 'b': 0},"uirevision":'no reset of zoom', "hoverlabel_align": 'right'}} for layer in super.AccumulatedSpikes2D] - SpikesActivityPerInput = [{"data":[go.Heatmap(z=super.SpikesActivityPerInput[layer], colorscale= 'jet',showscale= False,hovertemplate=('Class: %{x} <br>Neuron: %{y} <br>Spikes: %{z} <extra></extra>'))],"layout":{"xaxis":dict(title="Class",tickmode="array",tickvals=[i for i in range(g.nbrClasses+1)]),"yaxis":dict(title="Neuron"),"margin":{'l':25,'r': 0,'t': 0},"uirevision":'no reset of zoom'}} for layer in super.SpikesActivityPerInput] + SpikesActivityPerInput = [{"data":[go.Heatmap(z=super.SpikesActivityPerInput[layer], colorscale= 'Reds',hovertemplate=('Class: %{x} <br>Neuron: %{y} <br>Spikes: %{z} <extra></extra>'))],"layout":{"xaxis":dict(title="Class",tickmode="array",tickvals=[i for i in range(g.nbrClasses+1)]),"yaxis":dict(title="Neuron"),"margin":{'r': 0,'t': 0},"uirevision":'no reset of zoom'}} for layer in super.SpikesActivityPerInput] return [elements,[],heatmaps,SpikesActivityPerInput] else: @@ -621,9 +626,9 @@ class callbacks(callbacksOp): matrix[layer] = [] indices[layer] = [] - heatmaps = [{"data":[go.Heatmap(z = matrix[layer], colorscale= 'Reds',showscale= False, customdata = indices[layer], hovertemplate=('Neuron: %{customdata} <br>Spikes: %{z} <extra></extra>'))],"layout":{"xaxis":dict(showgrid = False, zeroline = False),"yaxis":dict(autorange = 'reversed',scaleanchor = 'x',showgrid = False, zeroline = False),"margin":{'l': 0, 'r': 0, 't': 5, 'b': 0},"uirevision":'no reset of zoom', "hoverlabel_align": 'right'}} for layer in super.AccumulatedSpikes2D] + heatmaps = [{"data":[go.Heatmap(z = matrix[layer], colorscale= 'Reds', customdata = indices[layer], hovertemplate=('Neuron: %{customdata} <br>Spikes: %{z} <extra></extra>'))],"layout":{"xaxis":dict(showgrid = False, zeroline = False),"yaxis":dict(autorange = 'reversed',scaleanchor = 'x',showgrid = False, zeroline = False),"margin":{'l': 0, 'r': 0, 't': 5, 'b': 0},"uirevision":'no reset of zoom', "hoverlabel_align": 'right'}} for layer in super.AccumulatedSpikes2D] - SpikesActivityPerInput = [{"data":[go.Heatmap(z=super.SpikesActivityPerInput[layer], colorscale= 'jet',showscale= False,hovertemplate=('Class: %{x} <br>Neuron: %{y} <br>Spikes: %{z} <extra></extra>'))],"layout":{"xaxis":dict(title="Class",tickmode="array",tickvals=[i for i in range(g.nbrClasses+1)]),"yaxis":dict(title="Neuron"),"margin":{'l':25,'r': 0,'t': 0},"uirevision":'no reset of zoom'}} for layer in super.SpikesActivityPerInput] + SpikesActivityPerInput = [{"data":[go.Heatmap(z=super.SpikesActivityPerInput[layer], colorscale= 'Reds',hovertemplate=('Class: %{x} <br>Neuron: %{y} <br>Spikes: %{z} <extra></extra>'))],"layout":{"xaxis":dict(title="Class",tickmode="array",tickvals=[i for i in range(g.nbrClasses+1)]),"yaxis":dict(title="Neuron"),"margin":{'r': 0,'t': 0},"uirevision":'no reset of zoom'}} for layer in super.SpikesActivityPerInput] return [elements,f"Neuron {mouseOverNodeData['label']} : {mouseOverNodeData['spikes']}" if 'spikes' in mouseOverNodeData else "", heatmaps,SpikesActivityPerInput] except Exception: print("OnHover:"+traceback.format_exc()) diff --git a/src/Modules/General/layout.py b/src/Modules/General/layout.py index e23ab657d1b7bb07e6d4feb5da0dd22fc99b417a..db02ae245e43c2c78e97128431e90463f7f1e8ca 100755 --- a/src/Modules/General/layout.py +++ b/src/Modules/General/layout.py @@ -271,7 +271,7 @@ class layout(layoutOp): )],style={'position': 'absolute','width': '100%','height': '100%','z-index': 999,"background": "rgba(68, 71, 99, 0.05)"}), html.P(id="spikes_info", style={"padding": "8px","margin":"0px"}) - ], style={ "height": "50vh","textAlign": "start", "padding": "0px"},className="col-lg-6 col-sm-12 col-xs-12"), + ], style={ "height": "50vh","textAlign": "start", "padding": "0px"},className="col-lg-5 col-sm-12 col-xs-12"), # 3D destribution html.Div([ @@ -279,7 +279,7 @@ class layout(layoutOp): dcc.Tabs([dcc.Tab(dbc.Card(dbc.CardBody([ dcc.Graph(id={"type":"SpikesActivityPerInput","index":i}, config={"displaylogo": False}) ])),label=i, value='SpikesActivityPerInput-'+str(x)) for x, i in enumerate(self.g.Layer_Neuron) if i != "Input"],value="SpikesActivityPerInput-1") - ], style={"textAlign": "start", },className="col-lg-3 col-sm-12 col-xs-12") + ], style={"textAlign": "start", },className="col-lg-4 col-sm-12 col-xs-12") ], className="row")), label="2D view", value="2Dview")], id="tabinfo", value="General information"), @@ -324,7 +324,7 @@ class layout(layoutOp): html.Span("Update Speed (s)", className="input-group-text") ], className="input-group-prepend"), - dbc.Input(type="number", id="speed", value=1, min=0.25, max=5, step=0.25, style={ + dbc.Input(type="number", id="speed", value=1, min=0.25, max=120, step=0.25, style={ "width": "30%", "textAlign": "center"}) ], className="input-group col-md-12 col-sm-12 col-lg-4", style={"height": "38px", "paddingTop": "12px"}),