def set_hypotheses(head, config): # Formulate a VEP hypothesis manually hyp_builder = HypothesisBuilder(head.connectivity.number_of_regions, config) # .set_normalize(0.99) # Regions of Pathological Excitability hypothesis: x0_indices = [2, 24] x0_values = [0.01, 0.01] hyp_builder.set_x0_hypothesis(x0_indices, x0_values) # Regions of Model Epileptogenicity hypothesis: e_indices = [1, 26] # e_indices = list(range(head.connectivity.number_of_regions)) # e_indices.remove(2) # e_indices.remove(25) # e_values = np.zeros((head.connectivity.number_of_regions,)) + 0.01 # e_values[[1, 26]] = 0.99 # e_values = np.delete(e_values, [2, 25]).tolist() e_values = np.array([1.5, 1.25]) # np.array([0.99] * 2) hyp_builder.set_e_hypothesis(e_indices, e_values) # Regions of Connectivity hypothesis: # w_indices = [] # [(0, 1), (0, 2)] # w_values = [] # [0.5, 2.0] # hypo_builder.set_w_indices(w_indices).set_w_values(w_values) hypothesis1 = hyp_builder.build_hypothesis() e_indices = [1, 26] # [1, 2, 25, 26] hypothesis2 = hyp_builder.build_hypothesis_from_file( "clinical_hypothesis_postseeg", e_indices) # Change something manually if necessary # hypothesis2.x0_values = [0.01, 0.01] return (hypothesis1, hypothesis2)
def test_read_hypothesis(self): test_file = os.path.join(self.config.out.FOLDER_TEMP, "TestHypothesis.h5") hypothesis_builder = HypothesisBuilder(3, self.config) dummy_hypothesis = hypothesis_builder.set_e_hypothesis( [0], [0.6]).build_hypothesis() self.writer.write_hypothesis(dummy_hypothesis, test_file) hypothesis = self.reader.read_hypothesis(test_file) assert dummy_hypothesis.number_of_regions == hypothesis.number_of_regions assert numpy.array_equal(dummy_hypothesis.x0_values, hypothesis.x0_values) assert dummy_hypothesis.x0_indices == hypothesis.x0_indices assert numpy.array_equal(dummy_hypothesis.e_values, hypothesis.e_values) assert dummy_hypothesis.e_indices == hypothesis.e_indices assert numpy.array_equal(dummy_hypothesis.w_values, hypothesis.w_values) assert dummy_hypothesis.w_indices == hypothesis.w_indices assert numpy.array_equal(dummy_hypothesis.lsa_propagation_indices, hypothesis.lsa_propagation_indices) if len(dummy_hypothesis.lsa_propagation_indices) == 0: assert numpy.array_equal([0, 0, 0], hypothesis.lsa_propagation_strengths) else: assert numpy.array_equal( dummy_hypothesis.lsa_propagation_strengths, hypothesis.lsa_propagation_strengths)