Skip to content

Commit

Permalink
Use the same diameter for masking when doing derotations one after th…
Browse files Browse the repository at this point in the history
…e other
  • Loading branch information
lauraporta committed Dec 12, 2023
1 parent 6702fef commit 418f339
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 3 additions & 1 deletion derotation/analysis/full_rotation_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
import logging
import sys
from pathlib import Path
Expand Down Expand Up @@ -57,7 +58,7 @@ def __call__(self):
self.contrast_enhancement()
self.process_analog_signals()
rotated_images = self.rotate_frames_line_by_line()
masked = self.add_circle_mask(rotated_images)
masked = self.add_circle_mask(rotated_images, self.mask_diameter)
self.save(masked)
self.save_csv_with_derotation_data()

Expand Down Expand Up @@ -127,6 +128,7 @@ def load_data(self):
self.num_frames = self.image_stack.shape[0]
self.num_lines_per_frame = self.image_stack.shape[1]
self.num_total_lines = self.num_frames * self.num_lines_per_frame
self.mask_diameter = copy.deepcopy(self.num_lines_per_frame)

self.direction, self.speed = read_randomized_stim_table(
self.config["paths_read"]["path_to_randperm"]
Expand Down
4 changes: 2 additions & 2 deletions derotation/analysis/incremental_rotation_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def __call__(self):
masked_unregistered, x_fitted, y_fitted
)

new_diameter = self.num_lines_per_frame - 2 * max(
self.new_diameter = self.num_lines_per_frame - 2 * max(
max(np.abs(shifts["x"])), max(np.abs(shifts["y"]))
)
masked = self.add_circle_mask(registered_images, new_diameter)
masked = self.add_circle_mask(registered_images, self.new_diameter)

self.save(masked)
self.save_csv_with_derotation_data()
Expand Down
14 changes: 11 additions & 3 deletions examples/derotation_slurm_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
IncrementalPipeline,
)

# =====================================================================
# Set up the config files
# =====================================================================

job_id = int(sys.argv[1:][0])
dataset_path = sys.argv[1:][1]
datasets = [path for path in os.listdir(dataset_path) if path.startswith("23")]
Expand All @@ -30,7 +34,6 @@
full_rotation_image = [file for file in image_files if "rotation_0" in file][0]
incremental_image = [file for file in image_files if "increment_0" in file][0]

# make debug_plots and logs and derotated folder in dataset
Path(f"{dataset_path}/{dataset}/debug_plots_incremental/").mkdir(
parents=True, exist_ok=True
)
Expand Down Expand Up @@ -78,8 +81,13 @@
yaml.dump(config, f)


derotate = IncrementalPipeline(f"incremental_rotation_{job_id}")
derotate()
# =====================================================================
# Run the pipeline
# =====================================================================

derotate_incremental = IncrementalPipeline(f"incremental_rotation_{job_id}")
derotate_incremental()

derotate_full = FullPipeline(f"full_rotation_{job_id}")
derotate_full.mask_diameter = derotate_incremental.new_diameter
derotate_full()

0 comments on commit 418f339

Please sign in to comment.