Skip to content

Commit

Permalink
fix: gmm limits don't go out of data bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
seankmartin committed Oct 16, 2024
1 parent f4c076f commit ae99495
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cryoet_data_portal_neuroglancer/precompute/contrast_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,14 @@ def compute_contrast_limit(
mean_to_use = means[closest_mean_index]
std_to_use = np.sqrt(variances[closest_mean_index])

return mean_to_use - low_variance_mult * std_to_use, mean_to_use + high_variance_mult * std_to_use
low_limit, high_limit = (
mean_to_use - low_variance_mult * std_to_use,
mean_to_use + high_variance_mult * std_to_use,
)
# Ensure that the limits are within the range of the volume
low_limit = float(max(low_limit, np.min(sample_data)))
high_limit = float(min(high_limit, np.max(sample_data)))
return low_limit, high_limit

def _objective_function(self, params):
return self.compute_contrast_limit(
Expand Down Expand Up @@ -648,6 +655,8 @@ def combined_contrast_limit_plot(
ax.axvline(limits[1], color=color)
custom_lines.append(Line2D([0], [0], color=color, lw=4))

min_x = min_x - 0.1 * (max_x - min_x)
max_x = max_x + 0.1 * (max_x - min_x)
ax.set_xlim(min_x, max_x)

# Produce a legend
Expand Down

0 comments on commit ae99495

Please sign in to comment.