-
Notifications
You must be signed in to change notification settings - Fork 0
/
spikingNetworkRun.py
executable file
·62 lines (53 loc) · 2.21 KB
/
spikingNetworkRun.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
#PROGRAM spikingNetworkRun.py
#10 July 2009, Nicholas Cain
#UW Department of Applied Mathematics under Dr. Eric Shea-Brown
import sys
import os
import time
import random
# Simulation settings:
trialRangeBegin=1 # trialRangeBegin - trialRangeEnd = Number of calls of the spikingNetwork.c file
trialRangeEnd=2
jobNameBase='crossStudy1' # Unique base-name for saving results and plots
dt = .02; # Time-step, in ms.
simDuration = 10000; # Simulation duration, in ms.
stimOnset = 10000; # Time for stimulus onset, in ms.
# Analysis settings:
analyze = 0;
analysisType='single'; # 'population' or 'single'
x_label = 'S1';
y_label = 'S1';
numberOfTrials = 10;
# Declare strings that vary between OS:
if sys.platform == 'darwin':
compileString='gcc -o spikingNetwork spikingNetwork.c'
matlabSettings = '-nosplash -nojvm -r'
runPrefix = './'
elif sys.platform == 'win32':
compileString='cl spikingNetwork.c'
matlabSettings = '-wait -automation -r'
runPrefix = ''
# Compile current build of spikingNetwork program:
print 'Beginning Run:'
print ' Compiling spikingNetwork.c ...'
os.system(compileString)
# Run Simulations, each time creating a data output file:
print ' Running Simulations ...'
tBegin=time.mktime(time.localtime())
for i in range(trialRangeBegin,trialRangeEnd + 1):
jobName=jobNameBase + '_' + str(i)
print ' Simulation # ' + str(i) + ' now running...'
os.system(runPrefix + 'spikingNetwork ' + str(simDuration/dt) + ' ' + str(stimOnset/dt) + ' ' + str(dt))
print ' Compiling results ...'
os.system('matlab ' + matlabSettings + ' "cd(\'' + os.getcwd() + '\'); getSpikes(\'' + jobName + '\',' + str(simDuration) + ',' + str(dt) + ');exit"')
# Find AIC for this trial:
if analyze == 1:
print ' Performing model comparison ...'
os.system('matlab ' + matlabSettings + ' "cd(\'' + os.getcwd() + '\'); spikeRateAnalysis(\'' + jobNameBase + '\'' + ',' + str(numberOfTrials) + ',' + str(stimOnset) + ',\'' + x_label + '\',\'' + y_label + '\',\'' + analysisType + '\',1);exit"')
else:
print ' Skipping model comparison'
# Finalize
tEnd = time.mktime(time.localtime())
secondsToCompute=tEnd-tBegin
print (' Total Computation Time: ', time.strftime("H:%H M:%M S:%S",time.gmtime(secondsToCompute)))