Skip to content

Commit

Permalink
Simplify derotation by line
Browse files Browse the repository at this point in the history
  • Loading branch information
lauraporta committed Nov 3, 2023
1 parent 61ccb1e commit 3070708
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions derotation/analysis/derotation_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import matplotlib.pyplot as plt
import numpy as np
import numpy.ma as ma
import pandas as pd
import tifffile as tiff
import tqdm
Expand Down Expand Up @@ -790,31 +789,17 @@ def rotate_frames_line_by_line(self) -> np.ndarray:
image_with_only_line = np.zeros_like(img_with_new_lines)
image_with_only_line[line_counter] = line

# is the mask really useful if we rotate with order=0?
empty_image_mask = np.ones_like(img_with_new_lines)
empty_image_mask[line_counter] = 0

rotated_line = rotate(
image_with_only_line,
rotation,
reshape=False,
order=0,
mode="constant",
)
rotated_mask = rotate(
empty_image_mask,
rotation,
reshape=False,
order=0,
mode="constant",
)

# apply rotated mask to rotated line-image
masked = ma.masked_array(rotated_line, rotated_mask)

# substitute the non masked values in the new image
rotated_filled_image = np.where(
masked.mask, rotated_filled_image, masked.data
rotated_line == 0, rotated_filled_image, rotated_line
)
previous_image_completed = False
if (
Expand Down

0 comments on commit 3070708

Please sign in to comment.