Ejemplo n.º 1
0
    def add_stimulus(self, name: str, k: int) -> None:
        """ Initialize a random stimulus with 'k' neurons firing.
        This stimulus can later be applied to different areas of the brain,
        also updating its outgoing connectomes in the process.

        Connectomes to all areas is initialized as an empty numpy array.
        For every target area, which are all existing areas, set the plasticity coefficient,
        beta, to equal that area's beta.

        :param name: Name used to refer to stimulus
        :param k: Number of neurons in the stimulus
        """
        self.stimuli[name]: Stimulus = Stimulus(k)
        self.connectomes_init_stimulus(self.stimuli[name], name)
Ejemplo n.º 2
0
    def add_stimulus(self, name: str, k: int) -> None:
        """ Initialize a random stimulus with 'k' neurons firing.
        This stimulus can later be applied to different areas of the brain,
        also updating its outgoing connectomes in the process.

        Connectomes to all areas is initialized as an empty numpy array.
        For every target area, which are all existing areas, set the plasticity coefficient,
        beta, to equal that area's beta.

        :param name: Name used to refer to stimulus
        :param k: Number of neurons in the stimulus
        """
        self.stimuli[name]: Stimulus = Stimulus(k)

        # This should be replaced by conectomes_init_stimulus(self, self.areas[name], name).
        # (From here to the end of the function).
        new_connectomes: Dict[str, ndarray] = {}
        for key in self.areas:
            new_connectomes[key] = np.empty((0, 0))
            self.areas[key].stimulus_beta[name] = self.areas[key].beta
        self.stimuli_connectomes[name] = new_connectomes
Ejemplo n.º 3
0
def stimuli():
	stimuli_list = []
  	for i in range(math.random(100,300)):
		beta = math.random(0.05, 0.15)
		n = math.random(int(10e6), int(10e8))
      	areas_list.append(Stimulus(beta, n))
Ejemplo n.º 4
0
    return areas_list

@pytest.fixture
def area(request):
  	beta, n, k = request.param
    if beta is None:
  		beta = math.random(0.05, 0.15)
    if n is None:
  		n = math.random(int(10e6), int(10e8))
    if k is None:
        k = math.sqrt(n)
	return Area(beta, n, k)

@pytest.fixture
def stimuli():
	stimuli_list = []
  	for i in range(math.random(100,300)):
		beta = math.random(0.05, 0.15)
		n = math.random(int(10e6), int(10e8))
      	areas_list.append(Stimulus(beta, n))
    return stimuli_list
  
@pytest.fixture
def stimulus(request):
  	beta, n = request.param
    if beta is None:
  		beta = math.random(0.05, 0.15)
    if n is None:
  		n = math.random(int(10e6), int(10e8))
	return Stimulus(beta, n)
Ejemplo n.º 5
0
# Redirect console to logfile
Logger(base_path / 'log').__enter__()

# Protect RAM from program using up all memory
# Allows program to use only half of free memory
protecc_ram(0.75)

# Create graph for presenting the results
fig, ax = plt.subplots()
plt.title('Assemblies Merge')
ax.set_xscale('log')
plt.xlabel('t (Repeat Parameter)')
plt.ylabel('Overlap %')

# Create basic brain model
stimulus = Stimulus(STIMULUS_SIZE)
area1 = Area(AREA_SIZE)
area2 = Area(AREA_SIZE)
area3 = Area(AREA_SIZE)
area4 = Area(AREA_SIZE)
assembly1 = Assembly([stimulus], area1)
assembly2 = Assembly([stimulus], area2)

print(f"Writing simulation to {base_path}")
begin_time = time.time()
for merge_stabilization, repeats in TESTS:
    recipe = BrainRecipe(area1, area2, area3, area4, stimulus, assembly1,
                         assembly2)
    # Define assembly out of recipe,
    # that way merge can done manually!
    assembly3 = (assembly1 + assembly2) >> area3