diff --git a/derotation/analysis/incremental_derotation_pipeline.py b/derotation/analysis/incremental_derotation_pipeline.py index dc8aa728..c68b0801 100644 --- a/derotation/analysis/incremental_derotation_pipeline.py +++ b/derotation/analysis/incremental_derotation_pipeline.py @@ -14,7 +14,6 @@ import matplotlib.pyplot as plt import numpy as np -import pandas as pd from derotation.analysis.blob_detection import BlobDetection from derotation.analysis.fit_ellipse import ( @@ -40,8 +39,10 @@ def __init__(self, *args, **kwargs): """Initialize the IncrementalPipeline object.""" super().__init__(*args, **kwargs) - self.small_rotations = 10 - self.number_of_rotations = self.rot_deg // self.small_rotations + self.degrees_per_small_rotation = 10 + self.number_of_rotations = ( + self.rot_deg // self.degrees_per_small_rotation + ) def __call__(self): """Overwrite the ``__call__`` method from the parent class to derotate @@ -60,8 +61,6 @@ def __call__(self): self.save(self.masked_image_volume) self.save_csv_with_derotation_data() - self.center_of_rotation = self.find_center_of_rotation() - def create_signed_rotation_array(self) -> np.ndarray: logging.info("Creating signed rotation array...") rotation_on = np.zeros(self.total_clock_time) @@ -116,7 +115,9 @@ def adjust_rotation_increment(self) -> Tuple[np.ndarray, np.ndarray]: self.rot_blocks_idx["end"], ) ] - new_increments = [self.small_rotations / t for t in ticks_per_rotation] + new_increments = [ + self.degrees_per_small_rotation / t for t in ticks_per_rotation + ] logging.info(f"New increment example: {new_increments[0]:.3f}") @@ -257,34 +258,6 @@ def plot_rotation_speeds(self): # rotation pipeline pass - def save_csv_with_derotation_data(self): - """Saves a csv file with the rotation angles by line and frame, - and the rotation on signal. - It is saved in the saving folder specified in the config file. - """ - df = pd.DataFrame( - columns=[ - "frame", - "rotation_angle", - "clock", - ] - ) - - df["frame"] = np.arange(self.num_frames) - df["rotation_angle"] = self.rot_deg_frame[: self.num_frames] - df["clock"] = self.frame_start[: self.num_frames] - - Path(self.config["paths_write"]["derotated_tiff_folder"]).mkdir( - parents=True, exist_ok=True - ) - - df.to_csv( - self.config["paths_write"]["derotated_tiff_folder"] - + self.config["paths_write"]["saving_name"] - + ".csv", - index=False, - ) - ### ------- Methods unique to IncrementalPipeline ----------------- ### def find_center_of_rotation(self) -> Tuple[int, int]: diff --git a/derotation/config/load_config.py b/derotation/config/load_config.py index edd3709b..f76d7796 100644 --- a/derotation/config/load_config.py +++ b/derotation/config/load_config.py @@ -66,9 +66,7 @@ def update_config_paths( config["paths_write"]["logs_folder"] = str( Path(output_folder) / "derotation" / "logs" ) - config["paths_write"]["derotated_tiff_folder"] = str( - Path(output_folder) / "derotation/" - ) + config["paths_write"]["derotated_tiff_folder"] = str(Path(output_folder)) config["paths_write"]["saving_name"] = ( f"derotated{f'_{folder_suffix}' if folder_suffix else ''}" ) diff --git a/derotation/derotate_batch.py b/derotation/derotate_batch.py index db41820f..c3fe811d 100644 --- a/derotation/derotate_batch.py +++ b/derotation/derotate_batch.py @@ -51,7 +51,6 @@ def derotate( Exception If the pipeline fails. """ - # FULL DEROTATION PIPELINE # find tif and bin files bin_path = list(dataset_folder.rglob(glob_naming_pattern_bin))[0] tif_path = list(dataset_folder.rglob(glob_naming_pattern_tif))[0] @@ -67,7 +66,7 @@ def derotate( folder_suffix=folder_suffix, ) - logging.info("Running full derotation pipeline") + logging.info(f"Running {folder_suffix} derotation pipeline") # Run the pipeline try: @@ -77,7 +76,7 @@ def derotate( derotator = IncrementalPipeline(config) derotator() except Exception as e: - logging.error("Full derotation pipeline failed") + logging.error("Derotation pipeline failed") logging.error(e.args) logging.error(traceback.format_exc()) raise e