version 1.41 | version 1.42 |
---|
| |
## | ## |
## VND -- Visual Neuronal Dynamics graphical interface | ## VND -- Visual Neuronal Dynamics graphical interface |
## | ## |
## $Id: vnd_gui.tcl,v 1.41 2025/06/29 21:05:50 jasonks2 Exp $ | ## $Id: vnd_gui.tcl,v 1.42 2025/06/30 23:56:37 barryi Exp $ |
## | ## |
## | ## |
## Home Page | ## Home Page |
| |
variable colorID "" | variable colorID "" |
variable numberRep | variable numberRep |
variable showRep true | variable showRep true |
variable sphereScale 3 | variable sphereScale 1.0 |
variable sphereRes 5 | variable sphereRes 10 |
variable proxyantialias "" | variable proxyantialias "" |
variable proxydepthcueing "" | variable proxydepthcueing "" |
variable proxyfps "" | variable proxyfps "" |
| |
variable listmodels | variable listmodels |
variable selRep | variable selRep |
variable materialRep | variable materialRep |
| variable scaling |
variable showRep | variable showRep |
variable sphereScale | variable sphereScale |
variable sphereRes | variable sphereRes |
| |
set showRep [lindex $args [expr $auxpos + 1]] | set showRep [lindex $args [expr $auxpos + 1]] |
} | } |
| |
| set auxpos [lsearch $args resolution] |
| if {$auxpos != -1} { |
| set sphereRes [lindex $args [expr $auxpos + 1]] |
| } |
| |
| set auxpos [lsearch $args scaling] |
| if {$auxpos != -1} { |
| set sphereScale [lindex $args [expr $auxpos + 1]] |
| } |
| |
set auxpos [lsearch $args color] | set auxpos [lsearch $args color] |
if {$auxpos != -1} { | if {$auxpos != -1} { |
set content [lindex $args [expr $auxpos + 1]] | set content [lindex $args [expr $auxpos + 1]] |
| |
set styleRep soma | set styleRep soma |
set colorID Type | set colorID Type |
set selRep "all" | set selRep "all" |
set sphereScale 3 | set sphereScale 1.0 |
set sphereRes 5 | set sphereRes 10 |
set showRep true | set showRep true |
set materialRep Opaque | set materialRep Opaque |
set repselected 0 | set repselected 0 |
| |
| |
# limit crowding in the default preview | # limit crowding in the default preview |
if {[::neuro::cmd_query "num_neurons"] > 10000} {set selRep "stride 5"} | if {[::neuro::cmd_query "num_neurons"] > 10000} {set selRep "stride 5"} |
if {[::neuro::cmd_query "num_neurons"] > 100000} {set selRep "stride 50"} | if {[::neuro::cmd_query "num_neurons"] > 100000} {set selRep "stride 50"; set sphereRes 6} |
if {[::neuro::cmd_query "num_neurons"] > 1000000} {set selRep "stride 500"} | if {[::neuro::cmd_query "num_neurons"] > 1000000} {set selRep "stride 500"; set sphereRes 6} |
| |
set repselected [.neuron.fp.systems.rep.main.table.tb index end] | set repselected [.neuron.fp.systems.rep.main.table.tb index end] |
} else { | } else { |
| |
#set repselected [.neuron.fp.systems.rep.main.table.tb index end] | #set repselected [.neuron.fp.systems.rep.main.table.tb index end] |
#puts "repselected $repselected, styleRep $styleRep, colorID $colorID, numberRep $numberRep selRep $selRep" | #puts "repselected $repselected, styleRep $styleRep, colorID $colorID, numberRep $numberRep selRep $selRep" |
#temporarily force scaling and resolution | #temporarily force scaling and resolution |
set scaling 1.0 | set scaling $sphereScale |
set resolution 6 | set resolution $sphereRes |
set repid [::neuro::cmd_create_rep_node_fullsel $styleRep $colorID $materialRep $scaling $resolution $selRep] | set repid [::neuro::cmd_create_rep_node_fullsel $styleRep $colorID $materialRep $scaling $resolution $selRep] |
#now that search is done, can set numberRep from rep property | #now that search is done, can set numberRep from rep property |
set numberRep [lindex [lsearch -inline -index 0 -integer [::neuro::cmd_query rep_property_list] $repid] 7] | set numberRep [lindex [lsearch -inline -index 0 -integer [::neuro::cmd_query rep_property_list] $repid] 7] |
| |
.neuron.fp.systems.rep.main.table.tb rowconfigure $rowid -selectforeground red | .neuron.fp.systems.rep.main.table.tb rowconfigure $rowid -selectforeground red |
} | } |
| |
| return $repid |
} | } |
| |
proc ::NeuronVND::delRep {args} { | proc ::NeuronVND::delRep {args} { |
| |
| |
} | } |
| |
| proc ::NeuronVND::delRepByRepid {repid} { |
| variable repselected |
| set r [lsearch -index 0 -integer $::neuro::nrepList $repid] |
| if {$r != -1} { |
| set repselected $r |
| delRep |
| return "Deleted rep $repid" |
| } else { |
| return "VND Error: rep $repid not found" |
| } |
| } |
proc ::NeuronVND::showHideRep {} { | proc ::NeuronVND::showHideRep {} { |
variable repselected | variable repselected |
| |
| |
return $::NeuronVND::alignment_populationID | return $::NeuronVND::alignment_populationID |
} | } |
| |
| #utility function to emit spike event data for Python interface |
| proc ::NeuronVND:spike_emit {the_sel popname} { |
| # set ::NeuronVND::spikePop1 $popname |
| # set ::NeuronVND::spikeSel1 $the_sel |
| #adapted code fron GUI, ignoring GUI-involved namespace vars so do not interfere |
| set spikePop1 $popname |
| set spikeSel1 $the_sel |
| #set spikePop1 "internal" |
| #set nodeIDList [::neuro::parse_full_selection_string "$::NeuronVND::spikeSel1 && population == $::NeuronVND::spikePop1" node] |
| set nodeIDList [::neuro::parse_full_selection_string "$spikeSel1 && population == $spikePop1" node] |
| |
| # in this first version, we color by type only |
| # query how many types there are in that population |
| set typeList [lsort -unique [::neuro::cmd_query node_list_attrib_values type $nodeIDList]] |
| set timeSeriesData {} |
| set colorList {blue red gray orange yellow tan silver green gray pink cyan purple lime mauve ochre iceblue black} |
| # for each type, find the nodeids and then search the spikeHash for activity data |
| set auxY {}; set auxX {}; set auxColor {}; |
| set auxY_text "y = \[" |
| set auxX_text "x = \[" |
| set auxColor_text "c = \[" |
| set auxGid_text "g = \[" |
| set n 0 |
| set output_limit 4000 |
| foreach t $typeList { |
| set colorForData [lindex $colorList [expr $t % 32]] ;# first one outside the loop |
| set auxNodeID [::neuro::parse_full_selection_string "$spikeSel1 && type == $t && population == $spikePop1" node] |
| #make a dict to connect population node_id to global node_id |
| set nid_gid_dict [dict create] |
| foreach theGlobalID $auxNodeID { |
| puts "theGlobalID = $theGlobalID" |
| foreach {ex ey ez exrot eyrot ezrot etype efileset_num epop enode_id egroup_id egroup_index ecartesian} $::neuro::node($theGlobalID) {} |
| #use per population id to match what is in the spike list |
| dict append nid_gid_dict $enode_id $theGlobalID |
| } |
| # create a timeseries for each type in typeList |
| puts "nid_gid_dict = $nid_gid_dict" |
| foreach p $::neuro::spikeHash(spikeList,$::NeuronVND::spikePop1) { |
| if [dict exists $nid_gid_dict [lindex $p 0]] { |
| if {$n > -1 } { |
| if {$n == 0} {set sp ""} else {set sp ","} |
| set auxX_text "$auxX_text${sp} [lindex $p 1]" |
| set auxY_text "$auxY_text${sp} [lindex $p 0]" |
| set auxColor_text "$auxColor_text${sp} \"$colorForData\"" |
| set auxGid_text "$auxGid_text${sp} [dict get $nid_gid_dict [lindex $p 0]]" |
| #lappend auxX [expr round([lindex $p 1])] |
| #lappend auxY [lindex $p 0] |
| #lappend auxColor $colorForData |
| incr n |
| } |
| } |
| } |
| #lappend timeSeriesData [list $auxY $auxX $colorForData] |
| #lappend timeSeriesData [list [lrange $auxY 0 3] [lrange $auxX 0 3] $colorForData] |
| |
| } |
| |
| set auxY_text "$auxY_text \], " |
| set auxX_text "$auxX_text \], " |
| set auxColor_text "$auxColor_text \]," |
| set auxGid_text "$auxGid_text \]" |
| |
| #set OUTFILE [open $the_filename w] |
| |
| #puts $OUTFILE "vndSpikeDataTransfer = dict(" |
| #puts $OUTFILE $auxX_text |
| #puts $OUTFILE $auxY_text |
| #puts $OUTFILE $auxColor_text |
| #puts $OUTFILE $auxGid_text |
| #puts $OUTFILE ")" |
| #close $OUTFILE |
| set ret_string "dict($auxX_text $auxY_text $auxColor_text $auxGid_text)" |
| return $ret_string |
| |
| |
| # define multiplot with first set of data, using colors from VMD |
| puts $colorForData |
| set spikePlothandle [multiplot -x [lindex $timeSeriesData 0 1] -y [lindex $timeSeriesData 0 0] -nolines -xmin 0 -xmax $::NeuronVND::spikeEnd -xlabel "Time (ms)" -marker square -radius 2 -fillcolor white -linecolor $colorForData -title "Neuronal Spike Activity" -callback ::NeuronVND::goto -legend "Type [lindex $typeList 0]"] |
| # add the rest of the data to the plot |
| for {set i 1} {$i < [llength $typeList]} {incr i} { |
| set colorForData [lindex $colorList [expr [lindex $typeList $i] % 32]] ;# rest inside the loop |
| puts $colorForData |
| $spikePlothandle add [lindex $timeSeriesData $i 1] [lindex $timeSeriesData $i 0] -callback ::NeuronVND::goto -fillcolor white -linecolor $colorForData -nolines -marker square -radius 2 -legend "Type [lindex $typeList $i]" |
| } |
| # finally plot all |
| $spikePlothandle configure -ylabel "NodeID" -ymax 300 -ymin 0 -xmin 0 -ysize 500 -xsize 700 |
| $spikePlothandle replot |
| #set black color to gray, since black is most common background |
| #if {$c ==16} {set c 2} |
| |
| } |
| |
| |
proc ::NeuronVND::select_pop_dialog {args} { | proc ::NeuronVND::select_pop_dialog {args} { |
# dialog box to choose population of loaded model | # dialog box to choose population of loaded model |