diff --git a/DeepSlice/coord_post_processing/angle_methods.py b/DeepSlice/coord_post_processing/angle_methods.py index b805b41..9bc0fb1 100644 --- a/DeepSlice/coord_post_processing/angle_methods.py +++ b/DeepSlice/coord_post_processing/angle_methods.py @@ -85,6 +85,9 @@ def get_mean_angle(DV_list, ML_list, method, depths=None, species=None): weighted_accuracy = plane_alignment.make_gaussian_weights(max) else: weighted_accuracy = [1.0] * len(df_center) + df_center = np.array(df_center) + df_center[df_center < min] = min + df_center[df_center > max] = max-1 weighted_accuracy = [weighted_accuracy[int(y)] for y in df_center] print(weighted_accuracy) DV_angle = np.average(DV_list, weights=weighted_accuracy) diff --git a/DeepSlice/main.py b/DeepSlice/main.py index 419e0c1..581b4ae 100644 --- a/DeepSlice/main.py +++ b/DeepSlice/main.py @@ -28,7 +28,8 @@ def predict( ensemble: bool = None, section_numbers: bool = True, legacy_section_numbers=False, - image_list = None + image_list = None, + use_secondary_model = False, ): """predicts the atlas position for a folder full of histological brain sections @@ -66,10 +67,22 @@ def predict( if secondary_weights == "None": print(f"ensemble is not available for {self.species}") + if use_secondary_model: + print("WARNING: use_secondary_model is set but no secondary model is available. use_secondary_model will be ignored.") + use_secondary_model = False ensemble = False - predictions = neural_network.predictions_util( - self.model, image_generator, primary_weights, secondary_weights, ensemble - ) + if use_secondary_model and ensemble: + print("WARNING: use_secondary_model is set but ensemble is also set. use_secondary_model will be ignored.") + use_secondary_model = False + if use_secondary_model: + print("Using secondary model") + predictions = neural_network.predictions_util( + self.model, image_generator, secondary_weights,None, ensemble + ) + else: + predictions = neural_network.predictions_util( + self.model, image_generator, primary_weights, secondary_weights, ensemble + ) predictions["width"] = width predictions["height"] = height if section_numbers: