derotation.analysis.bayesian_optimization#

Bayesian optimization to find the best center of rotation. It optimizes the center of rotation by running first the entire derotation process and then calculating the point to point distance of the most detected blob in the mean images, calculated at angle steps of 10 degrees.

Steps in the optimization:
  • Derotate the movie.

  • Calculate the mean images.

  • Calculate the point to point distance of the most detected blob.

  • Return the negative of the point to point distance as the metric to maximize.

The call to ptd_of_most_detected_blob can output debugging plots.

The optimization is done using the BayesianOptimization class from the bayes_opt library. The results of the optimization are printed to the console.

Classes

BO_for_derotation(movie, rot_deg_line, ...)

Bayesian optimization to find the best center of rotation.

class derotation.analysis.bayesian_optimization.BO_for_derotation(movie, rot_deg_line, rot_deg_frame, blank_pixels_value, center, delta, init_points=2, n_iter=10, debug_plots_folder=PosixPath('debug_plots'))[source]#

Bayesian optimization to find the best center of rotation.

Parameters:
  • movie (np.ndarray) – The calcium imaging movie to derotate.

  • rot_deg_line (np.ndarray) – The rotation angles of the rotation plane.

  • rot_deg_frame (np.ndarray) – The rotation angles of the frames.

  • blank_pixels_value (float) – The value of the blank pixels.

  • center (Tuple[int, int]) – The initial center of rotation.

  • delta (int) – The variation allowed in the boundaries of the center of rotation.

  • init_points (int, optional) – The number of initial points to evaluate, by default 2

  • n_iter (int, optional) – The number of iterations to run the optimization, by default 10

  • debug_plots_folder (Path, optional) – The folder to save the debugging plots, by default Path(“./debug_plots”)

Methods

optimize()

Optimize the center of rotation.

optimize()[source]#

Optimize the center of rotation.