Skip to content

Commit f0fa329

Browse files
Merge pull request #498 from MetaCell/feature/447_netpyne_upgrade_101
updating release/080 branch with latest netpyne upgrade 101
2 parents 7f41c38 + f5c9568 commit f0fa329

File tree

20 files changed

+597
-1027
lines changed

20 files changed

+597
-1027
lines changed

netpyne_ui/netpyne_geppetto.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ def simulate_single_model(self, experiment: model.Experiment = None, use_prev_in
248248
netpyne_model = self.instantiateNetPyNEModel()
249249

250250
self.geppetto_model = self.model_interpreter.getGeppettoModel(netpyne_model)
251+
251252
simulations.run()
252253

253254
if self.geppetto_model:
@@ -777,7 +778,12 @@ def conns_length(cell) -> int:
777778
else:
778779
return [ui.getSVG(fig)]
779780
else:
780-
return fig_data
781+
if plotName == 'plotEEG':
782+
return self.simConfig.filename + '_EEG.png'
783+
elif plotName == 'plotDipole':
784+
return self.simConfig.filename + '_dipole.png'
785+
else:
786+
return fig_data
781787
except Exception as e:
782788
err = "There was an exception in %s():" % (e.plotName)
783789
logging.exception(("%s \n %s \n%s" % (err, e, sys.exc_info())))
@@ -834,7 +840,9 @@ def getAvailablePlots(self):
834840
"plotShape",
835841
"plot2Dnet",
836842
"iplotConn",
837-
"granger"
843+
"granger",
844+
"plotDipole",
845+
"plotEEG"
838846
]
839847

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

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ multimethod==1.3
4444
nbconvert==5.6.1
4545
nbformat==5.0.6
4646
neuromllite==0.1.9
47-
netpyne==1.0.0.2
47+
netpyne==1.0.2.1
4848
NEURON==8.0.2
4949
numpy==1.18.5
5050
oauthlib==3.0.1

webapp/Main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Provider } from 'react-redux';
44
import { MuiThemeProvider } from '@material-ui/core/styles';
55
import * as Sentry from '@sentry/react';
66
import { CaptureConsole } from '@sentry/integrations';
7+
import { LoadingSpinner } from '@metacell/geppetto-meta-client/components';
78
import { NetPyNE } from './components';
89
import theme from './theme';
910
import store from './redux/store';
@@ -33,6 +34,7 @@ ReactDOM.render(
3334
<div>
3435
<MuiThemeProvider theme={theme}>
3536
<Provider store={store}>
37+
<LoadingSpinner />
3638
<NetPyNE />
3739
</Provider>
3840
</MuiThemeProvider>

webapp/components/NetPyNE.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
LayoutManager,
99
Drawer,
1010
Dialog,
11+
ConfirmationDialog,
1112
LaunchDialog,
1213
} from 'netpyne/components';
1314

@@ -140,6 +141,7 @@ class NetPyNE extends React.Component {
140141
</Box>
141142
</div>
142143
<Dialog />
144+
<ConfirmationDialog />
143145
<ErrorDialog />
144146
<LaunchDialog />
145147
</div>

webapp/components/definition/configuration/NetPyNESimConfig.js

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,6 @@ class NetPyNESimConfig extends React.Component {
7171
<ListComponent model="simConfig.seeds" />
7272
</NetPyNEField>
7373

74-
<NetPyNEField
75-
id="simConfig.checkErrors"
76-
className="netpyneCheckbox"
77-
>
78-
<NetPyNECheckbox model="simConfig.checkErrors" />
79-
</NetPyNEField>
80-
81-
<NetPyNEField
82-
id="simConfig.checkErrorsVerbose"
83-
className="netpyneCheckbox"
84-
>
85-
<NetPyNECheckbox model="simConfig.checkErrorsVerbose" />
86-
</NetPyNEField>
8774
</div>
8875
);
8976
contentRight = (
@@ -290,13 +277,54 @@ class NetPyNESimConfig extends React.Component {
290277
<NetPyNECheckbox model="simConfig.saveLFPCells" />
291278
</NetPyNEField>
292279

280+
<NetPyNEField
281+
id="simConfig.saveLFPPops"
282+
className="netpyneCheckbox"
283+
style={{ marginTop: 25 }}
284+
>
285+
<NetPyNECheckbox model="simConfig.saveLFPPops" />
286+
</NetPyNEField>
287+
293288
<NetPyNEField
294289
id="simConfig.recordStim"
295290
className="netpyneCheckbox"
296291
style={{ marginTop: 25 }}
297292
>
298293
<NetPyNECheckbox model="simConfig.recordStim" />
299294
</NetPyNEField>
295+
296+
<NetPyNEField
297+
id="simConfig.recordDipole"
298+
className="netpyneCheckbox"
299+
style={{ marginTop: 25 }}
300+
>
301+
<NetPyNECheckbox model="simConfig.recordDipole" />
302+
</NetPyNEField>
303+
304+
<NetPyNEField
305+
id="simConfig.recordDipolesHNN"
306+
className="netpyneCheckbox"
307+
style={{ marginTop: 25 }}
308+
>
309+
<NetPyNECheckbox model="simConfig.recordDipolesHNN" />
310+
</NetPyNEField>
311+
312+
313+
<NetPyNEField
314+
id="simConfig.saveDipoleCells"
315+
className="netpyneCheckbox"
316+
style={{ marginTop: 25 }}
317+
>
318+
<NetPyNECheckbox model="simConfig.saveDipoleCells" />
319+
</NetPyNEField>
320+
321+
<NetPyNEField
322+
id="simConfig.saveDipolePops"
323+
className="netpyneCheckbox"
324+
style={{ marginTop: 25 }}
325+
>
326+
<NetPyNECheckbox model="simConfig.saveDipolePops" />
327+
</NetPyNEField>
300328
</div>
301329
);
302330
} else if (this.state.sectionId === CONFIG_SECTIONS.NET_PARAMS) {
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import React from 'react';
2+
import Dialog from '@material-ui/core/Dialog/Dialog';
3+
import Button from '@material-ui/core/Button';
4+
import DialogActions from '@material-ui/core/DialogActions';
5+
import DialogContent from '@material-ui/core/DialogContent';
6+
import DialogTitle from '@material-ui/core/DialogTitle';
7+
import { withStyles } from '@material-ui/core/styles';
8+
import { PYTHON_CALL, LOAD_TUTORIAL } from '../../redux/actions/general';
9+
10+
const styles = () => ({
11+
cancel: { marginRight: 10 },
12+
});
13+
14+
class ConfirmationDialog extends React.Component {
15+
constructor (props) {
16+
super(props);
17+
this.state = { hide: !this.props.open };
18+
}
19+
20+
handleConfirmation = () => {
21+
if (this.props.confirmationDialogOnConfirm) {
22+
if (this.props.confirmationDialogOnConfirm.type === PYTHON_CALL) {
23+
this.props.pythonCall(this.props.confirmationDialogOnConfirm.cmd, this.props.confirmationDialogOnConfirm.args);
24+
} else if (this.props.confirmationDialogOnConfirm.type === LOAD_TUTORIAL) {
25+
if (this.props.confirmationDialogOnConfirm.payload !== undefined) {
26+
this.props.dispatchAction(this.props.confirmationDialogOnConfirm.action(this.props.confirmationDialogOnConfirm.payload));
27+
} else {
28+
this.props.dispatchAction(this.props.confirmationDialogOnConfirm.action);
29+
}
30+
}
31+
} else {
32+
console.log('Command/desired behaviour not passed to confirmation dialog');
33+
}
34+
}
35+
36+
render () {
37+
const {
38+
confirmationDialogOpen,
39+
confirmationDialogTitle,
40+
confirmationDialogMessage,
41+
closeConfirmationDialog,
42+
} = this.props;
43+
44+
return (
45+
<Dialog
46+
fullWidth
47+
maxWidth="sm"
48+
open={confirmationDialogOpen}
49+
onClose={() => closeConfirmationDialog()}
50+
>
51+
<DialogTitle>{confirmationDialogTitle}</DialogTitle>
52+
<DialogContent style={{ color: 'white' }}>
53+
{confirmationDialogMessage}
54+
</DialogContent>
55+
<DialogActions>
56+
<Button
57+
onClick={closeConfirmationDialog}
58+
style={styles.cancel}
59+
key="CANCEL"
60+
>
61+
CANCEL
62+
</Button>
63+
<Button
64+
color="primary"
65+
variant="contained"
66+
onClick={() => { this.handleConfirmation(); closeConfirmationDialog(); }}
67+
key="CONFIRM"
68+
>
69+
CONFIRM
70+
</Button>
71+
</DialogActions>
72+
</Dialog>
73+
);
74+
}
75+
}
76+
77+
export default withStyles(styles)(ConfirmationDialog);

webapp/components/general/Dialog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const AboutContent = withStyles(styles)(({ classes }) => (
2929
NetPyNE-UI v0.8.0
3030
</Link>
3131
<Link variant="h5" style={{ display: 'block' }} href="https://github.com/Neurosim-lab/netpyne" target="_blank">
32-
NetPyNE v01.0.0.2
32+
NetPyNE v1.0.1
3333
</Link>
3434
<Link variant="h5" style={{ display: 'block' }} href="https://www.neuron.yale.edu/neuron/" target="_blank">
3535
NEURON v8.0.0

webapp/components/index.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { openBackendErrorDialog, closeBackendErrorDialog } from '../redux/action
1616
import {
1717
updateCards, editModel, simulateNetwork, createNetwork, closeDialog,
1818
createAndSimulateNetwork, showNetwork, pythonCall, modelLoaded, deleteNetParamsObj, resetModel,
19-
setDefaultWidgets, changeInstanceColor,
19+
setDefaultWidgets, changeInstanceColor, openConfirmationDialog, closeConfirmationDialog,
2020
} from '../redux/actions/general';
2121

2222
import {
@@ -58,6 +58,7 @@ import _Topbar from './topbar/Topbar';
5858
import _SwitchPageButton from './topbar/SwitchPageButton';
5959
import _NetPyNEThumbnail from './general/NetPyNEThumbnail';
6060
import _Dialog from './general/Dialog';
61+
import _ConfirmationDialog from './general/ConfirmationDialog';
6162
import _SelectCellTemplate from './definition/cellRules/SelectCellTemplate';
6263
import _Experiments from './experiments/Experiments';
6364
import _ExperimentEdit from './experiments/ExperimentEdit';
@@ -322,6 +323,7 @@ export const Topbar = connect(
322323
dispatchAction: (action) => dispatch(action),
323324
closeDialog: () => dispatch(closeTopbarDialog),
324325
resetModel: () => dispatch(resetModel),
326+
openConfirmationDialog: (payload) => dispatch(openConfirmationDialog(payload)),
325327
}),
326328
)(_Topbar);
327329

@@ -357,6 +359,20 @@ export const Dialog = connect(
357359
(dispatch) => ({ handleClose: () => dispatch(closeDialog) }),
358360
)(_Dialog);
359361

362+
export const ConfirmationDialog = connect(
363+
(state) => ({
364+
confirmationDialogOpen: state.general.confirmationDialogOpen,
365+
confirmationDialogTitle: state.general.confirmationDialogTitle,
366+
confirmationDialogMessage: state.general.confirmationDialogMessage,
367+
confirmationDialogOnConfirm: state.general.confirmationDialogOnConfirm,
368+
}),
369+
(dispatch) => ({
370+
dispatchAction: (action) => dispatch(action),
371+
closeConfirmationDialog: () => dispatch(closeConfirmationDialog),
372+
pythonCall: (cmd, args) => dispatch(pythonCall(cmd, args)),
373+
}),
374+
)(_ConfirmationDialog);
375+
360376
export const SelectCellTemplate = connect(
361377
null,
362378
(dispatch) => ({

webapp/components/topbar/Topbar.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import ImportExportHLSDialog from './dialogs/ImportExportHLS';
2020
import ImportCellParamsDialog from './dialogs/ImportCellParams';
2121
import UploadDownloadFilesDialog from './dialogs/UploadDownloadFiles';
2222

23-
import { TOPBAR_CONSTANTS } from '../../constants';
23+
import { TOPBAR_CONSTANTS, MODEL_STATE, DEFAULT_CONFIRMATION_DIALOG_MESSAGE } from '../../constants';
24+
import { LOAD_TUTORIAL } from '../../redux/actions/general';
2425

2526
const styles = () => ({
2627
topbar: {
@@ -85,6 +86,26 @@ class Topbar extends Component {
8586
}
8687
break;
8788
}
89+
case 'handleTutorial': {
90+
const [action, payload] = click.parameters;
91+
if (this.props.modelState === MODEL_STATE.INSTANTIATED || this.props.modelState === MODEL_STATE.SIMULATED) {
92+
this.props.openConfirmationDialog({
93+
title: 'Warning',
94+
message: DEFAULT_CONFIRMATION_DIALOG_MESSAGE,
95+
onConfirm: {
96+
type: LOAD_TUTORIAL,
97+
action,
98+
payload,
99+
},
100+
});
101+
} else if (payload !== undefined) {
102+
this.props.dispatchAction(action(payload));
103+
} else {
104+
this.props.dispatchAction(action);
105+
}
106+
107+
break;
108+
}
88109

89110
default:
90111
console.log(`Menu action not mapped, it is ${click}`);
@@ -101,9 +122,12 @@ class Topbar extends Component {
101122
classes,
102123
modelLoaded,
103124
dialogOpen,
125+
modelState,
104126
topbarDialogName,
105127
topbarDialogMetadata,
128+
openConfirmationDialog,
106129
} = this.props;
130+
107131
let content;
108132
if (dialogOpen) {
109133
switch (topbarDialogName) {
@@ -129,6 +153,8 @@ class Topbar extends Component {
129153
open={dialogOpen}
130154
onRequestClose={() => this.handleClose()}
131155
mode="IMPORT"
156+
modelState={modelState}
157+
openConfirmationDialog={(payload) => openConfirmationDialog(payload)}
132158
/>
133159
);
134160
break;

webapp/components/topbar/dialogs/ActionDialog.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ class ActionDialog extends React.Component {
3838
performAction = () => {
3939
if (this.props.command) {
4040
if (this.props.isFormValid === undefined || this.props.isFormValid()) {
41-
GEPPETTO.trigger(GEPPETTO.Events.Show_spinner, this.props.message);
42-
this.props.pythonCall(this.props.command, this.props.args);
41+
if (typeof this.props.callback !== 'undefined' || this.props.callback !== null) {
42+
this.props.callback(this.props.command, this.props.args);
43+
} else {
44+
// GEPPETTO.trigger(GEPPETTO.Events.Show_spinner, this.props.message);
45+
this.props.pythonCall(this.props.command, this.props.args);
46+
}
4347
}
4448
}
4549
this.setState({ hide: true });

0 commit comments

Comments
 (0)