simcontrol_som02.tcl 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. #!/usr/bin/tclsh
  2. #ToDo
  3. # ShowWeights (without Tom)
  4. # ShowWeights at SetTrialNr (driven from simulation)
  5. # switch between facilitatory and normal inhibition (set default to normal)
  6. # WeightSum
  7. # switch between linear and quadratic
  8. # choose Stimulus Set (radio button)
  9. # ShowSelectivity
  10. package require Tk
  11. package require BWidget
  12. wm minsize . 350 400
  13. set SimulationName som02
  14. set LibSimcontrolPath "$env(HOME)/prog/objsim/src"
  15. source "$LibSimcontrolPath/libsimcontrol.tcl"
  16. source "$env(HOME)/prog/objsim/scripts/getSimLayout.tcl"
  17. TestLibSimcontrol
  18. SetSimDirAndFileNames som02
  19. proc SetTrialNr {nr} {
  20. set ::TrialNr $nr
  21. ShowListWeights ${::LBname}
  22. }
  23. proc StartSim {} {
  24. set CmdParas {}
  25. append CmdParas " --SimControlName [tk appname] "
  26. foreach CmdOpt $::SimOptionsList {
  27. if {$CmdOpt != "SimControlName"} {
  28. append CmdParas " --$CmdOpt $::SimOptions($CmdOpt) "
  29. }
  30. }
  31. foreach CmdFlag $::SimFlagsList {
  32. if {$::SimFlags($CmdFlag) == 0} {
  33. set CmdFlag "No$CmdFlag"
  34. }
  35. append CmdParas " --$CmdFlag "
  36. }
  37. puts "CommandLineParameter: $CmdParas"
  38. # exec "./startsim $CmdParas >zombi.txt"
  39. set ::inout [open "|./startsim $CmdParas" "r"]
  40. # puts "Neuronentyp: $::NType"
  41. # fconfigure $::inout -blocking 0 -buffering line -translation crlf -eofchar {}
  42. while {[eof $::inout] != 1} {
  43. puts [gets $::inout]
  44. }
  45. close $::inout
  46. # puts [read $::inout]
  47. # ShowSim
  48. }
  49. proc StopSim {} {
  50. # puts $::SimName
  51. set ::inout [open "|./startsim stop" "r"]
  52. while {[eof $::inout] != 1} {
  53. puts [gets $::inout]
  54. }
  55. close $::inout
  56. # puts "Neuronentyp: $::NType"
  57. # fconfigure $::inout -blocking 0 -buffering line -translation crlf -eofchar {}
  58. # puts [read $::inout]
  59. # ShowSim
  60. }
  61. proc ShowSim {} {
  62. set ShowOptions {}
  63. if {$::SimOptions(NeuronType) == 0} {
  64. append ShowOptions ",CutSpikes=$::CutSpikePot "
  65. }
  66. set Command "csim_showsimspikes, dirname=\"$::SimDataDir\", /sec $ShowOptions \n"
  67. # set Command "csim_showsimspikes, dirname=\"$::SimDataDir\", /sec \n"
  68. puts $Command
  69. puts $::idl $Command
  70. }
  71. proc GenerateParaOverlapInput {} {
  72. set Options {}
  73. append ShowOptions ", Active=$::Active "
  74. append ShowOptions ", Overlap=$::Overlap"
  75. append ShowOptions ", NPatterns=4"
  76. append ShowOptions ", OW=5"
  77. append ShowOptions ", OH=8"
  78. append ShowOptions ", /Show"
  79. set Command "makeobjmovie_paraoverlap $ShowOptions \n"
  80. puts $Command
  81. puts $::idl $Command
  82. }
  83. proc TestParaEntry {} {
  84. puts $::InputStrength
  85. puts $::LearnRate
  86. puts $::CheckVar
  87. }
  88. ####################StartOfMainProgram
  89. OpenIDL
  90. ReadSimConfigFile
  91. # pack [button .dummy -command "ReadIDL" -text "ReadIDL"]
  92. # pack [button .showsim -command "ShowSim" -text "ShowSim"]
  93. labelframe .but0 -width 1500 -height 100 -borderwidth 4 -relief sunken -text "SimControl" -padx 10 -pady 5
  94. pack .but0 -pady 10
  95. set curframe .but0
  96. # pack [button ${curframe}.test -command "ShowWM1" -text "ChangeWeightFile"] -side left
  97. # pack [button ${curframe}.test2 -command "ShowWM1" -text "ChangeWeightFile"] -side left
  98. #pack [button ${curframe}.change -command "ShowWM1" -text "ChangeWeightFile"] -side left
  99. frame ${curframe}.startstop
  100. pack ${curframe}.startstop -pady 3
  101. set curframe1 ${curframe}.startstop
  102. pack [button ${curframe1}.startsim -command "StartSim" -text "StartSim"] -side left -padx 5
  103. pack [button ${curframe1}.stopsim -command "StopSim" -text "StopSim"] -side left
  104. # labelframe ${curframe}.modelchose -text "Choose Neuron Model" -padx 5
  105. # pack ${curframe}.modelchose
  106. # set curframe1 ${curframe}.modelchose
  107. # pack [radiobutton ${curframe1}.one -value 0 -text "Izhikevich-Neuron" -variable SimOptions(NeuronType)] -anchor sw
  108. # pack [radiobutton ${curframe1}.two -value 1 -text "Izh7-Model-Neuron" -variable SimOptions(NeuronType)] -anchor sw
  109. # pack [radiobutton ${curframe1}.three -value 2 -text "Izh8-Model-Neuron" -variable SimOptions(NeuronType)] -anchor sw
  110. # pack [radiobutton ${curframe1}.four -value 3 -text "Marburg-Model-Neuron" -variable SimOptions(NeuronType)] -anchor sw
  111. # lappend SimOptionsList NeuronType
  112. # frame ${curframe}.stimselectionframe -padx 1
  113. # pack ${curframe}.stimselectionframe -side top
  114. # set curframe1 ${curframe}.stimselectionframe
  115. # labelframe ${curframe1}.stimsetchoose -text "ChooseStimType" -padx 5
  116. # pack ${curframe1}.stimsetchoose -side right
  117. # set curframe2 ${curframe1}.stimsetchoose
  118. # # pack [radiobutton ${curframe1}.test -value 9 -text "test" -variable SimOptions(StimulusNumber)] -anchor sw
  119. # set StimTypeList {}
  120. # lappend StimTypeList [radiobutton ${curframe2}.one -value 0 -command "ShowRadioStimSet 0" -text "Test" -variable SimOptions(StimulusSet)]
  121. # lappend StimTypeList [radiobutton ${curframe2}.two -value 1 -command "ShowRadioStimSet 1" -text "Parametric" -variable SimOptions(StimulusSet)]
  122. # lappend StimTypeList [radiobutton ${curframe2}.three -value 2 -command "ShowRadioStimSet 2" -text "Scan" -variable SimOptions(StimulusSet)]
  123. # lappend StimTypeList [radiobutton ${curframe2}.four -value 3 -command "ShowRadioStimSet 3" -text "File" -variable SimOptions(StimulusSet)]
  124. # lappend StimTypeList [radiobutton ${curframe2}.five -value 4 -command "ShowRadioStimSet 4" -text "ASCII" -variable SimOptions(StimulusSet)]
  125. # lappend StimTypeList [radiobutton ${curframe2}.six -value 6 -command "ShowRadioStimSet 3" -text "Sequence" -variable SimOptions(StimulusSet)]
  126. # foreach ListItem $StimTypeList {
  127. # pack $ListItem -anchor sw
  128. # }
  129. # lappend SimOptionsList StimulusSet
  130. # labelframe ${curframe1}.stimchoose -text "Choose Stimulus Set" -padx 2
  131. # #frame ${curframe1}.stimchoose -padx 5
  132. # pack ${curframe1}.stimchoose -side left
  133. # set StimNumberChooseFrame ${curframe1}.stimchoose
  134. # set StimSelectionList {}
  135. proc ShowRadioStimSet {StimSetNr} {
  136. puts $StimSetNr
  137. set curframe1 $::StimNumberChooseFrame
  138. DestroyElements $::StimSelectionList
  139. set Delindex [lsearch $::SimOptionsList StimFileName]
  140. if {$Delindex != -1} {
  141. set ::SimOptionsList [lreplace $::SimOptionsList $Delindex $Delindex]
  142. }
  143. if {$StimSetNr == 0} {
  144. set ::StimSelectionList {}
  145. lappend ::StimSelectionList [radiobutton ${curframe1}.one -value 0 -text "5x5, 4 stim, no overlap" -variable ::SimOptions(StimulusNumber)]
  146. lappend ::StimSelectionList [radiobutton ${curframe1}.two -value 1 -text "5x5, 4 stim, small overlap" -variable ::SimOptions(StimulusNumber)]
  147. lappend ::StimSelectionList [radiobutton ${curframe1}.three -value 2 -text "5x5, 4 stim, high overlap" -variable ::SimOptions(StimulusNumber)]
  148. foreach ListItem $::StimSelectionList {
  149. pack $ListItem -anchor sw
  150. }
  151. }
  152. if {$StimSetNr == 1} {
  153. frame ${curframe1}.genovpat
  154. pack ${curframe1}.genovpat
  155. set curframe2 ${curframe1}.genovpat
  156. lappend ::StimSelectionList $curframe2
  157. set ::Active 0.2
  158. set ::Overlap 0.8
  159. SimParaEntry active ::Active $curframe2
  160. SimParaEntry overlap ::Overlap $curframe2
  161. pack [button ${curframe2}.genoverlapbutton -command "GenerateParaOverlapInput" -text "GenOvInput"] -side bottom
  162. }
  163. if {$StimSetNr == 3} {
  164. frame ${curframe1}.stmfilename
  165. pack ${curframe1}.stmfilename
  166. set curframe2 ${curframe1}.stmfilename
  167. lappend ::StimSelectionList $curframe2
  168. lappend ::SimOptionsList StimFileName
  169. # SimOptionsEntry stmfile StimFileName $curframe2
  170. label ${curframe2}.stmfilelabel -text "StimulusFileName"
  171. pack ${curframe2}.stmfilelabel -anchor sw -side top
  172. set mybut [entry ${curframe2}.stmfileentry -textvariable ::SimOptions(StimFileName) -width 15 -bg white -relief sunken -border 1 -highlightcolor green]
  173. pack $mybut -side left -anchor n -side bottom -pady 2
  174. }
  175. }
  176. # ShowRadioStimSet 0
  177. # lappend SimOptionsList StimulusNumber
  178. labelframe ${curframe}.setparameter -text "Set Simulation Parameters" -padx 5 -pady 3
  179. pack ${curframe}.setparameter -pady 5
  180. set curframe1 ${curframe}.setparameter
  181. # SimFlagsEntry defaultconfigfile MakeDefaultConfig $curframe1
  182. # SimOptionsEntry2 NTrials $curframe1
  183. # SimOptionsEntry2 NSteps $curframe1
  184. # SimOptionsEntry2 ITNx $curframe1
  185. # SimOptionsEntry2 ITNy $curframe1
  186. # SimOptionsEntry2 InputStrength $curframe1
  187. # SimOptionsEntry2 InitialWeights $curframe1
  188. # SimOptionsEntry2 LearnRate $curframe1
  189. # SimOptionsEntry2 FWMaxWeights $curframe1
  190. # SimOptionsEntry2 WeightSum $curframe1
  191. # SimFlagsEntry quadnorm QuadraticNorm $curframe1
  192. # SimFlagsEntry loadweights LoadWeights $curframe1
  193. # SimOptionsEntry2 ITExExWeights $curframe1
  194. # SimOptionsEntry2 ITExExRange $curframe1
  195. set ResultsWindowName .simresultswin
  196. frame ${curframe}.results3 -borderwidth 1 -relief sunken
  197. pack ${curframe}.results3
  198. set curframe1 ${curframe}.results3
  199. pack [checkbutton ${curframe1}.show -text "Show Simulation Results" -variable VisibleSimResults -command [list ShowHideWin ${::ResultsWindowName} VisibleSimResults]] -side top
  200. ShowResultsWindow $ResultsWindowName
  201. set LayoutWindowName .simlayoutwin
  202. pack [checkbutton ${curframe1}.show2 -text "Show Network Layout" -variable VisibleSimLayout -command [list ShowHideWin ${::LayoutWindowName} VisibleSimLayout] ] -side top
  203. ShowLayoutWindow $LayoutWindowName $SimDataDir
  204. set OptionsWindowName .simoptionswin
  205. pack [checkbutton ${curframe1}.show3 -text "Show Options" -variable VisibleSimOptions -command [list ShowHideWin ${::OptionsWindowName} VisibleSimOptions] ] -side top
  206. ShowOptionsWindow $OptionsWindowName
  207. set SimOutputWindowName .simoutputwin
  208. pack [checkbutton ${curframe1}.show4 -text "Show Simulation Output " -variable VisibleSimoutputWindow -command [list ShowHideOutputWin ${::SimOutputWindowName} ::VisibleSimoutputWindow] ] -side top
  209. ShowSimoutputWindow $SimOutputWindowName
  210. ShowHideWin ${::SimOutputWindowName} ::VisibleSimoutputWindow