def three_oscillator_unstimulated_list(): parameters = legion_parameters() parameters.teta = 0 # because no stmulated neighbors template_dynamic_legion(3, 2000, 200, conn_type.LIST_BIDIR, [0, 0, 0], parameters)
def testSyncEnsembleAllocationOneStimulatedOscillator(self): params = legion_parameters() params.teta = 0 # due to no neighbors LegionTestTemplates.templateSyncEnsembleAllocation([1], params, conn_type.NONE, 2000, 500, [[0]])
def testSyncEnsembleAllocationThreeMixStimulatedOscillators(self): parameters = legion_parameters() parameters.Wt = 4.0 self.templateSyncEnsembleAllocation([1, 0, 1], None, conn_type.LIST_BIDIR, 1500, 1500, [[0, 2], [1]])
def template_segmentation_image(image_file, parameters, steps, time, ccore_flag = True): image = read_image(image_file); stimulus = rgb2gray(image); for pixel_index in range(len(stimulus)): if (stimulus[pixel_index] < 235): stimulus[pixel_index] = 1; else: stimulus[pixel_index] = 0; if (parameters is None): parameters = legion_parameters(); net = legion_network(len(stimulus), parameters, conn_type.GRID_FOUR, ccore = ccore_flag); output_dynamic = net.simulate(steps, time, stimulus); ensembles = output_dynamic.allocate_sync_ensembles(); draw_image_mask_segments(image_file, ensembles); # draw_dynamics(output_dynamic.time, output_dynamic.output, x_title = "Time", y_title = "x(t)", separate = ensembles); # just for checking correctness of results - let's use classical algorithm dbscan_instance = dbscan(image, 3, 4, True); dbscan_instance.process(); trustable_clusters = dbscan_instance.get_clusters(); draw_dynamics(output_dynamic.time, output_dynamic.output, x_title = "Time", y_title = "x(t)", separate = trustable_clusters);
def simple_segmentation_example(): "Perfect results!" parameters = legion_parameters(); parameters.eps = 0.02; parameters.alpha = 0.005; parameters.betta = 0.1; parameters.gamma = 7.0; parameters.teta = 0.9; parameters.lamda = 0.1; parameters.teta_x = -0.5; parameters.teta_p = 7.0; parameters.Wz = 0.7; parameters.mu = 0.01; parameters.fi = 3.0; parameters.teta_xz = 0.1; parameters.teta_zx = 0.1; parameters.ENABLE_POTENTIONAL = False; template_dynamic_legion(81, 2500, 2500, conn_type = conn_type.GRID_FOUR, params = parameters, stimulus = [1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0], separate_repr = [ [0, 1, 2, 9, 10, 11, 18, 19, 20], [14, 15, 16, 17, 23, 24, 25, 26, 33, 34, 35, 42, 43, 44, 51, 52, 53], [45, 46, 47, 48, 54, 55, 56, 57, 63, 64, 65, 66, 72, 73, 74, 75] ]);
def thirteen_oscillator_three_stimulated_ensembles_list(): "Good example of three synchronous ensembels" "Not accurate due to false skipes are observed" parameters = legion_parameters(); parameters.Wt = 4.0; parameters.fi = 0.8; template_dynamic_legion(15, 1000, 1000, conn_type = conn_type.LIST_BIDIR, stimulus = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1], params = parameters, separate_repr = [ [0, 1, 2], [3, 4, 5, 9, 10], [6, 7, 8], [11, 12, 13, 14] ]);
def testUstimulatedOscillatorWithoutLateralPotential(self): params = legion_parameters(); params.teta = 0; # because no neighbors at all net = legion_network(1, type_conn = conn_type.NONE, parameters = params, ccore = False); dynamic = net.simulate(1000, 200, [0]); assert extract_number_oscillations(dynamic.output, amplitude_threshold = 0.0) == 0;
def sixteen_oscillator_two_stimulated_ensembles_grid(): "Not accurate false due to spikes are observed" parameters = legion_parameters(); parameters.teta_x = -1.1; template_dynamic_legion(16, 2000, 1500, conn_type = conn_type.GRID_FOUR, params = parameters, stimulus = [1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1]);
def testStimulatedOscillatorWithoutLateralPotential(self): params = legion_parameters(); params.teta = 0; # because no neighbors at all net = legion_network(1, [1], type_conn = conn_type.NONE, parameters = params); (t, x, z) = net.simulate(1000, 200); assert extract_number_oscillations(x) > 1;
def testStimulatedOscillatorWithoutLateralPotential(self): params = legion_parameters(); params.teta = 0; # because no neighbors at all net = legion_network(1, type_conn = conn_type.NONE, parameters = params, ccore = False); dynamic = net.simulate(2000, 400, [1]); assert extract_number_oscillations(dynamic.output) > 1;
def testUnstimulatedTwoOscillators(self): params = legion_parameters(); params.teta_p = 2.5; net = legion_network(2, [0, 0], type_conn = conn_type.LIST_BIDIR, parameters = params); (t, x, z) = net.simulate(1000, 1000); assert extract_number_oscillations(x, 0) == 1; assert extract_number_oscillations(x, 1) == 1;
def three_oscillator_mix_stimulated_list(): parameters = legion_parameters() parameters.Wt = 4.0 template_dynamic_legion(3, 1200, 1200, conn_type=conn_type.LIST_BIDIR, stimulus=[1, 0, 1], params=parameters)
def testUstimulatedOscillatorWithoutLateralPotential(self): params = legion_parameters() params.teta = 0 # because no neighbors at all net = legion_network(1, type_conn=conn_type.NONE, parameters=params) dynamic = net.simulate(1000, 200, [0]) assert extract_number_oscillations(dynamic.output) == 1
def testStimulatedOscillatorWithoutLateralPotential(self): params = legion_parameters() params.teta = 0 # because no neighbors at all net = legion_network(1, [1], type_conn=conn_type.NONE, parameters=params) (t, x, z) = net.simulate(1000, 200) assert extract_number_oscillations(x) > 1
def testUnstimulatedTwoOscillators(self): params = legion_parameters() params.teta_p = 2.5 net = legion_network(2, [0, 0], type_conn=conn_type.LIST_BIDIR, parameters=params) (t, x, z) = net.simulate(1000, 1000) assert extract_number_oscillations(x, 0) == 1 assert extract_number_oscillations(x, 1) == 1
def segmentation_image_simple1(): "Perfect" parameters = legion_parameters(); parameters.eps = 0.02; parameters.alpha = 0.005; parameters.betta = 0.1; parameters.gamma = 7.0; parameters.teta = 0.9; parameters.lamda = 0.1; parameters.teta_x = -0.5; parameters.teta_p = 7.0; parameters.Wz = 0.7; parameters.mu = 0.01; parameters.fi = 3.0; parameters.teta_xz = 0.1; parameters.teta_zx = 0.1; parameters.ENABLE_POTENTIONAL = False; template_segmentation_image(IMAGE_SIMPLE_SAMPLES.IMAGE_SIMPLE12, parameters, 2000, 2000, True);
def testOutputDynamicInformation(self): LegionTestTemplates.templateOutputDynamicInformation([1, 0, 1], legion_parameters(), conn_type.LIST_BIDIR, 100, 100, False);
def testSyncEnsembleAllocationThreeMixStimulatedOscillatorsByCore(self): parameters = legion_parameters(); parameters.Wt = 4.0; LegionTestTemplates.templateSyncEnsembleAllocation([1, 0, 1], None, conn_type.LIST_BIDIR, 1500, 1500, [[0, 2], [1]], True);
def testSyncEnsembleAllocationOneStimulatedOscillatorByCore(self): params = legion_parameters(); params.teta = 0; # due to no neighbors self.templateSyncEnsembleAllocation([1], params, conn_type.NONE, 2000, 500, [[0]], True);
def one_oscillator_stimulated(): parameters = legion_parameters() parameters.teta = 0 # because no neighbors at all template_dynamic_legion(1, 2000, 500, conn_type.NONE, [1], parameters)
def three_oscillator_mix_stimulated_list(): parameters = legion_parameters(); parameters.Wt = 4.0; template_dynamic_legion(3, 1500, 1500, conn_type = conn_type.LIST_BIDIR, stimulus = [1, 0, 1], params = parameters);
def three_oscillator_unstimulated_list(): parameters = legion_parameters(); parameters.teta = 0; # because no stmulated neighbors template_dynamic_legion(3, 2000, 200, conn_type = conn_type.LIST_BIDIR, params = parameters);
def one_oscillator_stimulated(): parameters = legion_parameters(); parameters.teta = 0; # because no neighbors at all template_dynamic_legion(1, 2000, 500, stimulus = [1], params = parameters);
def testOutputDynamicInformationByCore(self): LegionTestTemplates.templateOutputDynamicInformation( [1, 0, 1], legion_parameters(), conn_type.LIST_BIDIR, 100, 100, True)
def testSyncEnsembleAllocationOneStimulatedOscillator(self): params = legion_parameters(); params.teta = 0; # due to no neighbors LegionTestTemplates.templateSyncEnsembleAllocation([1], params, conn_type.NONE, 2000, 500, [[0]], False);
def one_oscillator_unstimulated(): parameters = legion_parameters(); parameters.teta = 0; # because no neighbors at all template_dynamic_legion(1, 2000, 500, conn_type.NONE, [0], parameters);
def testSyncEnsembleAllocationThreeMixStimulatedOscillators(self): parameters = legion_parameters(); parameters.Wt = 4.0; LegionTestTemplates.templateSyncEnsembleAllocation([1, 0, 1], None, conn_type.LIST_BIDIR, 1500, 1500, [[0, 2], [1]], False);