diff --git a/src/Global_Var.py b/src/Global_Var.py index 879ce06be8f76d6aced7d1a583744f429a2c9757..2c0a2d8495498e00c6e7b92c0b2eccc481f60fd8 100755 --- a/src/Global_Var.py +++ b/src/Global_Var.py @@ -118,21 +118,24 @@ class Global_Var(): if ('labels' in self.db.list_collection_names()): col = pymongo.collection.Collection(self.db, 'labels') col.create_index([("T", 1)]) - print("Labels index done") + if self.config.DEBUG: + print("Labels index done") if ('spikes' in self.db.list_collection_names()): col = pymongo.collection.Collection(self.db, 'spikes') col.create_index([("T", 1)]) col.create_index([("i.L", 1)]) col.create_index([("i.N", 1)]) - print("Spikes index done") + if self.config.DEBUG: + print("Spikes index done") if ('potential' in self.db.list_collection_names()): col = pymongo.collection.Collection(self.db, 'potential') col.create_index([("T", 1)]) col.create_index([("L", 1)]) col.create_index([("N", 1)]) - print("Potential index done") + if self.config.DEBUG: + print("Potential index done") if ('synapseWeight' in self.db.list_collection_names()): col = pymongo.collection.Collection(self.db, 'synapseWeight') @@ -140,7 +143,8 @@ class Global_Var(): col.create_index([("C", 1)]) col.create_index([("L", 1)]) col.create_index([("To", 1)]) - print("Synapses index done") + if self.config.DEBUG: + print("Synapses index done") def getLabelTime(self, step, value): """ Return a string that represent time . diff --git a/src/Modules/General/callbacks.py b/src/Modules/General/callbacks.py index ffb730852d857089c469cba67b8c2f7b9e0a60df..61c1ebb70b1be2ab6d1a82b7617b4ce057159f8c 100755 --- a/src/Modules/General/callbacks.py +++ b/src/Modules/General/callbacks.py @@ -609,9 +609,9 @@ class callbacks(callbacksOp): matrix[layer] = [] indices[layer] = [] - 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] + heatmaps = [{"data":[go.Heatmap(z = matrix[layer], colorscale= 'Reds', customdata = indices[layer], hovertemplate=('Neuron: %{customdata} <br>Spikes: %{z} <extra></extra>'),xgap=4,ygap=4)],"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= '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] + SpikesActivityPerInput = [{"data":[go.Heatmap(z=super.SpikesActivityPerInput[layer], colorscale= 'Reds',hovertemplate=('Class: %{x} <br>Neuron: %{y} <br>Spikes: %{z} <extra></extra>'),xgap=4,ygap=4)],"layout":{"xaxis":dict(title="Class",tickmode="array",zeroline = False,tickvals=[i for i in range(g.nbrClasses+1)]),"yaxis":dict(title="Neuron",zeroline = False),"margin":{'r': 0,'t': 0},"uirevision":'no reset of zoom'}} for layer in super.SpikesActivityPerInput] return [elements,[],heatmaps,SpikesActivityPerInput] else: @@ -626,9 +626,9 @@ class callbacks(callbacksOp): matrix[layer] = [] indices[layer] = [] - 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] + heatmaps = [{"data":[go.Heatmap(z = matrix[layer], colorscale= 'Reds', customdata = indices[layer], hovertemplate=('Neuron: %{customdata} <br>Spikes: %{z} <extra></extra>'),xgap=4,ygap=4)],"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= '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] + SpikesActivityPerInput = [{"data":[go.Heatmap(z=super.SpikesActivityPerInput[layer], colorscale= 'Reds',hovertemplate=('Class: %{x} <br>Neuron: %{y} <br>Spikes: %{z} <extra></extra>'),xgap=4,ygap=4)],"layout":{"xaxis":dict(title="Class",tickmode="array",zeroline = False,tickvals=[i for i in range(g.nbrClasses+1)]),"yaxis":dict(title="Neuron",zeroline = False),"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/spark.py b/src/Modules/General/spark.py index 063d31fce6974b6f5d323afb079478b620e4483d..eb175ab21d45eba707a0eedd9a5c2eb12e83e735 100755 --- a/src/Modules/General/spark.py +++ b/src/Modules/General/spark.py @@ -93,7 +93,8 @@ class spark(sparkOp): pass # ------------------------------------------------------------ - print("done ", self.MODULE_NAME) + if self.g.config.DEBUG: + print("done ", self.MODULE_NAME) except Exception: print("GlobalSpark:" + traceback.format_exc()) diff --git a/src/Modules/Neuron/layout.py b/src/Modules/Neuron/layout.py index 81c30ab51ce42e84096259e8b988addb93022dfc..603cab5dcb0e539ea41031fa89cdea3d0cd2d85b 100755 --- a/src/Modules/Neuron/layout.py +++ b/src/Modules/Neuron/layout.py @@ -57,7 +57,8 @@ class layout(layoutOp): """ try: self.clearData([]) - print("neuron-vis") + if self.g.config.DEBUG: + print("neuron-vis") self.SpikePerNeuron = self.getSpikePerNeuron(self.g) layer = dbc.Card( dbc.CardBody( @@ -181,11 +182,11 @@ class layout(layoutOp): 'layout': {'margin': {'l': 0, 'r': 0, 't': 30, 'b': 0}}} else: data = self.SpikePerNeuron - + print(data) data = [d for d, l in product(data, g.finalLabels) if ( int(l["N"]) == d['i']['N'] and int(l["Label"]) == filteredClass["z"])] xx = [N["i"]["N"] for N in data] - yy = [(count["count"]) for count in data] + yy = [count["count"] for count in data] graph = {'data': [go.Bar( x=[x for x in range(len(xx))], diff --git a/src/Modules/Neuron/spark.py b/src/Modules/Neuron/spark.py index 02c4dec4f691f0002cb287a2497ee82b511da34f..54dafba7cc68f4572e9155fd13dca0fa29a63f9d 100755 --- a/src/Modules/Neuron/spark.py +++ b/src/Modules/Neuron/spark.py @@ -53,7 +53,8 @@ class spark(sparkOp): if(not self.DOCUMENT_NAME in self.g.db.list_collection_names()): print(self.DOCUMENT_NAME, "not found") self.g.modules = [module for module in self.g.modules if module != self.MODULE_NAME] - print("done ", self.MODULE_NAME) + if self.g.config.DEBUG: + print("done ", self.MODULE_NAME) except Exception: print("Error:" + traceback.format_exc()) diff --git a/src/Modules/Synapse/spark.py b/src/Modules/Synapse/spark.py index 70e9a8fc1e26fd5af8c26d3831327e7deda84113..89cce7af9ae4878decfeccf9f18368dafc095108 100755 --- a/src/Modules/Synapse/spark.py +++ b/src/Modules/Synapse/spark.py @@ -61,8 +61,9 @@ class spark(sparkOp): col = pymongo.collection.Collection(self.g.db, 'synapseWeightFinal') globalSynapseWeights = pd.DataFrame(list(col.aggregate([{"$group": {"_id":None, "x":{"$max":"$_id.index.x"}, "y":{"$max":"$_id.index.y"}}}]))) self.g.NeuronsSize = {"x":globalSynapseWeights["x"].max(),"y":globalSynapseWeights["y"].max()} - - print("done", self.MODULE_NAME) + + if self.g.config.DEBUG: + print("done", self.MODULE_NAME) except Exception: print("Error:" + traceback.format_exc())