MCPcopy Create free account
hub / github.com/DFin/Neural-Network-Visualisation / setSelectedNeuron

Method setSelectedNeuron

assets/main.js:2005–2026  ·  view source on GitHub ↗
(layerIndex, neuronIndex)

Source from the content-addressed store, hash-verified

2003 }
2004
2005 setSelectedNeuron(layerIndex, neuronIndex) {
2006 if (!Number.isInteger(layerIndex) || !Number.isInteger(neuronIndex)) return;
2007 const layer = this.layerMeshes[layerIndex];
2008 if (!layer) return;
2009 const boundedIndex = Math.max(0, Math.min(layer.positions.length - 1, neuronIndex));
2010 if (
2011 this.selectedNeuron &&
2012 this.selectedNeuron.layerIndex === layerIndex &&
2013 this.selectedNeuron.neuronIndex === boundedIndex
2014 ) {
2015 this.clearSelection();
2016 return;
2017 }
2018 this.selectedNeuron = { layerIndex, neuronIndex: boundedIndex };
2019 this.updateConnectionVisibility();
2020 this.buildSelectionConnectionMeshes();
2021 if (this.lastDisplayActivations && this.lastNetworkActivations) {
2022 this.update(this.lastDisplayActivations, this.lastNetworkActivations, this.lastPreActivations);
2023 } else if (typeof this.requestRender === "function") {
2024 this.requestRender();
2025 }
2026 }
2027
2028 clearSelection() {
2029 if (!this.selectedNeuron) return;

Callers 1

trySelectNeuronMethod · 0.95

Calls 4

clearSelectionMethod · 0.95
updateMethod · 0.95

Tested by

no test coverage detected