derotation.analysis.incremental_derotation_pipeline#
This module contains the IncrementalPipeline
class, which is a child of
the FullPipeline
class. It is used to derotate the image stack that was
acquired using the incremental rotation method. The class inherits all the
attributes and methods from the FullPipeline
class and adds additional
logic to register the images.
Methods that are not overwritten from the parent class are not documented
here.
Classes
|
Derotate the image stack that was acquired using the incremental rotation method. |
- class derotation.analysis.incremental_derotation_pipeline.IncrementalPipeline(*args, **kwargs)[source]#
Derotate the image stack that was acquired using the incremental rotation method.
As a child of
FullPipeline
, it inherits all the attributes and methods from it and adds additional logic to register the images. Here in the constructor we specify the degrees for each incremental rotation and the number of rotations.Methods
__call__
()Overwrite the
__call__
method from the parent class to derotate the image stack acquired using the incremental rotation method.add_circle_mask
(image_stack[, diameter])Adds a circular mask to the rotated image stack.
Overwrite the method from the parent class to adjust the rotation increment and the number of ticks per rotation.
calculate_angles_by_line_and_frame
()From the interpolated angles, it calculates the rotation angles by line and frame.
calculate_velocity
()Calculates the velocity of the rotation by line.
Check if the number of rotation angles by frame is equal to the number of frames in the image stack.
check_number_of_rotations
()Checks that the number of rotations is as expected.
check_rotation_number
(start, end)Checks that the number of rotations is as expected.
Checks that the number of rotations is as expected.
clock_to_latest_frame_start
(clock_time)Get the index of the frame that is being acquired at the given clock time.
clock_to_latest_line_start
(clock_time)Get the index of the line that is being scanned at the given clock time.
clock_to_latest_rotation_start
(clock_time)Get the index of the latest rotation that happened.
correct_start_and_end_rotation_signal
(start, end)Removes artifacts from the start and end times of the on periods of the rotation signal.
Reconstructs an array that has the same length as the full rotation signal.
derotate_frames_line_by_line
()Wrapper for the function
derotate_an_image_array_line_by_line
.drop_ticks_outside_of_rotation
()Drops the rotation ticks that are outside of the rotation periods.
Find the center of rotation by fitting an ellipse to the largest blob centers.
find_image_offset
(img)Find the "F0", also called "image offset" for a given image.
find_missing_rotation_on_periods
()Find the missing rotation on periods by looking at the rotation ticks and the rotation on signal.
find_optimal_parameters
()Finds the optimal parameters for the derotation.
find_rotation_peaks
()Finds the peaks of the rotation ticks signal using scipy.signal.find_peaks.
get_config
(config_name)Loads config file from derotation/config folder.
Overwrite the method from the parent class to interpolate the angles.
get_peaks_in_rotation
(start, end)Counts the number of ticks in a rotation given the start and end times of the rotation.
get_start_end_times_with_threshold
(signal, ...)Finds the start and end times of the on periods of the signal.
Overwrite the method from the parent class to check if the number of ticks is as expected.
load_data
()Loads data from the paths specified in the config file.
mean_image_for_each_rotation
(...)Calculates the mean image for each rotation and saves it in the
debug_plots
folder.plot_max_projection_with_center
(stack[, name])Plots the maximum projection of the image stack with the center of rotation.
Plots example rotation angles by line and frame for each speed.
plot_rotation_on_and_ticks
()Plots the rotation ticks and the rotation on signal.
Plots the velocity of the rotation for each speed.
process_analog_signals
()From the analog signals (frame clock, line clock, full rotation, rotation ticks) calculates the rotation angles by line and frame.
remove_artifacts_from_interpolated_angles
()Removes artifacts from the interpolated angles, coming from an inconsistency between the number of ticks and cumulative sum.
save
(masked)Saves the masked image stack in the saving folder specified in the config file.
save_csv_with_derotation_data
()Saves a csv file with the rotation angles by line and frame, and the rotation on signal.
set_optimal_center
()Checks if the optimal center of rotation is calculated.
start_logging
()Starts logging process using fancylog package.
- create_signed_rotation_array()[source]#
Reconstructs an array that has the same length as the full rotation signal. It is 0 when the motor is off, and it is 1 or -1 when the motor is on, depending on the direction of rotation. 1 is clockwise, -1 is counter clockwise. Uses the start and end times of the on periods of rotation signal, and the direction of rotation to reconstruct the array.
- Returns:
The rotation on signal.
- Return type:
np.ndarray
- is_number_of_ticks_correct()[source]#
Overwrite the method from the parent class to check if the number of ticks is as expected.
- Returns:
True if the number of ticks is as expected, False otherwise.
- Return type:
bool
- adjust_rotation_increment()[source]#
Overwrite the method from the parent class to adjust the rotation increment and the number of ticks per rotation.
- Returns:
The new rotation increment and the number of ticks per rotation.
- Return type:
Tuple[np.ndarray, np.ndarray]
- get_interpolated_angles()[source]#
Overwrite the method from the parent class to interpolate the angles.
- Returns:
The interpolated angles.
- Return type:
np.ndarray
- check_rotation_number_after_interpolation(start, end)[source]#
Checks that the number of rotations is as expected.
- Raises:
ValueError – if the number of start and end of rotations is different
ValueError – if the number of rotations is not as expected
- check_number_of_frame_angles()[source]#
Check if the number of rotation angles by frame is equal to the number of frames in the image stack.
- Raises:
ValueError – if the number of rotation angles by frame is not equal to the number of frames in the image stack.
- check_rotation_number(start, end)[source]#
Checks that the number of rotations is as expected.
- Raises:
ValueError – if the number of start and end of rotations is different
ValueError – if the number of rotations is not as expected
- plot_rotation_angles_and_velocity()[source]#
Plots example rotation angles by line and frame for each speed. This plot will be saved in the
debug_plots
folder. Please inspect it to check that the rotation angles are correctly calculated.
- plot_rotation_speeds()[source]#
Plots the velocity of the rotation for each speed. This plot will be saved in the
debug_plots
folder. Please inspect it to check that the velocity is correctly calculated.
- find_center_of_rotation()[source]#
Find the center of rotation by fitting an ellipse to the largest blob centers.
Step 1: Calculate the mean images for each rotation increment. Step 2: Find the blobs in the mean images. Step 3: Fit an ellipse to the largest blob centers and get its center.
- Returns:
The coordinates center of rotation (x, y).
- Return type:
Tuple[int, int]