Skip to content
This repository was archived by the owner on Jan 27, 2023. It is now read-only.

Commit 04926e5

Browse files
author
Antonio Ulloa
committed
Exchanging hard-coded variables with variables contained in input files
1 parent 00dc2a1 commit 04926e5

File tree

6 files changed

+107
-9
lines changed

6 files changed

+107
-9
lines changed

auditory_model/lsnm_tvb_link.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
ea1d 474
2+
ia1d 474
3+
ea1u 474
4+
ia1u 474
5+
ea2d 470
6+
ia2d 470
7+
ea2c 470
8+
ia2c 470
9+
ea2u 470
10+
ia2u 470
11+
estg 477
12+
istg 477
13+
exfs 51
14+
infs 51
15+
efd1 51
16+
ifd1 51
17+
efd2 51
18+
ifd2 51
19+
exfr 51
20+
infr 51

simulation/sim.py

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,18 @@ def __init__(self):
110110

111111
def initUI(self):
112112

113+
global learning
114+
learning = False # Determines whether hebbian learning will be applied
115+
116+
global learning_file # name of the file that contains name of modules that will undergo
117+
learning_file ="" # hebbian learning
118+
113119
global useTVBConnectome
114120
useTVBConnectome = False # Determines whether to use a TVB connectome within simulation
115121

122+
global embedding_file # locations of embedded LSNM nodes within TVB connectome
123+
embedding_file = ""
124+
116125
global generateSubject
117126
generateSubject = False # Determines whether or not to vary connection weights given
118127
# to create a new subject for the current simulation
@@ -163,21 +172,28 @@ def initUI(self):
163172
# define the action to be taken if Run button is clicked on
164173
neuralNetButton.clicked.connect(self.browseNeuralNets)
165174

175+
# define check box to allow user to define LSNM module that will participate as a source
176+
# in hebbian learning
177+
learningBox = QtGui.QCheckBox('Use Hebbian Learning', self)
178+
layout.addWidget(learningBox, 4, 0)
179+
# define the action to be taken if learning box is selected
180+
learningBox.stateChanged.connect(self.learningOrNot)
181+
166182
# define checkbox to allow users to determine whether or not a TVB connectome will be used
167183
# in simulation
168184
connectomeBox = QtGui.QCheckBox('Use TVB Connectome', self)
169-
layout.addWidget(connectomeBox, 4, 0)
185+
layout.addWidget(connectomeBox, 5, 0)
170186
connectomeBox.stateChanged.connect(self.connectomeOrNot)
171187

172188
# create a push button object labeled 'Run'
173189
runButton = QtGui.QPushButton('Run simulation', self)
174-
layout.addWidget(runButton, 5, 0)
190+
layout.addWidget(runButton, 7, 0)
175191
# define the action to be taken if Run button is clicked on
176192
runButton.clicked.connect(self.onStart)
177193

178194
# create a push button object labeled 'Exit'
179195
exitButton = QtGui.QPushButton('Quit LSNM', self)
180-
layout.addWidget(exitButton, 6, 0)
196+
layout.addWidget(exitButton, 8, 0)
181197
# define the action to be taken if Exit button is clicked on
182198
exitButton.clicked.connect(QtCore.QCoreApplication.instance().quit)
183199

@@ -197,20 +213,28 @@ def initUI(self):
197213
self.neuralNetTextEdit = QtGui.QLineEdit()
198214
layout.addWidget(self.neuralNetTextEdit, 3, 1)
199215

216+
# create a text edit object for reading file that contains modules that will undergo learning
217+
self.learningTextEdit = QtGui.QLineEdit()
218+
layout.addWidget(self.learningTextEdit, 4, 1)
219+
220+
# create text edit object that contains name of file with locations of LSNM nodes within TVB
221+
self.embeddingTextEdit = QtGui.QLineEdit()
222+
layout.addWidget(self.embeddingTextEdit, 5, 1)
223+
200224
# define checkbox to allow users to determine whether or not to vary weights randomly from
201225
# weights given to create a new simulated subject
202226
newSubjectBox= QtGui.QCheckBox('Vary weights to create new subject', self)
203-
layout.addWidget(newSubjectBox, 4, 1)
227+
layout.addWidget(newSubjectBox, 6, 0)
204228
newSubjectBox.stateChanged.connect(self.createNewSubject)
205229

206230
# define output display to keep users updated with simulation progress status messages
207231
self.runTextEdit = QtGui.QTextEdit()
208-
layout.addWidget(self.runTextEdit, 5, 1)
232+
layout.addWidget(self.runTextEdit, 7, 1)
209233

210234
# define progress bar to keep user informed of simulation progress status
211235
self.progressBar = QtGui.QProgressBar(self)
212236
self.progressBar.setRange(0,100)
213-
layout.addWidget(self.progressBar, 6, 1)
237+
layout.addWidget(self.progressBar, 8, 1)
214238

215239
# define the main thread as the main simulation code
216240
self.myLongTask = TaskThread()
@@ -260,19 +284,40 @@ def browseNeuralNets(self):
260284
global neural_net
261285
# allow user to browse files to find desired input file containing neural net (model and weights
262286
# combined)
263-
neural_net = QtGui.QFileDialog.getOpenFileName(self, 'Select *.txt file that contains neural net', '.')
287+
neural_net = QtGui.QFileDialog.getOpenFileName(self, 'Select *.json file that contains neural net', '.')
264288

265-
# display contents of file containing neural net (model and weights combined
289+
# display contents of file containing neural net (model and weights combined)
266290
self.neuralNetTextEdit.setText(neural_net)
267291

292+
def learningOrNot(self, state):
293+
294+
global learning
295+
global learning_file
296+
# allow user to decide whether network weights will be participating in Hebbian learning during
297+
# simulation
298+
if state == QtCore.Qt.Checked:
299+
learning = True
300+
print '\rUsing Hebbian learning...'
301+
learning_file = QtGui.QFileDialog.getOpenFileName(self, 'Select file that contains learning modules', '.')
302+
303+
# display contents of file with names of modules whose weights will undergo hebbian learning
304+
self.learningTextEdit.setText(learning_file)
305+
else:
306+
learning = False
307+
print '\rNot Using learning...'
268308

269309
def connectomeOrNot(self, state):
270310

271311
global useTVBConnectome
312+
global embedding_file
272313
# allow user to decide whether to use a TVB connectome as part of the simulation
273314
if state == QtCore.Qt.Checked:
274315
useTVBConnectome = True
275316
print '\rUsing TVB Connectome...'
317+
embedding_file = QtGui.QFileDialog.getOpenFileName(self,'Select file that contains locations of LSNM nodes', '.')
318+
319+
# display contents of file with locations of LSNM nodes with TVB connectome
320+
self.embeddingTextEdit.setText(embedding_file)
276321
else:
277322
useTVBConnectome = False
278323
print '\rNOT Using TVB Connectome...'
@@ -765,7 +810,7 @@ def run(self):
765810

766811
# run the simulation for the number of timesteps given
767812
print '\rRunning simulation...'
768-
813+
769814
if useTVBConnectome:
770815
# the following 'for loop' is the main loop of the TVB simulation with the parameters
771816
# defined above. Note that the LSNM simulator is literally embedded into the TVB

visual_model/learning.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ev4h exss
2+
ev4v exss
3+
ev4d exss

visual_model/lsnm_tvb_link.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
ev1v 345
2+
iv1v 345
3+
ev1h 345
4+
iv1h 345
5+
ev4v 393
6+
iv4v 393
7+
ev4c 393
8+
iv4c 393
9+
ev4h 393
10+
iv4h 393
11+
exss 413
12+
inss 413
13+
exfs 47
14+
infs 47
15+
efd1 74
16+
ifd1 74
17+
efd2 41
18+
ifd2 41
19+
exfr 125
20+
infr 125
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
* Simulation Start Time: Thu Jun 9 14:07:03 2016
2+
* Simulation End Time: Thu Jun 9 14:09:57 2016
3+
* Simulation duration (timesteps): 6600
4+
* Model description used:
5+
* Weights list used:
6+
* Neural net used: /Users/Antonio/Documents/NEURALBYTES/NIHPROJECT2/lsnm_in_python/visual_model/subject_12/output.test/neuralnet.json
7+
* Simulation script used: /Users/Antonio/Documents/NEURALBYTES/NIHPROJECT2/lsnm_in_python/visual_model/script_to_replicate_Horwitz_2005_Fig_3.py
8+
* Were weights changed to generate a new subject? NO
9+
* Was TVB Connectome used in the simulation? NO

visual_model/subject_12/output.test/neuralnet.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)