Skip to content

Commit 17cb15e

Browse files
committed
Merge branch 'precns' of github.com:MetaCell/NetPyNE-UI into precns
2 parents 8ebd61c + 4b790ca commit 17cb15e

8 files changed

Lines changed: 76 additions & 15 deletions

File tree

webapp/components/definition/cellRules/NetPyNECellRules.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -544,16 +544,34 @@ export default class NetPyNECellRules extends React.Component {
544544

545545
getCopyPath () {
546546
const basePath = "netParams.cellParams"
547+
const { value:model } = this.state
548+
const { selectedCellRule, selectedSection, selectedMechanism } = this.state
549+
if (!model) {
550+
return 'undefined'
551+
}
547552
switch (this.state.page) {
548-
case "main":
549-
return `${basePath}["${this.state.selectedCellRule}"]`
550-
case "sections":
551-
return `${basePath}["${this.state.selectedCellRule}"].secs["${this.state.selectedSection}"]`
552-
case "mechanisms":
553-
return `${basePath}["${this.state.selectedCellRule}"].secs["${this.state.selectedSection}"].mechs["${this.state.selectedMechanism}"]`
554-
default:
555-
return "undefined"
553+
case "main": {
554+
if (model[selectedCellRule]) {
555+
return `${basePath}["${selectedCellRule}"]`
556+
}
557+
break
558+
}
559+
case "sections": {
560+
if (model[selectedCellRule].secs[selectedSection]) {
561+
return `${basePath}["${selectedCellRule}"].secs["${selectedSection}"]`
562+
}
563+
break
564+
}
565+
case "mechanisms":{
566+
if (model[selectedCellRule].secs[selectedSection].mechs[selectedMechanism]) {
567+
return `${basePath}["${selectedCellRule}"].secs["${selectedSection}"].mechs["${selectedMechanism}"]`
568+
}
569+
break
570+
}
571+
default: {
572+
}
556573
}
574+
return "undefined"
557575
}
558576

559577
callbackForNewCellTypeCreated (newCellTypeName) {

webapp/components/definition/connectivity/NetPyNEConnectivityRules.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ export default class NetPyNEConnectivityRules extends Component {
154154
return true;
155155
}
156156

157+
getCopyPath (){
158+
const { value: model, selectedConnectivityRule } = this.state
159+
return model && model[selectedConnectivityRule] && `netParams.connParams["${selectedConnectivityRule}"]`
160+
}
161+
157162
render () {
158163
var actions = [
159164
<Button
@@ -226,7 +231,7 @@ export default class NetPyNEConnectivityRules extends Component {
226231

227232
</div>
228233
<Divider />
229-
<RulePath text={`netParams.connParams["${this.state.selectedConnectivityRule}"]`}/>
234+
<RulePath text={this.getCopyPath()}/>
230235
<Divider />
231236
<Filter
232237
value={this.state.filterValue}

webapp/components/definition/populations/NetPyNEPopulations.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ export default class NetPyNEPopulations extends React.Component {
154154
return true;
155155
}
156156

157+
getPath () {
158+
const { value: model, selectedPopulation } = this.state
159+
return model && model[selectedPopulation] && `netParams.popParams["${selectedPopulation}"]`
160+
}
161+
157162
render () {
158163
var actions = [
159164
<Button
@@ -229,7 +234,7 @@ export default class NetPyNEPopulations extends React.Component {
229234

230235
</div>
231236
<Divider />
232-
<RulePath text={`netParams.popParams["${this.state.selectedPopulation}"]`}/>
237+
<RulePath text={this.getPath()}/>
233238
<Divider />
234239
<Filter
235240
value={this.state.filterPopValue}

webapp/components/definition/stimulationSources/NetPyNEStimulationSources.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ export default class NetPyNEStimulationSources extends Component {
134134
return true;
135135
}
136136

137+
getPath () {
138+
const { value: model, selectedStimulationSource } = this.state
139+
return model && model[selectedStimulationSource] && `netParams.stimSourceParams["${selectedStimulationSource}"]`
140+
}
141+
137142
render () {
138143
var actions = [
139144
<Button
@@ -202,7 +207,7 @@ export default class NetPyNEStimulationSources extends Component {
202207
</div>
203208
</div>
204209
<Divider />
205-
<RulePath text={`netParams.stimSourceParams["${this.state.selectedStimulationSource}"]`}/>
210+
<RulePath text={this.getPath()}/>
206211
<Divider />
207212
<Filter
208213
value={this.state.filterValue}

webapp/components/definition/stimulationTargets/NetPyNEStimulationTarget.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ export default class NetPyNEStimulationTarget extends React.Component {
6262

6363
async isStimSourceTypeNetStim (stimSourceName) {
6464
var isNetStim = false
65+
const { name: stimName } = this.props
6566
if (stimSourceName === undefined) {
6667
try {
67-
stimSourceName = await Utils.evalPythonMessage("netpyne_geppetto.netParams.stimTargetParams['" + this.props.name + "']['source']")
68+
const NETPYNE_OBJ = "netpyne_geppetto.netParams.stimTargetParams"
69+
const STIM_TARGET_OBJ = `${NETPYNE_OBJ}['${stimName}']`
70+
const SAFE_QUERY = `${STIM_TARGET_OBJ}['source'] if "${stimName}" in ${NETPYNE_OBJ} and "source" in ${STIM_TARGET_OBJ} else ''`
71+
stimSourceName = await Utils.evalPythonMessage(SAFE_QUERY)
6872
} catch (error){
6973
console.log(error)
7074
}

webapp/components/definition/stimulationTargets/NetPyNEStimulationTargets.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default class NetPyNEStimulationTargets extends Component {
4444
var defaultStimulationTargets = { 'stim_target': { 'source': '', 'conds': {} } };
4545
var key = Object.keys(defaultStimulationTargets)[0];
4646
var value = defaultStimulationTargets[key];
47-
var model = this.state.value;
47+
var model = { ...this.state.value };
4848
var StimulationTargetId = Utils.getAvailableKey(model, key);
4949
var newStimulationTarget = Object.assign({ name: StimulationTargetId }, value);
5050
Utils.execPythonMessage('netpyne_geppetto.netParams.stimTargetParams["' + StimulationTargetId + '"] = ' + JSON.stringify(value));
@@ -133,6 +133,11 @@ export default class NetPyNEStimulationTargets extends Component {
133133
return true;
134134
}
135135

136+
getPath () {
137+
const { value: model, selectedStimulationTarget } = this.state
138+
return model && model[selectedStimulationTarget] && `netParams.stimTargetParams["${selectedStimulationTarget}"]`
139+
}
140+
136141
render () {
137142
var actions = [
138143
<Button
@@ -198,7 +203,7 @@ export default class NetPyNEStimulationTargets extends Component {
198203

199204
</div>
200205
<Divider />
201-
<RulePath text={`netParams.stimTargetParams["${this.state.selectedStimulationTarget}"]`}/>
206+
<RulePath text={this.getPath()}/>
202207
<Divider />
203208
<Filter
204209
value={this.state.filterValue}

webapp/components/definition/synapses/NetPyNESynapses.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ export default class NetPyNESynapses extends Component {
133133
return true;
134134
}
135135

136+
137+
getPath () {
138+
const { value: model, selectedSynapse } = this.state
139+
return model && model[selectedSynapse] && `netParams.synMechParams["${selectedSynapse}"]`
140+
}
141+
136142
render () {
137143
var actions = [
138144
<Button
@@ -198,7 +204,7 @@ export default class NetPyNESynapses extends Component {
198204

199205
</div>
200206
<Divider />
201-
<RulePath text={`netParams.synMechParams["${this.state.selectedSynapse}"]`}/>
207+
<RulePath text={this.getPath()}/>
202208
<Divider />
203209
<Filter
204210
value={this.state.filterValue}

webapp/redux/middleware/middleware.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ const createSimulateBackendCall = async (cmd, payload, consoleMessage, spinnerTy
154154
throw new Error(responsePayload.errorMessage);
155155
} else {
156156
GEPPETTO.trigger(GEPPETTO.Events.Show_spinner, GEPPETTO.Resources.PARSING_MODEL);
157+
158+
dehydrateCanvas()
159+
157160
GEPPETTO.Manager.loadModel(response);
158161
GEPPETTO.CommandController.log('Instantiation / Simulation completed.');
159162

@@ -178,3 +181,13 @@ const pythonCall = async ({ cmd, args }) => {
178181
}
179182
return response;
180183
}
184+
185+
186+
const dehydrateCanvas = () => {
187+
if ('CanvasContainer' in window) {
188+
CanvasContainer.engine.reset()
189+
Object.values(CanvasContainer.engine.meshes).forEach(mesh => {
190+
CanvasContainer.engine.removeObject(mesh)
191+
})
192+
}
193+
}

0 commit comments

Comments
 (0)