version 1.40 | version 1.41 |
---|
| |
## | ## |
## VND -- Visual Neuronal Dynamics graphical interface | ## VND -- Visual Neuronal Dynamics graphical interface |
## | ## |
## $Id: vnd_gui.tcl,v 1.40 2025/04/24 02:57:59 jasonks2 Exp $ | ## $Id: vnd_gui.tcl,v 1.41 2025/06/29 21:05:50 jasonks2 Exp $ |
## | ## |
## | ## |
## Home Page | ## Home Page |
| |
variable x_array_apical | variable x_array_apical |
variable y_array_apical | variable y_array_apical |
variable z_array_apical | variable z_array_apical |
| variable scale |
| |
| variable bio_mode "" |
| |
variable x_array_no_axon | variable x_array_no_axon |
variable y_array_no_axon | variable y_array_no_axon |
| |
variable nodes "" | variable nodes "" |
variable main_pa_list "" | variable main_pa_list "" |
variable exclude_axons 1 | variable exclude_axons 1 |
variable com_list_apical | variable com_list_apical "" |
| variable com_list_no_axon "" |
variable flip_priority_axis 0 | variable flip_priority_axis 0 |
variable vcom_to_pa | variable vcom_to_pa |
variable vcom_to_bio | variable vcom_to_bio |
variable vdot | variable vdot |
variable vdot_list "" | variable vdot_list "" |
| variable main_pa_list_no_axon |
| |
| variable flip_list |
} | } |
initialize | initialize |
} | } |
| |
$fro2.tb insert end [list "101" "20.000" "12" "mayority"] | $fro2.tb insert end [list "101" "20.000" "12" "mayority"] |
$fro2.tb insert end [list "102" "7.000" "5" ""] | $fro2.tb insert end [list "102" "7.000" "5" ""] |
$fro2.tb insert end [list "103" "3.000" "1" ""] | $fro2.tb insert end [list "103" "3.000" "1" ""] |
| |
} | } |
| |
proc ::NeuronVND::loadObject {f} { | proc ::NeuronVND::loadObject {f} { |
| |
grid [button $w.main.label3.but4 -text "Align to x, y, z" -command {::NeuronVND::jump_mult_node}] -row $gr -column 0 -sticky news -padx 4 -pady 1 | grid [button $w.main.label3.but4 -text "Align to x, y, z" -command {::NeuronVND::jump_mult_node}] -row $gr -column 0 -sticky news -padx 4 -pady 1 |
grid [button $w.main.label3.but5 -text "Reset position" -command {::NeuronVND::resetpos}] -row $gr -column 1 -sticky news -padx 4 -pady 1 | grid [button $w.main.label3.but5 -text "Reset position" -command {::NeuronVND::resetpos}] -row $gr -column 1 -sticky news -padx 4 -pady 1 |
incr gr | incr gr |
grid [labelframe $w.main.label2 -text "Navigation Controls" -labelanchor nw ] -row $gr -column 0 -sticky news -padx 2 -pady 1 | |
incr gr | |
grid [label $w.main.label2.sel -text "Select Object:"] -row $gr -column 0 -sticky news | |
grid [ttk::combobox $w.main.label2.cb -width 30 -values "" -textvariable ::NeuronVND::objIndex -state readonly] -row $gr -column 1 -columnspan 4 | |
bind $w.main.label2.cb <<ComboboxSelected>> { | |
set ::NeuronVND::objIndex [%W get] | |
mol top [lindex $::NeuronVND::objIndex 0] | |
%W selection clear | |
} | |
incr gr | |
grid [label $w.main.label2.movex -text "Translate in X:"] -row $gr -column 0 -sticky news | |
grid [button $w.main.label2.movex1 -text "-" -command {::NeuronVND::movePcaGraphs x neg}] -row $gr -column 1 -sticky news | |
#grid [button $w.fp.navigation.main.movex2 -text "-" -command {::NeuronVND::movePcaGraphs x -100}] -row 3 -column 2 -sticky news | |
grid [spinbox $w.main.label2.movex2 -width 3 -increment 10 -from 10 -to 1000 -textvariable ::NeuronVND::movex -background white] -row $gr -column 2 -sticky news | |
grid [button $w.main.label2.movex3 -text "+" -command {::NeuronVND::movePcaGraphs x pos}] -row $gr -column 3 -sticky news | |
#grid [button $w.fp.navigation.main.movex4 -text "+++" -command {::NeuronVND::movePcaGraphs x 500}] -row 3 -column 4 -sticky news | |
incr gr | |
grid [label $w.main.label2.movey -text "Translate in Y:"] -row $gr -column 0 -sticky news | |
grid [button $w.main.label2.movey1 -text "-" -command {::NeuronVND::movePcaGraphs y neg}] -row $gr -column 1 -sticky news | |
#grid [button $w.fp.navigation.main.movey2 -text "-" -command {::NeuronVND::movePcaGraphs y -100}] -row 4 -column 2 -sticky news | |
grid [spinbox $w.main.label2.movey2 -width 3 -increment 10 -from 10 -to 1000 -textvariable ::NeuronVND::movey -background white] -row $gr -column 2 -sticky news | |
grid [button $w.main.label2.movey3 -text "+" -command {::NeuronVND::movePcaGraphs y pos}] -row $gr -column 3 -sticky news | |
#grid [button $w.fp.navigation.main.movey4 -text "+++" -command {::NeuronVND::movePcaGraphs y 500}] -row 4 -column 4 -sticky news | |
incr gr | |
grid [label $w.main.label2.movez -text "Translate in Z:"] -row $gr -column 0 -sticky news | |
grid [button $w.main.label2.movez1 -text "-" -command {::NeuronVND::movePcaGraphs z neg}] -row $gr -column 1 -sticky news | |
#grid [button $w.fp.navigation.main.movez2 -text "-" -command {::NeuronVND::movePcaGraphs z -100}] -row 5 -column 2 -sticky news | |
grid [spinbox $w.main.label2.movez2 -width 3 -increment 10 -from 10 -to 1000 -textvariable ::NeuronVND::movez -background white] -row $gr -column 2 -sticky news | |
grid [button $w.main.label2.movez3 -text "+" -command {::NeuronVND::movePcaGraphs z pos}] -row $gr -column 3 -sticky news | |
#grid [button $w.fp.navigation.main.movez4 -text "+++" -command {::NeuronVND::moveGraphs z 500}] -row 5 -column 4 -sticky news | |
incr gr | |
grid [ttk::separator $w.main.label2.sep1] -row $gr -column 0 -sticky news -columnspan 5 -pady 2 -padx 2 | |
incr gr | |
grid [label $w.main.label2.rotx -text "Rotate around X:"] -row $gr -column 0 -sticky news | |
grid [button $w.main.label2.rotx1 -text "-" -command {::NeuronVND::rotPcaGraphs x neg}] -row $gr -column 1 -sticky news | |
#grid [button $w.fp.navigation.main.rotx2 -text "-" -command {::NeuronVND::rotPcaGraphs x -15}] -row $row -column 2 -sticky news | |
grid [spinbox $w.main.label2.rotx2 -width 3 -increment 5 -from 5 -to 180 -textvariable ::NeuronVND::rotarx -background white] -row $gr -column 2 -sticky news | |
grid [button $w.main.label2.rotx3 -text "+" -command {::NeuronVND::rotPcaGraphs x pos}] -row $gr -column 3 -sticky news | |
#grid [button $w.fp.navigation.main.rotx4 -text "+++" -command {::NeuronVND::rotPcaGraphs x 45}] -row $gr -column 4 -sticky news | |
incr gr | |
grid [label $w.main.label2.roty -text "Rotate around Y:"] -row $gr -column 0 -sticky news | |
grid [button $w.main.label2.roty1 -text "-" -command {::NeuronVND::rotPcaGraphs y neg}] -row $gr -column 1 -sticky news | |
#grid [button $w.fp.navigation.main.roty2 -text "-" -command {::NeuronVND::rotPcaGraphs y -15}] -row $gr -column 2 -sticky news | |
grid [spinbox $w.main.label2.roty2 -width 3 -increment 5 -from 5 -to 180 -textvariable ::NeuronVND::rotary -background white] -row $gr -column 2 -sticky news | |
grid [button $w.main.label2.roty3 -text "+" -command {::NeuronVND::rotPcaGraphs y pos}] -row $gr -column 3 -sticky news | |
#grid [button $w.fp.navigation.main.roty4 -text "+++" -command {::NeuronVND::rotPcaGraphs y 45}] -row $gr -column 4 -sticky news | |
incr gr | |
grid [label $w.main.label2.rotz -text "Rotate around Z:"] -row $gr -column 0 -sticky news | |
grid [button $w.main.label2.rotz1 -text "-" -command {::NeuronVND::rotPcaGraphs z neg}] -row $gr -column 1 -sticky news | |
#grid [button $w.fp.navigation.main.rotz2 -text "-" -command {::NeuronVND::rotPcaGraphs z -15}] -row $gr -column 2 -sticky news | |
grid [spinbox $w.main.label2.rotz2 -width 3 -increment 5 -from 5 -to 180 -textvariable ::NeuronVND::rotarz -background white] -row $gr -column 2 -sticky news | |
grid [button $w.main.label2.rotz3 -text "+" -command {::NeuronVND::rotPcaGraphs z pos}] -row $gr -column 3 -sticky news | |
#grid [button $w.fp.navigation.main.rotz4 -text "+++" -command {::NeuronVND::rotPcaGraphs z 45}] -row $gr -column 4 -sticky news | |
| |
wm protocol . WM_DELETE_WINDOW { | wm protocol . WM_DELETE_WINDOW { |
destroy .neuron.aligntoolgui | destroy .neuron.aligntoolgui |
::NeuronVND::delete_all | ::NeuronVND::delete_all |
| |
#function for multiple nodes in 1 selection -> see draw_axis | #function for multiple nodes in 1 selection -> see draw_axis |
proc ::NeuronVND::draw_mult_axes {selection_string} { | proc ::NeuronVND::draw_mult_axes {selection_string} { |
variable sel_string | variable sel_string |
variable x_array | variable x_array "" |
variable y_array | variable y_array "" |
variable z_array | variable z_array "" |
variable x_array_apical "" | variable x_array_apical "" |
variable y_array_apical "" | variable y_array_apical "" |
variable z_array_apical "" | variable z_array_apical "" |
variable x_array_no_axon | variable x_array_no_axon "" |
variable y_array_no_axon | variable y_array_no_axon "" |
variable z_array_no_axon | variable z_array_no_axon "" |
| variable x_array_soma "" |
| variable y_array_soma "" |
| variable z_array_soma "" |
variable size_array | variable size_array |
variable state | variable state |
variable rot_count | variable rot_count |
| |
variable morph_spherelist_combo_axon_exlusion | variable morph_spherelist_combo_axon_exlusion |
variable morph_spherelist_combo_apical | variable morph_spherelist_combo_apical |
variable com_list_apical | variable com_list_apical |
| variable com_list |
| variable com_list_no_axon |
| variable com_list_soma |
| variable scale |
| variable flip_list |
| variable main_pa_list_no_axon |
| |
| |
| set com_list "" |
set ::NeuronVND::objList "" | set ::NeuronVND::objList "" |
set ::NeuronVND::objIndex "" | set ::NeuronVND::objIndex "" |
set spherelist_list "" | set spherelist_list "" |
| |
variable vdot | variable vdot |
variable vcom_to_pa | variable vcom_to_pa |
variable vcom_to_bio | variable vcom_to_bio |
variable vdot_list | variable vdot_list "" |
variable flip_priority_axis 0 | variable flip_priority_axis 0 |
variable principal_axis_mol | variable principal_axis_mol |
set counter 0 | set counter 0 |
set flipped_list "" | set flipped_list "" |
| set flip_list "" |
set sel_string $selection_string | set sel_string $selection_string |
| |
| variable bio_mode |
| |
#perform for all reps | #perform for all reps |
set principal_axis_mol [mol new] | set principal_axis_mol [mol new] |
lappend principal_axis_mol_list $principal_axis_mol | lappend principal_axis_mol_list $principal_axis_mol |
| |
set nsize [llength $output_header] | set nsize [llength $output_header] |
set morph_spherelist_combo "" | set morph_spherelist_combo "" |
for {set i 0} {$i < $nsize} {incr i} { | for {set i 0} {$i < $nsize} {incr i} { |
set morph_spherelist_combo "" | |
set morph_spherelist_combo_apical "" | |
set morph_spherelist_combo_axon_exlusion "" | |
set morpho_details_of_one_node [::neuro::cmd_query morpho_details -moved_coords_compart_types "global_node_id == [lindex $nodes $i]"] | set morpho_details_of_one_node [::neuro::cmd_query morpho_details -moved_coords_compart_types "global_node_id == [lindex $nodes $i]"] |
| |
set principal_axis_mol [mol new] | set principal_axis_mol [mol new] |
lappend principal_axis_mol_list $principal_axis_mol | lappend principal_axis_mol_list $principal_axis_mol |
set name [mol rename $principal_axis_mol "Principal Axes Number: $sel_string"] | set name [mol rename $principal_axis_mol "Principal Axes Number: $sel_string"] |
| |
} | } |
} | } |
} | } |
| |
| foreach coord [lindex [lindex $morpho_details_of_one_node 0] 3] { |
| if {[lindex $coord 0] == 1} { |
| lappend morph_spherelist_combo_apical [lindex $coord 1] |
| foreach {x y z} [lindex $coord 1] { |
| lappend x_array_soma $x |
| lappend y_array_soma $y |
| lappend z_array_soma $z |
| } |
| } |
| } |
| |
if {$::NeuronVND::exclude_axons == 1} { | if {$::NeuronVND::exclude_axons == 1} { |
set ::NeuronVND::princ_axes_spherelist $morph_spherelist_combo_axon_exlusion | if {[llength $x_array_no_axon]} { |
lappend spherelist_list $::NeuronVND::princ_axes_spherelist | |
set size_array [llength $x_array_no_axon] | set size_array [llength $x_array_no_axon] |
::Orient::sel_mass $size_array | ::Orient::sel_mass $size_array |
::Orient::sel_com $x_array_no_axon $y_array_no_axon $z_array_no_axon | ::Orient::sel_com $x_array_no_axon $y_array_no_axon $z_array_no_axon |
#after running sel_mass/sel_com. Some data has been generated, let's copy the variables to our large list | ::Orient::calc_principalaxes $x_array_no_axon $y_array_no_axon $z_array_no_axon |
set paxis [vmd_draw_principalaxes $x_array_no_axon $y_array_no_axon $z_array_no_axon [lindex $principal_axis_mol_list $i] $flip_priority_axis] | set a3 [lindex $::Orient::calculated_axis 2] |
lappend paxis_list $paxis | set a2 [lindex $::Orient::calculated_axis 1] |
| set a1 [lindex $::Orient::calculated_axis 0] |
lappend com_list $::Orient::center_of_mass | set scale $::NeuronVND::princ_axes_scale |
lappend size_list $::Orient::assigned_weights | set $::Orient::center_of_mass "" |
lappend main_pa_list $priority_axis | } else { |
#vecsub of the priority axis (using type 1,4,3) from COM to get a vector | puts "--------AXON ARRAY IS EMPTY------" |
set vcom_to_pa [vecsub [lindex $main_pa_list $i] [lindex $com_list $i]] | } |
| if {[llength $x_array_apical] && [llength $x_array_soma]} { |
if {[llength $x_array_apical]} { | set ::NeuronVND::princ_axes_spherelist $morph_spherelist_combo_axon_exlusion |
| lappend spherelist_list $::NeuronVND::princ_axes_spherelist |
set size_array [llength $x_array_apical] | set size_array [llength $x_array_apical] |
::Orient::sel_mass $size_array | ::Orient::sel_mass $size_array |
::Orient::sel_com $x_array_apical $y_array_apical $z_array_apical | ::Orient::sel_com $x_array_apical $y_array_apical $z_array_apical |
lappend com_list_apical $::Orient::center_of_mass | lappend com_list_apical $::Orient::center_of_mass |
#vector of the soma com to bio_com (apical region) | set $::Orient::center_of_mass "" |
set vcom_to_bio [vecsub [lindex $com_list_apical $i] [lindex $com_list $i]] | set size_array [llength $x_array_soma] |
#dot product between initial vector and bio vector (apical) | ::Orient::sel_mass $size_array |
set vdot [vecdot $vcom_to_pa $vcom_to_bio] | ::Orient::sel_com $x_array_soma $y_array_soma $z_array_soma |
| lappend com_list_soma $::Orient::center_of_mass |
| set $::Orient::center_of_mass "" |
| set flippy 1 |
| set vbio [vecsub [lindex $com_list_apical $i] [lindex $com_list_soma $i]] |
| set vdot [vecdot $a3 $vbio] |
| #utility to check bio vector and a3 |
| #::NeuronVND::draw_vector_given_length [lindex $principal_axis_mol_list $i] [lindex $com_list_soma $i] $vbio 70 9 |
| #::NeuronVND::draw_vector_given_length [lindex $principal_axis_mol_list $i] [lindex $com_list_soma $i] $a3 50 10 |
lappend vdot_list $vdot | lappend vdot_list $vdot |
if {$vdot < 0} { | if {$vdot < 0} { |
graphics [lindex $principal_axis_mol_list $i] delete all | #FLIPPING |
| #Here we flip a1, a2, and a3 for the current neuron |
| set a1 [vecscale -1 $a1] |
| set a2 [vecscale -1 $a2] |
| set a3 [vecscale -1 $a3] |
| |
set flip_priority_axis 1 | set flip_priority_axis 1 |
set size_array_2 [llength $x_array_no_axon] | set size_array [llength $x_array_no_axon] |
::Orient::sel_mass $size_array_2 | ::Orient::sel_mass $size_array |
::Orient::sel_com $x_array_no_axon $y_array_no_axon $z_array_no_axon | ::Orient::sel_com $x_array_no_axon $y_array_no_axon $z_array_no_axon |
set paxis [vmd_draw_principalaxes $x_array_no_axon $y_array_no_axon $z_array_no_axon [lindex $principal_axis_mol_list $i] $flip_priority_axis] | |
#lappend paxis_list $paxis | |
| #set paxis [vmd_draw_principalaxes $x_array_no_axon $y_array_no_axon $z_array_no_axon [lindex $principal_axis_mol_list $i] $flip_priority_axis] |
| |
| graphics [lindex $principal_axis_mol_list $i] color red |
| vmd_draw_vector [lindex $principal_axis_mol_list $i] $::Orient::center_of_mass [vecscale $scale $a1] |
| graphics [lindex $principal_axis_mol_list $i] color green |
| vmd_draw_vector [lindex $principal_axis_mol_list $i] $::Orient::center_of_mass [vecscale $scale $a2] |
| graphics [lindex $principal_axis_mol_list $i] color 24 |
| vmd_draw_vector [lindex $principal_axis_mol_list $i] $::Orient::center_of_mass [vecscale $scale $a3] |
| |
| |
| graphics [lindex $principal_axis_mol_list $i] color white |
| #now just drawing straight from calculated axis |
| graphics [lindex $principal_axis_mol_list $i] text [vecadd $::Orient::center_of_mass [vecscale [expr $scale * 1.02] $a1]] "3" |
| graphics [lindex $principal_axis_mol_list $i] text [vecadd $::Orient::center_of_mass [vecscale [expr $scale * 1.02] $a2]] "2" |
| graphics [lindex $principal_axis_mol_list $i] text [vecadd $::Orient::center_of_mass [vecscale [expr $scale * 1.02] $a3]] "1" |
| |
incr counter | incr counter |
lappend flipped_list [lindex $nodes $i] | lappend flipped_list [lindex $nodes $i] |
| set paxis [list $a1 $a2 $a3] |
| lappend paxis_list $paxis |
| |
| lappend main_pa_list $a3 |
| lappend flip_list "1" |
| lappend com_list_no_axon $::Orient::center_of_mass |
| set $::Orient::center_of_mass "" |
| |
| } else { |
| #NOT FLIPPING |
| set flip_priority_axis 0 |
| set size_array [llength $x_array_no_axon] |
| ::Orient::sel_mass $size_array |
| ::Orient::sel_com $x_array_no_axon $y_array_no_axon $z_array_no_axon |
| #removed since this recalcated function reduced efficiency |
| #set paxis [vmd_draw_principalaxes $x_array_no_axon $y_array_no_axon $z_array_no_axon [lindex $principal_axis_mol_list $i] $flip_priority_axis] |
| |
| graphics [lindex $principal_axis_mol_list $i] color red |
| vmd_draw_vector [lindex $principal_axis_mol_list $i] $::Orient::center_of_mass [vecscale $scale $a1] |
| graphics [lindex $principal_axis_mol_list $i] color green |
| vmd_draw_vector [lindex $principal_axis_mol_list $i] $::Orient::center_of_mass [vecscale $scale $a2] |
| graphics [lindex $principal_axis_mol_list $i] color 24 |
| vmd_draw_vector [lindex $principal_axis_mol_list $i] $::Orient::center_of_mass [vecscale $scale $a3] |
| |
| graphics [lindex $principal_axis_mol_list $i] color white |
| graphics [lindex $principal_axis_mol_list $i] text [vecadd $::Orient::center_of_mass [vecscale [expr $scale * 1.02] $a1]] "3" |
| graphics [lindex $principal_axis_mol_list $i] text [vecadd $::Orient::center_of_mass [vecscale [expr $scale * 1.02] $a2]] "2" |
| graphics [lindex $principal_axis_mol_list $i] text [vecadd $::Orient::center_of_mass [vecscale [expr $scale * 1.02] $a3]] "1" |
| |
| lappend main_pa_list $a3 |
| set paxis [list $a1 $a2 $a3] |
| lappend paxis_list $paxis |
| lappend flip_list "0" |
| lappend com_list_no_axon $::Orient::center_of_mass |
| set $::Orient::center_of_mass "" |
} | } |
| } else { |
| set ::NeuronVND::princ_axes_spherelist $morph_spherelist_combo_axon_exlusion |
| lappend spherelist_list $::NeuronVND::princ_axes_spherelist |
| set flip_priority_axis 0 |
| set size_array [llength $x_array_no_axon] |
| ::Orient::sel_mass $size_array |
| ::Orient::sel_com $x_array_no_axon $y_array_no_axon $z_array_no_axon |
| set paxis [vmd_draw_principalaxes $x_array_no_axon $y_array_no_axon $z_array_no_axon [lindex $principal_axis_mol_list $i] $flip_priority_axis] |
| lappend main_pa_list $priority_axis |
| lappend paxis_list $paxis |
| lappend flip_list "0" |
| lappend com_list_no_axon $::Orient::center_of_mass |
| set $::Orient::center_of_mass "" |
} | } |
puts "now excluding" | |
} elseif {$::NeuronVND::exclude_axons == 0} { | } elseif {$::NeuronVND::exclude_axons == 0} { |
graphics [lindex $principal_axis_mol_list $i] delete all | |
set flip_priority_axis 0 | set flip_priority_axis 0 |
set ::NeuronVND::princ_axes_spherelist $morph_spherelist_combo | set ::NeuronVND::princ_axes_spherelist $morph_spherelist_combo |
lappend spherelist_list $::NeuronVND::princ_axes_spherelist | lappend spherelist_list $::NeuronVND::princ_axes_spherelist |
set size_array [llength $x_array] | set size_array [llength $x_array] |
::Orient::sel_mass $size_array | ::Orient::sel_mass $size_array |
::Orient::sel_com $x_array $y_array $z_array | ::Orient::sel_com $x_array $y_array $z_array |
#after running sel_mass/sel_com. Some data has been generated, let's copy the variables to our large list | |
| |
#see here we use a different list x_array (this list contains mutually exhaustive structural points) | |
#set paxis [vmd_draw_principalaxes $x_array_no_axon $y_array_no_axon $z_array_no_axon [lindex $principal_axis_mol_list $i] $flip_priority_axis] | |
set paxis [vmd_draw_principalaxes $x_array $y_array $z_array [lindex $principal_axis_mol_list $i] $flip_priority_axis] | set paxis [vmd_draw_principalaxes $x_array $y_array $z_array [lindex $principal_axis_mol_list $i] $flip_priority_axis] |
lappend paxis_list $paxis | lappend paxis_list $paxis |
lappend com_list $::Orient::center_of_mass | lappend com_list $::Orient::center_of_mass |
lappend size_list $::Orient::assigned_weights | lappend size_list $::Orient::assigned_weights |
lappend main_pa_list $priority_axis | lappend main_pa_list $priority_axis |
#vecsub of the priority axis (using type 1,4,3) from COM to get a vector | |
set vcom_to_pa [vecsub [lindex $main_pa_list $i] [lindex $com_list $i]] | |
display resetview | display resetview |
puts "now including" | |
} | } |
| set x_array_soma "" |
| set y_array_soma "" |
| set z_array_soma "" |
set x_array_apical "" | set x_array_apical "" |
set y_array_apical "" | set y_array_apical "" |
set z_array_apical "" | set z_array_apical "" |
| |
set x_array "" | set x_array "" |
set y_array "" | set y_array "" |
set z_array "" | set z_array "" |
| set morph_spherelist_combo "" |
| set morph_spherelist_combo_apical "" |
| set morph_spherelist_combo_axon_exlusion "" |
} | } |
| |
puts "list -> $vdot_list" | puts "list -> $vdot_list" |
puts "-------------THERE HAS BEEN $counter AXIS FLIPPED-------------" | puts "-------------THERE HAS BEEN $counter AXIS FLIPPED-------------" |
puts "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" | puts "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" |
| |
set percent [expr [expr double($counter)/$total] * 100] | set percent [expr [expr double($counter)/$total] * 100] |
} | } |
puts "The percent flipped = $percent%" | puts "The percent flipped = $percent%" |
| |
} | } |
| |
#fill Mariano's objlist #haky way | #fill Mariano's objlist #haky way |
lappend ::NeuronVND::objList [list $principal_axis_mol $name2] | lappend ::NeuronVND::objList [list $principal_axis_mol $name2] |
set ::NeuronVND::objIndex [lindex $::NeuronVND::objList 0] | set ::NeuronVND::objIndex [lindex $::NeuronVND::objList 0] |
set_scale | |
set rot_count 0 | set rot_count 0 |
} | } |
| |
| proc ::NeuronVND::draw_vector_given_length {mol start vec length col} { |
| set nvec [vecscale [expr 1 / [veclength $vec]] $vec] |
| set draw_vec [vecscale $length $nvec] |
| set end [vecadd $start $draw_vec] |
| |
| puts "dvgl: mol = $mol, start = $start, end = $end, vec = $vec, length = $length, color = $col" |
| #the 70 makes it thicker than other arrows that we draw |
| #set scaling [expr [veclength [vecsub $end $start]]/70] |
| set scaling 4 |
| # an arrow is made of a cylinder and a cone |
| set middle [vecadd $start [vecscale 0.8 [vecsub $end $start]]] |
| graphics $mol color $col |
| graphics $mol cylinder $start $middle radius [expr 1.4*$scaling] |
| #i added this |
| #graphics $mol line $start [vecadd $start {100 100 100}] width 2 style solid |
| #puts [list cone $middle $end radius [expr 5*$scaling]] |
| graphics $mol cone $middle $end radius [expr 5*$scaling] |
| } |
| |
#function used for aligning to input vector | #function used for aligning to input vector |
proc ::NeuronVND::jump_mult_node {} { | proc ::NeuronVND::jump_mult_node {} { |
variable objList | variable objList |
| |
variable spherelist_list | variable spherelist_list |
variable nodes | variable nodes |
variable main_pa_list | variable main_pa_list |
| variable com_list_apical |
| variable com_list_soma |
| variable com_list_no_axon |
set aggoffset [transidentity] | set aggoffset [transidentity] |
set aggrot [transidentity] | set aggrot [transidentity] |
| variable flip_list |
| variable main_pa_list_no_axon |
| |
set objid [lindex $objIndex 0] | set objid [lindex $objIndex 0] |
if {$objid == ""} {return} | if {$objid == ""} {return} |
| |
#in Layman's terms, each neuron in the selection gets aligned to input vector | #in Layman's terms, each neuron in the selection gets aligned to input vector |
for {set i 0} {$i < [expr [llength $nodes]]} {incr i} { | for {set i 0} {$i < [expr [llength $nodes]]} {incr i} { |
| |
set princ_moved_mol [mol new] | set princ_moved_mol [mol new] |
mol rename $princ_moved_mol "Aligned molecule" | mol rename $princ_moved_mol "Aligned molecule" |
lappend princ_moved_mol_list $princ_moved_mol | lappend princ_moved_mol_list $princ_moved_mol |
| |
set a2 [lindex $paxis_list $i 1] | set a2 [lindex $paxis_list $i 1] |
set a3 [lindex $paxis_list $i 2] | set a3 [lindex $paxis_list $i 2] |
| |
puts "IN THE LOOP a1 = $a1, a2 = $a2, a3 = $a3" | if {$::NeuronVND::exclude_axons == 1} { |
#constant | set com [lindex $com_list_no_axon $i] |
| puts "now exlcuding and setting com_list_no_axon" |
| } else { |
| set com [lindex $com_list $i] |
| puts "including and setting com_list" |
| } |
set user_target [list $xin $yin $zin] | set user_target [list $xin $yin $zin] |
| |
set m1 [transvecinv [lindex $main_pa_list $i]] | set m1 [transvecinv [lindex $main_pa_list $i]] |
set m2 [transvec $user_target] | set m2 [transvec $user_target] |
set m_orig_to_com [transoffset [lindex $com_list $i]] | set m_orig_to_com [transoffset $com] |
set m_com_to_orig [transoffset [vecscale -1 [lindex $com_list $i]]] | set m_com_to_orig [transoffset [vecscale -1 $com]] |
#m_to_user is specifically for the morphology included with translations to origin and back to COM | #m_to_user is specifically for the morphology included with translations to origin and back to COM |
set m_to_user [transmult $m_orig_to_com $m2 $m1 $m_com_to_orig] | set m_to_user [transmult $m_orig_to_com $m2 $m1 $m_com_to_orig] |
set aggrot [transmult $m2 $m1] | set aggrot [transmult $m2 $m1] |
| |
set a2_moved [coordtrans $aggrot $a2] | set a2_moved [coordtrans $aggrot $a2] |
set a3_moved [coordtrans $aggrot $a3] | set a3_moved [coordtrans $aggrot $a3] |
| |
if {$::NeuronVND::exclude_axons == 1} { | #coding when to use com_list_apical |
set a3_moved_flip [vecscale -1 $a3_moved] | |
} elseif {$::NeuronVND::exclude_axons == 0} { | |
set a3_moved_flip [vecscale -1 $a3_moved] | |
} | |
| |
graphics $princ_moved_mol delete all | graphics $princ_moved_mol delete all |
graphics $princ_moved_mol_axes delete all | graphics $princ_moved_mol_axes delete all |
| |
#draw numbers here and set principal axis | #draw numbers here and set principal axis |
graphics [lindex $princ_moved_mol_axes_list $i] color 9 | graphics [lindex $princ_moved_mol_axes_list $i] color 9 |
vmd_draw_vector [lindex $princ_moved_mol_axes_list $i] [lindex $com_list $i] [vecscale $princ_axes_scale $a1_moved] | vmd_draw_vector [lindex $princ_moved_mol_axes_list $i] $com [vecscale $princ_axes_scale $a1_moved] |
graphics [lindex $princ_moved_mol_axes_list $i] color 12 | graphics [lindex $princ_moved_mol_axes_list $i] color 12 |
vmd_draw_vector [lindex $princ_moved_mol_axes_list $i] [lindex $com_list $i] [vecscale $princ_axes_scale $a2_moved] | vmd_draw_vector [lindex $princ_moved_mol_axes_list $i] $com [vecscale $princ_axes_scale $a2_moved] |
graphics [lindex $princ_moved_mol_axes_list $i] color 15 | graphics [lindex $princ_moved_mol_axes_list $i] color 15 |
vmd_draw_vector [lindex $princ_moved_mol_axes_list $i] [lindex $com_list $i] [vecscale $princ_axes_scale $a3_moved_flip] | vmd_draw_vector [lindex $princ_moved_mol_axes_list $i] $com [vecscale $princ_axes_scale $a3_moved] |
| |
foreach sphere [lindex $spherelist_list $i] { | foreach sphere [lindex $spherelist_list $i] { |
set ts [coordtrans $m_to_user $sphere] | set ts [coordtrans $m_to_user $sphere] |
graphics [lindex $princ_moved_mol_list $i] color 32 | graphics [lindex $princ_moved_mol_list $i] color 32 |
| |
} | } |
display update on | display update on |
} | } |
| |
#utility function to set principal axis scale | |
proc ::NeuronVND::set_scale {} { | |
variable princ_axes_scale | |
variable princ_axes | |
variable scale1_temp | |
variable scale2_temp | |
variable scale3_temp | |
set a1 [lindex $princ_axes 0] | |
set a2 [lindex $princ_axes 1] | |
set a3 [lindex $princ_axes 2] | |
set aggrot [transidentity] | |
set aggrot [transmult $aggrot [transaxis x 0]] | |
| |
set a1_moved [coordtrans $aggrot $a1] | |
set a2_moved [coordtrans $aggrot $a2] | |
set a3_moved [coordtrans $aggrot $a3] | |
| |
set scale1_temp [vecscale $princ_axes_scale $a1_moved] | |
set scale2_temp [vecscale $princ_axes_scale $a2_moved] | |
set scale3_temp [vecscale $princ_axes_scale $a3_moved] | |
} | |
| |
#free the lists from memory | #free the lists from memory |
proc ::NeuronVND::delete_axes {} { | proc ::NeuronVND::delete_axes {} { |
variable principal_axis_mol | variable principal_axis_mol |
| |
| |
variable principal_axis_mol_list | variable principal_axis_mol_list |
variable com_list_apical | variable com_list_apical |
| variable com_list |
| variable com_list_no_axon |
| variable flip_list |
| |
mol delete $principal_axis_mol | mol delete $principal_axis_mol |
mol delete $princ_moved_mol_axes | mol delete $princ_moved_mol_axes |
| |
set ::NeuronVND::x_array "" | set ::NeuronVND::x_array "" |
set ::NeuronVND::y_array "" | set ::NeuronVND::y_array "" |
set ::NeuronVND::z_array "" | set ::NeuronVND::z_array "" |
| set ::NeuronVND::x_array_soma "" |
| set ::NeuronVND::y_array_soma "" |
| set ::NeuronVND::z_array_soma "" |
| |
set princ_moved_mol_list "" | set princ_moved_mol_list "" |
set princ_moved_mol_axes_list "" | set princ_moved_mol_axes_list "" |
set mov_count 0 | set mov_count 0 |
| |
set ::NeuronVND::paxis_list "" | set ::NeuronVND::paxis_list "" |
set ::NeuronVND::spherelist_list "" | set ::NeuronVND::spherelist_list "" |
set ::NeuronVND::com_list_apical "" | set ::NeuronVND::com_list_apical "" |
| set ::NeuronVND::com_list "" |
| set ::NeuronVND::com_list_no_axon "" |
| set ::NeuronVND::com_list_soma "" |
| set ::NeuronVND::flip_list "" |
} | } |
| |
proc ::NeuronVND::delete_all {} { | proc ::NeuronVND::delete_all {} { |