Skip to content

Commit 1b06749

Browse files
author
Lucas Rebscher
committed
#215 Use netpyne's checkAvailablePlots method
1 parent 0d8d07b commit 1b06749

3 files changed

Lines changed: 44 additions & 14 deletions

File tree

netpyne_ui/netpyne_geppetto.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,9 @@ def getDirList(self, dir=None, onlyDirs=False, filterFiles=False):
428428
file_list.append({'title': f, 'path': ff})
429429
return dir_list + file_list
430430

431+
def checkAvailablePlots(self):
432+
return analysis.checkAvailablePlots()
433+
431434
def getPlot(self, plotName, LFPflavour, theme='gui'):
432435
try:
433436
with redirect_stdout(sys.__stdout__):
@@ -523,8 +526,18 @@ def getMechParams(self, mechanism):
523526
return [value[:-(len(mechanism) + 1)] for value in params]
524527

525528
def getAvailablePlots(self):
526-
plots = ["iplotRaster", "iplotSpikeHist", "plotSpikeStats", "iplotRatePSD", "iplotTraces", "iplotLFP",
527-
"plotShape", "plot2Dnet", "iplotConn", "granger"]
529+
plots = [
530+
"iplotRaster",
531+
"iplotSpikeHist",
532+
"plotSpikeStats",
533+
"iplotRatePSD",
534+
"iplotTraces",
535+
"iplotLFP",
536+
"plotShape",
537+
"plot2Dnet",
538+
"iplotConn",
539+
"granger"
540+
]
528541

529542
return [plot for plot in plots if plot not in list(self.simConfig.analysis.keys())]
530543

webapp/constants.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const NETPYNE_COMMANDS = {
2525
exportHLS: 'netpyne_geppetto.exportHLS',
2626
plotFigure: 'netpyne_geppetto.getPlot',
2727
deleteParam: 'netpyne_geppetto.deleteParam',
28+
checkAvailablePlots: 'netpyne_geppetto.checkAvailablePlots',
2829
};
2930

3031
export const PYTHON_CONSOLE_WIDGET = {
@@ -80,6 +81,7 @@ export const NETWORK_PLOT_WIDGETS = {
8081
hideOnClose: true,
8182
initialized: false,
8283
method: {
84+
plotKey: 'plotConn',
8385
plotMethod: 'iplotConn',
8486
plotType: false,
8587
},
@@ -96,6 +98,7 @@ export const NETWORK_PLOT_WIDGETS = {
9698
hideOnClose: true,
9799
initialized: false,
98100
method: {
101+
plotKey: 'plot2Dnet',
99102
plotMethod: 'iplot2Dnet',
100103
plotType: false,
101104
},
@@ -116,6 +119,7 @@ export const PLOT_WIDGETS = {
116119
enableRename: false,
117120
initialized: false,
118121
method: {
122+
plotKey: 'plotTraces',
119123
plotMethod: 'iplotTraces',
120124
plotType: false,
121125
},
@@ -132,6 +136,7 @@ export const PLOT_WIDGETS = {
132136
hideOnClose: true,
133137
initialized: false,
134138
method: {
139+
plotKey: 'plotRaster',
135140
plotMethod: 'iplotRaster',
136141
plotType: false,
137142
},
@@ -148,6 +153,7 @@ export const PLOT_WIDGETS = {
148153
hideOnClose: true,
149154
initialized: false,
150155
method: {
156+
plotKey: 'plotSpikeHist',
151157
plotMethod: 'iplotSpikeHist',
152158
plotType: false,
153159
},
@@ -164,6 +170,7 @@ export const PLOT_WIDGETS = {
164170
enableRename: false,
165171
initialized: false,
166172
method: {
173+
key: 'plotSpikeStats',
167174
plotMethod: 'iplotSpikeStats',
168175
plotType: false,
169176
},
@@ -180,6 +187,7 @@ export const PLOT_WIDGETS = {
180187
hideOnClose: true,
181188
initialized: false,
182189
method: {
190+
key: 'plotRatePSD',
183191
plotMethod: 'iplotRatePSD',
184192
plotType: false,
185193
},
@@ -196,6 +204,7 @@ export const PLOT_WIDGETS = {
196204
hideOnClose: true,
197205
initialized: false,
198206
method: {
207+
plotKey: 'plotLFP',
199208
plotMethod: 'iplotLFP',
200209
plotType: 'timeSeries',
201210
},
@@ -212,6 +221,7 @@ export const PLOT_WIDGETS = {
212221
enableRename: false,
213222
initialized: false,
214223
method: {
224+
plotKey: 'plotLFP',
215225
plotMethod: 'iplotLFP',
216226
plotType: 'PSD',
217227
},
@@ -228,6 +238,7 @@ export const PLOT_WIDGETS = {
228238
hideOnClose: true,
229239
initialized: false,
230240
method: {
241+
plotKey: 'plotLFP',
231242
plotMethod: 'iplotLFP',
232243
plotType: 'spectrogram',
233244
},
@@ -244,6 +255,7 @@ export const PLOT_WIDGETS = {
244255
enableRename: false,
245256
initialized: false,
246257
method: {
258+
plotKey: 'granger',
247259
plotMethod: 'granger',
248260
plotType: false,
249261
},
@@ -260,6 +272,7 @@ export const PLOT_WIDGETS = {
260272
enableRename: false,
261273
initialized: false,
262274
method: {
275+
plotKey: 'plotRxDConcentration',
263276
plotMethod: 'iplotRxDConcentration',
264277
plotType: false,
265278
},

webapp/redux/middleware/plotMiddleware.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,11 @@ export default (store) => (next) => (action) => {
5252
break;
5353
}
5454
case SET_WIDGETS: {
55-
// This is triggered once when we change the layout from Edit > Explore
55+
// This is triggered once when we change the layout from Edit > Explore.
56+
// We add the widgets (back) to the sidebar but without fetching any data.
5657
for (const widget of Object.values(action.data)) {
57-
// TODO: initializes all widgets once CREATE_NETWORK was called, but we want lazy loading!
5858
if (widget.id in PLOT_WIDGETS) {
59-
setWidget(widget)
60-
.then((widget) => (widget ? next(addWidget(widget)) : null));
59+
next(addWidget(widget));
6160
}
6261
}
6362
next(action);
@@ -75,15 +74,20 @@ export default (store) => (next) => (action) => {
7574
}
7675
case SIMULATE_NETWORK:
7776
case CREATE_SIMULATE_NETWORK: {
78-
// TODO: reset widget state (disabled|false)
79-
// TODO: widget.disabled = True|False
8077
window.plotCache = {};
81-
// TODO: use netpyne checkAvailable plots to determine what is enabled and disabled!
82-
// only have to call it here and for create network, i.e. once the model changes
83-
for (const widget of Object.values(PLOT_WIDGETS)) {
84-
widget.initialized = false;
85-
next(addWidget(widget));
86-
}
78+
79+
Utils.evalPythonMessage(NETPYNE_COMMANDS.checkAvailablePlots, [])
80+
.then((plots) => {
81+
Object.values(PLOT_WIDGETS)
82+
.forEach((widget) => {
83+
widget.initialized = false;
84+
widget.disabled = true;
85+
if (widget.method.plotKey in plots) {
86+
widget.disabled = !plots[widget.method.plotKey];
87+
}
88+
next(addWidget(widget));
89+
});
90+
});
8791

8892
next(action);
8993
break;

0 commit comments

Comments
 (0)