예제 #1
0
def produce_axon_growth_demo(id, targets, iterations_count):
    model = Model(name="testing_activity", targets=targets)
    t = time.time()
    for i in range(iterations_count):
        if i > 20:
            axon_indexes_to_fire = np.random.choice(len(targets), len(targets)/8)
            for index in axon_indexes_to_fire:
                model.axons[index].fire()
        model.iterate(write_to_disk=False)
        if i % 50 == 0:
            for axon in model.axons:
                output_directory = "../results/Plots/AxonGrowth/AXON-id=" + str(axon.id) + "-target=" + str(axon.target)
                if not os.path.exists(output_directory):
                    os.makedirs(output_directory)
                number = "%04d" % i
                plot_axon(axon, output_directory + "/" + number + ".png", 100.0, 100.0)
    print("Activity demo finished plotting for Axon " + str(id) + " in " + str(time.time() - t))
예제 #2
0
def produce_axon_growth_demo(id, targets, iterations_count):
    model = Model(name="testing_activity", targets=targets)
    t = time.time()
    for i in range(iterations_count):
        if i > 20:
            axon_indexes_to_fire = np.random.choice(len(targets),
                                                    len(targets) / 8)
            for index in axon_indexes_to_fire:
                model.axons[index].fire()
        model.iterate(write_to_disk=False)
        if i % 50 == 0:
            for axon in model.axons:
                output_directory = "../results/Plots/AxonGrowth/AXON-id=" + str(
                    axon.id) + "-target=" + str(axon.target)
                if not os.path.exists(output_directory):
                    os.makedirs(output_directory)
                number = "%04d" % i
                plot_axon(axon, output_directory + "/" + number + ".png",
                          100.0, 100.0)
    print("Activity demo finished plotting for Axon " + str(id) + " in " +
          str(time.time() - t))
예제 #3
0
파일: test_model.py 프로젝트: calben/retino
 def test_iterate(self):
     # model = Model(targets=[np.asarray([60.0, 50.0])])
     model = Model()
     # model = Model(postsynapticcells=[PostSynapticCell(1, size=100, origin=np.asarray([50.0, 50.0]))])
     for i in range(400):
         if i % 10 == 0:
             if i % 20 == 0:
                 activities_df = pd.DataFrame(0, index=np.arange(100), columns=np.arange(100))
                 activities_df.ix[i-5 % 1000:i+5 % 1000] = 1
                 model.iterate(plot_overview_to_disk=True, activities_df=activities_df)
             else:
                 model.iterate(plot_overview_to_disk=True)
         else:
             model.iterate(write_to_disk=False)
         print("Model Score", model.postsynapticcell_mapping_score)
     assert (len(model.axons[0].segments) > 1)
예제 #4
0
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import sys

from retino.model import Model
from retino.utils import *
from retino.postsynapticcell import PostSynapticCell

sys.setrecursionlimit(1500)

info = pd.DataFrame({"PSC Mapping Score": []})
info.index.name = "Iteration"

model = Model(targets=np.mgrid[30:81:5, 30:81:5].reshape(2, -1).T)
# model = Model()
# model = Model(postsynapticcells=[PostSynapticCell(1, size=100, origin=np.asarray(o)) for o in
#                                 np.mgrid[50:60:2, 50:60:2].reshape(2, -1).T])
for i in range(601):
    if i % 50 == 0:
        model.iterate(plot_overview_to_disk=True)
    elif i % 10 == 0:
        model.iterate(write_to_disk=False, plot_model_axons_to_disk=True)
    else:
        model.iterate(write_to_disk=False)
    info = info.append(pd.Series({
        "PSC Mapping Score": model.postsynapticcell_mapping_score,
        "Average Segments Per Axon": np.average(np.asarray([len(x.segments) for x in model.axons]))
    }, name=i))
    info.to_csv("models/" + model.timestamp + "/info.csv")
예제 #5
0
def generate_model(model_number, number_of_iterations):
    model = Model(name=str(model_number))
    model.iterate()
예제 #6
0
파일: test_model.py 프로젝트: calben/retino
 def test_default_targets(self):
     model = Model()
     print(model)
     assert (True)
예제 #7
0
파일: test_model.py 프로젝트: calben/retino
 def test_dump(self):
     model = Model()
     model.dump("model.pickle")
     with open("model.pickle", 'rb') as f:
         assert (len(pickle.load(f).axons) is retino.AXON_COUNT_SQRT ** 2)