organoid_tracker.util.moving_average module
- class organoid_tracker.util.moving_average.LinesAverage(*lines: Tuple[List[float], List[float]], x_step_size: float = 1)
Bases:
PlotAverage
A moving average for a bunch of lines.
- count_values_at_min_max_x() Tuple[int, int]
Gets how many y values we have at the lowest and highest x positions.
- get_x_positions_and_means() Tuple[ndarray, ndarray]
Gets the x positions and the means at those x positions.
- plot(axes: ~matplotlib.axes._axes.Axes, *, color: ~organoid_tracker.core.Color = <organoid_tracker.core.Color object>, linewidth=2, error_opacity=0.8, standard_error: bool = False, label='Average')
Plots the moving average to the given axis. For example:
plot(plt.gca(), label=”My moving average”)
The error bar is either the standard deviation (if standard_error is False) or the standard error (if standard_error is True).
- class organoid_tracker.util.moving_average.MovingAverage(x_values: Union[List[float], ndarray], y_values: Union[List[float], ndarray], *, window_width: float, x_step_size: float = 1)
Bases:
PlotAverage
A moving average calculation for a point cloud. Usage example:
>>> import matplotlib.pyplot as plt >>> # Create and plot some sample data >>> x_values = [0, 0, 1, 2, 4, 6, 8] >>> y_values = [6, 8, 5, 3, 2, -1, -4] >>> plt.scatter(x_values, y_values) >>> >>> # Calculate and plot the moving average >>> average = MovingAverage(x_values, y_values, window_width=3) # Calculate with this window width >>> average.plot(plt.gca()) # Plot to the current axis (gca = get current axis) >>> plt.show()
- get_mean_at(x: float) Optional[float]
Gets the mean at the given x. Ignores the step size that was supplied for this object, so the mean is calculated exactly at the given point. Returns None if there is no data withing the averaging window.
- get_x_positions_and_means() Tuple[ndarray, ndarray]
Gets the x positions and the means at those x positions.
- plot(axes: ~matplotlib.axes._axes.Axes, *, color: ~organoid_tracker.core.Color = <organoid_tracker.core.Color object>, color_function: ~typing.Optional[~typing.Callable[[float], ~organoid_tracker.core.Color]] = None, linewidth=2, error_opacity=0.8, standard_error: bool = False, label='Moving average')
Color_function is a function x -> color, used to give the line different colors for different x.
- class organoid_tracker.util.moving_average.PlotAverage
Bases:
ABC
- abstract get_x_positions_and_means() Tuple[ndarray, ndarray]
Gets the x positions and the means at those x positions.
- abstract plot(axes: ~matplotlib.axes._axes.Axes, *, color: ~organoid_tracker.core.Color = <organoid_tracker.core.Color object>, linewidth=2, error_opacity=0.8, standard_error: bool = False, label='Moving average')
Plots the moving average to the given axis. For example:
plot(plt.gca(), label=”My moving average”)
The error bar is either the standard deviation (if standard_error is False) or the standard error (if standard_error is True).