Skip to content
Snippets Groups Projects
Commit 2b2a6666 authored by Kepa Cantero's avatar Kepa Cantero Committed by Axel von Arnim
Browse files

Merged in NRRPLT-6872 (pull request #3)


[NRRPLT-6872] BrainVisu and CLE should support multiple populations

Approved-by: default avatarSusie Murphy <susie.murphy@epfl.ch>
Approved-by: default avatarClaudio Sousa <claudio.sousa@gmail.com>
parent c7d458d8
No related branches found
No related tags found
No related merge requests found
...@@ -75,7 +75,7 @@ BRAIN3D.MainView.prototype.init = function () ...@@ -75,7 +75,7 @@ BRAIN3D.MainView.prototype.init = function ()
this.paused = false; this.paused = false;
this.totalParticles = 0; this.totalParticles = 0;
this.particles = []; this.particles = [];
this.indexToParticles = {}; this.populationIndexToParticles = {};
this.waitingSpikes = []; this.waitingSpikes = [];
this.spikeScaleFactor = 0.0; this.spikeScaleFactor = 0.0;
this.spikeFactorChanged = false; this.spikeFactorChanged = false;
...@@ -339,15 +339,16 @@ BRAIN3D.MainView.prototype.newParticle = function (index, pop, posx, posy, posz, ...@@ -339,15 +339,16 @@ BRAIN3D.MainView.prototype.newParticle = function (index, pop, posx, posy, posz,
psuper.nextlevel = newp; psuper.nextlevel = newp;
} }
if (index in this.indexToParticles) if (this.populationIndexToParticles[pop.name] == undefined) {
{ this.populationIndexToParticles[pop.name] = {};
this.indexToParticles[index].push(newp); this.populationIndexToParticles[pop.name][index] = [newp];
} else {
if (this.populationIndexToParticles[pop.name][index] == undefined) {
this.populationIndexToParticles[pop.name][index] = [newp];
} else {
this.populationIndexToParticles[pop.name][index].push(newp);
} }
else
{
this.indexToParticles[index] = [newp];
} }
return newp; return newp;
}; };
...@@ -384,7 +385,6 @@ BRAIN3D.MainView.prototype.init3DBrain = function () // Init brain 3D object ...@@ -384,7 +385,6 @@ BRAIN3D.MainView.prototype.init3DBrain = function () // Init brain 3D object
// Particles // Particles
this.particles = []; this.particles = [];
this.indexToParticles = {};
this.totalParticles = 0; this.totalParticles = 0;
if (this.object) if (this.object)
...@@ -395,9 +395,9 @@ BRAIN3D.MainView.prototype.init3DBrain = function () // Init brain 3D object ...@@ -395,9 +395,9 @@ BRAIN3D.MainView.prototype.init3DBrain = function () // Init brain 3D object
} }
var visibleNeurons = {}; var visibleNeurons = {};
var visibleNeuronsLastLevel = {}; var popVisibleNeuronsLastLevel = {};
this.addParticleForNeuron = function (i) this.addParticleForNeuron = function (populationName, i)
{ {
var nsize = 1.0; var nsize = 1.0;
...@@ -415,9 +415,23 @@ BRAIN3D.MainView.prototype.init3DBrain = function () // Init brain 3D object ...@@ -415,9 +415,23 @@ BRAIN3D.MainView.prototype.init3DBrain = function () // Init brain 3D object
nsize = 1.0 - ((visibleNeurons[i] - 1.0) * BRAIN3D.OVERLAPPING_NEURONS_RESIZE_FACTOR); nsize = 1.0 - ((visibleNeurons[i] - 1.0) * BRAIN3D.OVERLAPPING_NEURONS_RESIZE_FACTOR);
} }
var previousLevel = (visibleNeuronsLastLevel.hasOwnProperty(i)) ? visibleNeuronsLastLevel[i] : null; var previousLevel = null
if ((popVisibleNeuronsLastLevel[populationName] != undefined) && (popVisibleNeuronsLastLevel[populationName][i] != undefined)) {
previousLevel = popVisibleNeuronsLastLevel[populationName][i];
}
visibleNeuronsLastLevel[i] = this.newParticle(i, popValues, 0, 0, 0, nsize, previousLevel); if (popVisibleNeuronsLastLevel[populationName] == undefined) {
popVisibleNeuronsLastLevel[populationName] = {};
}
popVisibleNeuronsLastLevel[populationName][i] = this.newParticle(
i,
popValues,
0,
0,
0,
nsize,
previousLevel
);
this.totalParticles++; this.totalParticles++;
}; };
...@@ -433,7 +447,7 @@ BRAIN3D.MainView.prototype.init3DBrain = function () // Init brain 3D object ...@@ -433,7 +447,7 @@ BRAIN3D.MainView.prototype.init3DBrain = function () // Init brain 3D object
for (var j in nlist) for (var j in nlist)
{ {
this.addParticleForNeuron(nlist[j]); this.addParticleForNeuron(popname, nlist[j]);
} }
} }
else else
...@@ -447,7 +461,7 @@ BRAIN3D.MainView.prototype.init3DBrain = function () // Init brain 3D object ...@@ -447,7 +461,7 @@ BRAIN3D.MainView.prototype.init3DBrain = function () // Init brain 3D object
for (var i = start; i < end; i += step) for (var i = start; i < end; i += step)
{ {
this.addParticleForNeuron(i); this.addParticleForNeuron(popname, i);
} }
} }
} }
...@@ -713,9 +727,9 @@ BRAIN3D.MainView.prototype.periodicalUpdate = function () ...@@ -713,9 +727,9 @@ BRAIN3D.MainView.prototype.periodicalUpdate = function ()
//------------------------------ //------------------------------
// Spikes // Spikes
BRAIN3D.MainView.prototype.applySpikeEffect = function (neuron) BRAIN3D.MainView.prototype.applySpikeEffect = function (populationName, neuron)
{ {
var particles = this.indexToParticles[neuron]; var particles = this.populationIndexToParticles[populationName][neuron];
for (var i = 0; i < particles.length; i++) for (var i = 0; i < particles.length; i++)
{ {
var p = particles[i]; var p = particles[i];
...@@ -744,17 +758,21 @@ BRAIN3D.MainView.prototype.processWaitingSpikes = function (elapsed) ...@@ -744,17 +758,21 @@ BRAIN3D.MainView.prototype.processWaitingSpikes = function (elapsed)
spike.time -= elapsed; spike.time -= elapsed;
if (spike.time <= 0) if (spike.time <= 0)
{ {
this.applySpikeEffect(spike.neuron); this.applySpikeEffect(spike.population, spike.neuron);
this.waitingSpikes.splice(i, 1); this.waitingSpikes.splice(i, 1);
i--; i--;
} }
} }
}; };
BRAIN3D.MainView.prototype.displaySpikes = function (spikes) BRAIN3D.MainView.prototype.displaySpikes = function (populationName, spikes)
{ {
// Spike format: [{"neuron":INDEX,"time":TIME},{"neuron":INDEX,"time":TIME}, ...] // Spike format: [{"neuron":INDEX,"time":TIME},{"neuron":INDEX,"time":TIME}, ...]
if (this.populations[populationName] == undefined) {
return;
}
var baseTime; var baseTime;
for (var i = 0; i < spikes.length; i++) for (var i = 0; i < spikes.length; i++)
...@@ -764,7 +782,7 @@ BRAIN3D.MainView.prototype.displaySpikes = function (spikes) ...@@ -764,7 +782,7 @@ BRAIN3D.MainView.prototype.displaySpikes = function (spikes)
if (i === 0) if (i === 0)
{ {
baseTime = spike.time; baseTime = spike.time;
this.applySpikeEffect(spike.neuron); this.applySpikeEffect(populationName, spike.neuron);
} }
else else
{ {
...@@ -772,11 +790,15 @@ BRAIN3D.MainView.prototype.displaySpikes = function (spikes) ...@@ -772,11 +790,15 @@ BRAIN3D.MainView.prototype.displaySpikes = function (spikes)
if (timeDiff < 1.0 / 30.0) if (timeDiff < 1.0 / 30.0)
{ {
this.applySpikeEffect(spike.neuron); this.applySpikeEffect(populationName, spike.neuron);
} }
else else
{ {
this.waitingSpikes.push({ "neuron": spike.neuron, "time": spike.time - baseTime }); this.waitingSpikes.push({
neuron: spike.neuron,
time: spike.time - baseTime,
population: populationName
});
} }
} }
} }
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment