Skip to content

Commit

Permalink
Fix image save bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lauraporta committed Nov 11, 2024
1 parent 831ed71 commit ca67671
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions calcium_imaging_automation/core/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ def create_folders(self, dataset_names: List[str], session_number) -> None:
)

def get_dataset_path(self, dataset_name: str) -> Path:
print((self.output_path / "derivatives"))
return next(
(self.output_path / "derivatives").glob(f"*{dataset_name}*"), None
(self.output_path / "derivatives").glob(f"*{dataset_name}*")
)

def save_image(
Expand All @@ -50,5 +49,8 @@ def save_image(
filename: str,
) -> None:
path = self.get_dataset_path(dataset_name)
image = Image.fromarray(image)
image.save(path / f"ses-{session_number}" / f"{filename}-{run_id}")
image = Image.fromarray(image).convert("L")
image.save(
path / f"ses-{session_number}" / f"{filename}-{run_id}.png",
mode="PNG",
)

0 comments on commit ca67671

Please sign in to comment.