Skip to content

Commit

Permalink
add output_dir as argument to compute_plant_traits since h5s are …
Browse files Browse the repository at this point in the history
…optional
  • Loading branch information
eberrigan committed May 13, 2024
1 parent 2e9b41e commit dc79968
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sleap_roots/trait_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ def compute_plant_traits(
self,
plant: Series,
write_csv: bool = False,
output_dir: str = ".",
csv_suffix: str = ".traits.csv",
return_non_scalar: bool = False,
) -> pd.DataFrame:
Expand All @@ -338,6 +339,7 @@ def compute_plant_traits(
plant: The plant image series as a `Series` object.
write_csv: A boolean value. If True, it writes per plant detailed
CSVs with traits for every instance on every frame.
output_dir: The directory to write the CSV files to.
csv_suffix: If `write_csv` is `True`, a CSV file will be saved with the same
name as the plant's `{plant.series_name}{csv_suffix}`.
return_non_scalar: If `True`, return all non-scalar traits as well as the
Expand Down Expand Up @@ -373,7 +375,7 @@ def compute_plant_traits(
traits = pd.concat([plant_name, frame_idx, traits], axis=1)

if write_csv:
csv_name = Path(plant.h5_path).with_suffix(csv_suffix)
csv_name = Path(output_dir) / f"{plant.series_name}{csv_suffix}"
traits[["plant_name", "frame_idx"] + self.csv_traits].to_csv(
csv_name, index=False
)
Expand Down

0 comments on commit dc79968

Please sign in to comment.