Skip to content

Commit

Permalink
allows the user to use the secondary model when available
Browse files Browse the repository at this point in the history
Former-commit-id: 54e1ee1
  • Loading branch information
PolarBean committed Apr 27, 2023
1 parent cc21cee commit 9247fac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
3 changes: 3 additions & 0 deletions DeepSlice/coord_post_processing/angle_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 17 additions & 4 deletions DeepSlice/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 9247fac

Please sign in to comment.