From c6fb7821a0153258381243ab7c9399da7f19bca1 Mon Sep 17 00:00:00 2001 From: "PRADEEP\\Pradeep" Date: Mon, 15 Jan 2024 23:07:37 +1100 Subject: [PATCH] added function to return csv filepath --- core/lls_core/models/output.py | 13 +++++++++++-- core/lls_core/models/results.py | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core/lls_core/models/output.py b/core/lls_core/models/output.py index 2f7b127e..94d8a794 100644 --- a/core/lls_core/models/output.py +++ b/core/lls_core/models/output.py @@ -1,8 +1,8 @@ from pydantic import Field, DirectoryPath, validator from strenum import StrEnum from pathlib import Path -from typing import TYPE_CHECKING - +from typing import TYPE_CHECKING, Union +from pandas import DataFrame from lls_core.models.utils import FieldAccessModel, enum_choices if TYPE_CHECKING: @@ -65,3 +65,12 @@ def make_filepath(self, suffix: str) -> Path: Returns a filepath for the resulting data """ return self.save_dir / Path(self.save_name + suffix).with_suffix("." + self.file_extension) + + def make_filepath_df(self, suffix: str,result:Union[DataFrame,list]) -> Path: + """ + Returns a filepath for the non-image data + """ + if isinstance(result, DataFrame): + return self.save_dir / Path(self.save_name + suffix).with_suffix(".csv") + + return diff --git a/core/lls_core/models/results.py b/core/lls_core/models/results.py index 213c655c..68dcc62e 100644 --- a/core/lls_core/models/results.py +++ b/core/lls_core/models/results.py @@ -135,7 +135,7 @@ def save(self) -> Iterable[Path]: """ for roi, result in self.process(): if isinstance(result, DataFrame): - path = self.lattice_data.make_filepath(make_filename_prefix(roi_index=roi)) + path = self.lattice_data.make_filepath_df(make_filename_prefix(roi_index=roi),result) result.to_csv(str(path)) yield path else: