Skip to content

Commit

Permalink
Add script to create plots from sample video
Browse files Browse the repository at this point in the history
  • Loading branch information
lauraporta committed Feb 21, 2024
1 parent 45fe6cf commit a4e43df
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions examples/create_plots_for_sample_video.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import tifffile as tiff

data_folder = Path("/Users/lauraporta/local_data/rotation/230822_CAA_1120509/")
original_tiff_path = data_folder / "imaging/rotation_00001_ce.tif"
derotated_tiff_path = data_folder / "derotated_image_stack_full.tif"
derotated_csv_path = data_folder / "derotated_image_stack_full.csv"
frames_to_save_path = data_folder / "frames/"

original_tiff = tiff.imread(original_tiff_path)
derotated_tiff = tiff.imread(derotated_tiff_path)
df = pd.read_csv(derotated_csv_path)
time_subset = np.arange(435, 510)

df = df.iloc[time_subset]

angle = df["rotation_angle"].values


for i, t in enumerate(time_subset):
ax1 = plt.subplot(221)
ax1.set_title("Original image")
ax1.imshow(original_tiff[t], cmap="gray")
ax1.axis("off")

ax2 = plt.subplot(222)
ax2.set_title("Derotated image")
ax2.imshow(derotated_tiff[t], cmap="gray")
ax2.axis("off")

ax3 = plt.subplot(212)
ax3.set_title("Rotation angle")
ax3.scatter(np.arange(0, len(angle)), angle, s=1)
ax3.set_xlabel("Time")
ax3.set_ylabel("Angle (degrees)")
ax3.axvline(x=i, color="r", linestyle="--")

plt.savefig(
frames_to_save_path / f"frame_{i}.png", bbox_inches="tight", dpi=200
)
plt.close()

0 comments on commit a4e43df

Please sign in to comment.