Ejemplo n.º 1
0
def six_oscillators_mix_3_stimulated():
    params = hhn_parameters()
    params.deltah = 400

    stimulus = [0, 0, 25, 25, 47, 47]
    template_dynamic_hhn(6, 1200, 600, stimulus, params, separate=True, ccore_flag=False)
    template_dynamic_hhn(6, 2400, 600, stimulus, params, separate=True, ccore_flag=True)
Ejemplo n.º 2
0
def six_oscillators_mix_3_stimulated():
    params = hhn_parameters();
    params.deltah = 400;

    stimulus = [0, 0, 25, 25, 47, 47];
    template_dynamic_hhn(6, 1200, 600, stimulus, params, separate=True, ccore_flag=False);
    template_dynamic_hhn(6, 2400, 600, stimulus, params, separate=True, ccore_flag=True);
Ejemplo n.º 3
0
def ten_oscillators_stimulated_partial_sync():
    params = hhn_parameters()
    params.w1 = 0.1
    params.w2 = 5.0
    params.w3 = 0

    template_dynamic_hhn(10, 750, 200, [25, 25, 25, 25, 25, 11, 11, 11, 11, 11], params, separate_representation=True)
Ejemplo n.º 4
0
def two_ensembles_80_oscillators():
    params = hhn_parameters()
    params.deltah = 650
    params.w1 = 0.1
    params.w2 = 9.0
    params.w3 = 5.0
    params.threshold = -10

    expected_ensembles = []
    stimulus = []

    base_stimulus = 10
    step_stimulus = 10
    amount_ensebles = 4
    region_size = 20
    for i in range(amount_ensebles):
        expected_ensembles += [[
            i for i in range(region_size * i, region_size * i + region_size)
        ]]
        stimulus += [base_stimulus + step_stimulus * i] * region_size

    template_dynamic_hhn(len(stimulus),
                         4000,
                         1000,
                         stimulus,
                         params,
                         separate=expected_ensembles,
                         ccore_flag=True)
Ejemplo n.º 5
0
def ten_oscillators_stimulated_sync():
    params = hhn_parameters();
    params.w1 = 0.1;
    params.w2 = 0.0;
    params.w3 = 0;
    
    template_dynamic_hhn(10, 750, 100, [25, 25, 25, 25, 25, 27, 27, 27, 27, 27], params, separate_representation = True);    
Ejemplo n.º 6
0
def ten_oscillators_stimulated_partial_sync():
    params = hhn_parameters();
    params.w1 = 0.1;
    params.w2 = 5.0;
    params.w3 = 0;
    
    template_dynamic_hhn(10, 750, 200, [25, 25, 25, 25, 25, 11, 11, 11, 11, 11], params, separate_representation = True);
Ejemplo n.º 7
0
def three_sync_ensembles():
    params = hhn_parameters();
    params.deltah = 400;

    stimulus = [25, 26, 25, 25, 26, 45, 46, 45, 44, 45, 65, 65, 65, 64, 66];
    separate = [ [0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14] ];
    num_osc = len(stimulus);
    template_dynamic_hhn(num_osc, 2400, 600, stimulus, params, separate=separate, ccore_flag=True);
Ejemplo n.º 8
0
def three_sync_ensembles():
    params = hhn_parameters();
    params.deltah = 400;

    stimulus = [25, 26, 25, 25, 26, 45, 46, 45, 44, 45, 65, 65, 65, 64, 66];
    separate = [ [0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14] ];
    num_osc = len(stimulus);
    template_dynamic_hhn(num_osc, 2400, 600, stimulus, params, separate=separate, ccore_flag=True);
Ejemplo n.º 9
0
def ten_oscillators_mix_stimulated():
    params = hhn_parameters()
    params.deltah = 400

    template_dynamic_hhn(6,
                         1200,
                         600, [0, 0, 25, 25, 47, 47],
                         params,
                         separate_representation=True)
Ejemplo n.º 10
0
def ten_oscillators_stimulated_partial_sync():
    params = hhn_parameters();
    params.w1 = 0.1;
    params.w2 = 5.0;
    params.w3 = 0;

    stimulus = [25, 25, 25, 25, 25, 11, 11, 11, 11, 11];
    template_dynamic_hhn(10, 750, 200, stimulus, params, separate=True, ccore_flag=False);
    template_dynamic_hhn(10, 750, 200, stimulus, params, separate=True, ccore_flag=True);
Ejemplo n.º 11
0
def ten_oscillators_stimulated_partial_sync():
    params = hhn_parameters();
    params.w1 = 0.1;
    params.w2 = 5.0;
    params.w3 = 0;

    stimulus = [25, 25, 25, 25, 25, 11, 11, 11, 11, 11];
    template_dynamic_hhn(10, 750, 200, stimulus, params, separate=True, ccore_flag=False);
    template_dynamic_hhn(10, 750, 200, stimulus, params, separate=True, ccore_flag=True);
Ejemplo n.º 12
0
def ten_oscillators_stimulated_sync():
    params = hhn_parameters()
    params.w1 = 0.1
    params.w2 = 0.0
    params.w3 = 0

    stumulus = [25, 25, 25, 25, 25, 27, 27, 27, 27, 27]

    template_dynamic_hhn(10, 750, 100, stumulus, params, separate=True, ccore_flag=False)
    template_dynamic_hhn(10, 750, 100, stumulus, params, separate=True, ccore_flag=True)
Ejemplo n.º 13
0
def ten_oscillators_stimulated_sync():
    params = hhn_parameters()
    params.w1 = 0.1
    params.w2 = 0.0
    params.w3 = 0

    template_dynamic_hhn(10,
                         750,
                         100, [25, 25, 25, 25, 25, 27, 27, 27, 27, 27],
                         params,
                         separate_representation=True)
Ejemplo n.º 14
0
def two_ensembles_80_oscillators():
    params = hhn_parameters();
    params.deltah = 650;
    params.w1 = 0.1;
    params.w2 = 9.0;
    params.w3 = 5.0;
    params.threshold = -10;
    
    expected_ensembles = [];
    stimulus = [];
    
    base_stimulus = 10;
    step_stimulus = 10;
    amount_ensebles = 4;
    region_size = 20;
    for i in range(amount_ensebles):
        expected_ensembles += [ [i for i in range(region_size * i, region_size * i + region_size)] ];
        stimulus += [ base_stimulus + step_stimulus * i ] * region_size;
    
    template_dynamic_hhn(len(stimulus), 4000, 1000, stimulus, params, separate=expected_ensembles, ccore_flag=True);
Ejemplo n.º 15
0
def six_oscillators_mix_2_stimulated():
    params = hhn_parameters();
    params.deltah = 400;
    
    template_dynamic_hhn(6, 1200, 600, [25, 25, 25, 47, 47, 47], params, separate_representation = True);
Ejemplo n.º 16
0
def template_image_segmentation(image_file, steps, time, dynamic_file_prefix):
    image = read_image(image_file);
    stimulus = rgb2gray(image);

    params = hhn_parameters();
    params.deltah = 650;
    params.w1 = 0.1;
    params.w2 = 9.0;
    params.w3 = 5.0;
    params.threshold = -10;

    stimulus = [255.0 - pixel for pixel in stimulus];
    divider = max(stimulus) / 50.0;
    stimulus = [int(pixel / divider) for pixel in stimulus];

    t, dyn_peripheral, dyn_central = None, None, None;

    if ( not os.path.exists(dynamic_file_prefix + 'dynamic_time.txt') or
         not os.path.exists(dynamic_file_prefix + 'dynamic_peripheral.txt') or
         not os.path.exists(dynamic_file_prefix + 'dynamic_dyn_central.txt') ):
        
        print("File with output dynamic is not found - simulation will be performed - it may take some time, be patient.");

        net = hhn_network(len(stimulus), stimulus, params, ccore=True);

        (t, dyn_peripheral, dyn_central) = net.simulate(steps, time);

        print("Store dynamic to save time for simulation next time.");

        with open(dynamic_file_prefix + 'dynamic_time.txt', 'wb') as file_descriptor:
            pickle.dump(t, file_descriptor);

        with open(dynamic_file_prefix + 'dynamic_peripheral.txt', 'wb') as file_descriptor:
            pickle.dump(dyn_peripheral, file_descriptor);

        with open(dynamic_file_prefix + 'dynamic_dyn_central.txt', 'wb') as file_descriptor:
            pickle.dump(dyn_central, file_descriptor);
    else:
        print("Load output dynamic from file.");
        
        with open (dynamic_file_prefix + 'dynamic_time.txt', 'rb') as file_descriptor:
            t = pickle.load(file_descriptor);

        with open (dynamic_file_prefix + 'dynamic_peripheral.txt', 'rb') as file_descriptor:
            dyn_peripheral = pickle.load(file_descriptor);

        with open (dynamic_file_prefix + 'dynamic_dyn_central.txt', 'rb') as file_descriptor:
            dyn_central = pickle.load(file_descriptor);

    animate_segmentation(t, dyn_peripheral, image_file, 200);

    # just for checking correctness of results - let's use classical algorithm
    if (False):
        dbscan_instance = dbscan(image, 3, 4, True);
        dbscan_instance.process();
        trustable_clusters = dbscan_instance.get_clusters();
    
        amount_canvases = len(trustable_clusters) + 2;
        visualizer = dynamic_visualizer(amount_canvases, x_title = "Time", y_title = "V", y_labels = False);
        visualizer.append_dynamics(t, dyn_peripheral, 0, trustable_clusters);
        visualizer.append_dynamics(t, dyn_central, amount_canvases - 2, True);
        visualizer.show();
Ejemplo n.º 17
0
def ten_oscillators_mix_stimulated():
    params = hhn_parameters()
    params.deltah = 400

    template_dynamic_hhn(6, 1200, 600, [0, 0, 25, 25, 47, 47], params, separate_representation=True)
Ejemplo n.º 18
0
def template_image_segmentation(image_file, steps, time, dynamic_file_prefix):
    image = read_image(image_file)
    stimulus = rgb2gray(image)

    params = hhn_parameters()
    params.deltah = 650
    params.w1 = 0.1
    params.w2 = 9.0
    params.w3 = 5.0
    params.threshold = -10

    stimulus = [255.0 - pixel for pixel in stimulus]
    divider = max(stimulus) / 50.0
    stimulus = [int(pixel / divider) for pixel in stimulus]

    t, dyn_peripheral, dyn_central = None, None, None

    if (not os.path.exists(dynamic_file_prefix + 'dynamic_time.txt') or
            not os.path.exists(dynamic_file_prefix + 'dynamic_peripheral.txt')
            or not os.path.exists(dynamic_file_prefix +
                                  'dynamic_dyn_central.txt')):

        print(
            "File with output dynamic is not found - simulation will be performed - it may take some time, be patient."
        )

        net = hhn_network(len(stimulus), stimulus, params, ccore=True)

        (t, dyn_peripheral, dyn_central) = net.simulate(steps, time)

        print("Store dynamic to save time for simulation next time.")

        with open(dynamic_file_prefix + 'dynamic_time.txt',
                  'wb') as file_descriptor:
            pickle.dump(t, file_descriptor)

        with open(dynamic_file_prefix + 'dynamic_peripheral.txt',
                  'wb') as file_descriptor:
            pickle.dump(dyn_peripheral, file_descriptor)

        with open(dynamic_file_prefix + 'dynamic_dyn_central.txt',
                  'wb') as file_descriptor:
            pickle.dump(dyn_central, file_descriptor)
    else:
        print("Load output dynamic from file.")

        with open(dynamic_file_prefix + 'dynamic_time.txt',
                  'rb') as file_descriptor:
            t = pickle.load(file_descriptor)

        with open(dynamic_file_prefix + 'dynamic_peripheral.txt',
                  'rb') as file_descriptor:
            dyn_peripheral = pickle.load(file_descriptor)

        with open(dynamic_file_prefix + 'dynamic_dyn_central.txt',
                  'rb') as file_descriptor:
            dyn_central = pickle.load(file_descriptor)

    animate_segmentation(t, dyn_peripheral, image_file, 200)

    # just for checking correctness of results - let's use classical algorithm
    if (False):
        dbscan_instance = dbscan(image, 3, 4, True)
        dbscan_instance.process()
        trustable_clusters = dbscan_instance.get_clusters()

        amount_canvases = len(trustable_clusters) + 2
        visualizer = dynamic_visualizer(amount_canvases,
                                        x_title="Time",
                                        y_title="V",
                                        y_labels=False)
        visualizer.append_dynamics(t, dyn_peripheral, 0, trustable_clusters)
        visualizer.append_dynamics(t, dyn_central, amount_canvases - 2, True)
        visualizer.show()
Ejemplo n.º 19
0
def six_oscillators_mix_2_stimulated():
    params = hhn_parameters();
    params.deltah = 400;
    
    template_dynamic_hhn(6, 1200, 600, [25, 25, 25, 47, 47, 47], params, separate_representation = True);