def check_neuron(neuron): """ Check the features of the neurons. Parameters: ----------- neuron: Neuron The neuron to be checked. Returns: warnings if some features are not correct. """ cor = 1 n = Neuron(input_file=get_swc_matrix(neuron), input_format='Matrix of swc without Node class') n.fit() list_features = neuron.features.keys() for f in range(len(list_features)): # if list_features[f] == 'curvature': # print(n.features[list_features[f]]) # print(neuron.features[list_features[f]]) # print(n.features[list_features[f]] - neuron.features[list_features[f]]) if len(n.features[list_features[f]]) - \ len(neuron.features[list_features[f]]) != 0: print("The size of feature " + list_features[f] + " is not calculated correctly.") cor = 0 else: a = n.features[list_features[f]] - neuron.features[ list_features[f]] if list_features[f] == 'branch_angle' or list_features[ f] == 'side_branch_angle': a = np.sort(n.features[list_features[f]], axis=0) - \ np.sort(neuron.features[list_features[f]], axis=0) a = a**2 # if list_features[f] == 'curvature': # print(n.features[list_features[f]]) # print(neuron.features[list_features[f]]) # print(a.sum()) if (a.sum() > 0.): print("The feature " + list_features[f] + " is not calculated correctly.") cor = 0
def read_file(self, input_format, input_file): if(input_format == 'Matrix of swc'): self.index = np.array([]) index = -1 for neuron in input_file: try: index += 1 m = subsample.fast_straigthen_subsample_swc(neuron, self.len_subsampling) n = Neuron(input_format=input_format, input_file=m) n.fit() self.index = np.append(self.index, index) self.database.append(n) print index except: print('ERROR IN:') print index if(input_format == 'Matrix of swc without Node class'): self.index = np.array([]) index = -1 for neuron in input_file: try: index += 1 m = subsample.fast_straigthen_subsample_swc(neuron, self.len_subsampling) n = Neuron(input_format=input_format, input_file=m) self.index = np.append(self.index, index) self.database.append(n) print index except: print('ERROR IN:') print index if(input_format == 'swc'): for neuron in input_file: n = Neuron(input_format=input_format, input_file=neuron) purne_n, dis = subsample.straight_subsample_with_fixed_number(n, self.n_subsampling) self.database.append(purne_n)