-
Notifications
You must be signed in to change notification settings - Fork 0
/
input_patterns.py
36 lines (29 loc) · 1.01 KB
/
input_patterns.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
import os
from brian import *
from brian.library.ionic_currents import *
from brian.library.IF import *
import numpy as np
import random as pyrandom
def input_patterns(trial_i):
reinit(states = True)
clear(erase = True, all = True)
if not os.path.exists('input_patterns'):
os.makedirs('input_patterns')
os.chdir('input_patterns')
Trial = trial_i[0]
# Initial pattern
scale_fac = 2
if not os.path.exists('scale_'+str(scale_fac)):
os.makedirs('scale_'+str(scale_fac))
os.chdir('scale_'+str(scale_fac))
N_input = 100 * scale_fac
d_input = 0.10 # active input density
if not os.path.exists('d_input_'+str(d_input)):
os.makedirs('d_input_'+str(d_input))
os.chdir('d_input_'+str(d_input))
# Active pattern of neurons
active = sorted(pyrandom.sample(xrange(N_input), int(d_input*N_input)))
np.save('active_pattern_'+str(Trial)+'.npy', active)
return
jobidx = int(sys.argv[1])
results = input_patterns([jobidx]) # launches multiple processes