This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.plotIV = function(protocolName, e){ | |
e.preventDefault(); | |
// figure out if we have any protocol and organize into a map | |
var experiments = Project.getExperiments(); | |
var protocolExperimentsMap = {}; | |
for(var i=0; i<experiments.length; i++){ | |
if(experiments[i].getName().startsWith('[P]')){ | |
// parse protocol pattern | |
var experimentName = experiments[i].getName(); | |
var protocolName = experimentName.substring(experimentName.lastIndexOf("[P] ")+4,experimentName.lastIndexOf(" - ")); | |
if(protocolExperimentsMap[protocolName] == undefined){ | |
protocolExperimentsMap[protocolName] = [experiments[i]]; | |
} else { | |
protocolExperimentsMap[protocolName].push(experiments[i]); | |
} | |
} | |
} | |
// look for experiments with that name | |
experiments = protocolExperimentsMap[protocolName]; | |
var membranePotentials = GEPPETTO.ModelFactory.getAllPotentialInstancesEndingWith('.v'); | |
var plotController = GEPPETTO.WidgetFactory.getController(GEPPETTO.Widgets.PLOT); | |
var plotWidget = null; | |
if(experiments.length > 0 && membranePotentials.length>0){ | |
plotWidget = G.addWidget(0).setName(protocolName + ' / IV Curve').setSize(300, 500); | |
} | |
var if_results = {}; | |
var iv_results = {}; | |
for(var i=0; i<experiments.length; i++){ | |
// loop and plot all membrane potentials | |
if(experiments[i].getStatus() == 'COMPLETED'){ | |
for(var j=0; j<membranePotentials.length; j++){ | |
plotController.plotStateVariable( | |
Project.getId(), | |
experiments[i].getId(), | |
membranePotentials[j], | |
plotWidget | |
); | |
} | |
} | |
} | |
for i in range(number_cells): | |
t = np.array(results['t'])*1000 | |
v = np.array(results["%s[%i]/v"%(pop.id, i)])*1000 | |
if plot_voltage_traces: | |
times_results.append(t) | |
volts_results.append(v) | |
volts_labels.append("%s nA"%stims[i]) | |
var min = Math.min.apply(null, arr), | |
max = Math.max.apply(null, arr); | |
mm = max_min(v, t, delta=0, peak_threshold=spike_threshold_mV) | |
spike_times = mm['maxima_times'] | |
var freq = 0; | |
var count = 0; | |
if (spike_times.length > 2){ | |
count = 0 | |
} | |
for (var i =0;i<spike_times.length;i++){ | |
if(spike_times[i]>=(pre_zero_pulse + analysis_delay) && (spike_times[i]< (pre_zero_pulse + analysis_duration+analysis_delay)){ | |
count+=1; | |
freq = 1000 * count/float(analysis_duration); | |
} | |
} | |
var mean_freq = mean_spike_frequency(spike_times); | |
#print("--- %s nA, spike times: %s, mean_spike_frequency: %f, freq (%fms -> %fms): %f"%(stims[i],spike_times, mean_freq, analysis_delay, analysis_duration+analysis_delay, freq)) | |
if_results[stims[i]] = freq | |
if freq == 0: | |
if post_zero_pulse==0: | |
iv_results[stims[i]] = v[-1] | |
else: | |
v_end = None | |
for j in range(len(t)): | |
if v_end==None and t[j]>=end_stim: | |
v_end = v[j] | |
iv_results[stims[i]] = v_end | |
}; | |
window.plotFI = function(protocolName, e){ | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment