From a474399985064f7aa29ab5be9c8c2a5f2fa29a54 Mon Sep 17 00:00:00 2001 From: Carlos Sevilla Salcedo Date: Fri, 8 Dec 2023 17:11:00 +0100 Subject: [PATCH] Adapt RGB to template --- .../DataProcessing/DataProcessing_core.py | 2 +- .../DataProcessing/plugins/RGBprocessing.py | 21 ++++++++++-- .../materialdesign_processing_demo.xml | 32 +++++++++++++++++-- 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/src/vai_lab/DataProcessing/DataProcessing_core.py b/src/vai_lab/DataProcessing/DataProcessing_core.py index 19d2c576..a963b44c 100644 --- a/src/vai_lab/DataProcessing/DataProcessing_core.py +++ b/src/vai_lab/DataProcessing/DataProcessing_core.py @@ -37,7 +37,7 @@ def launch(self) -> None: out = getattr(self._plugin, "{}".format(method))() self.output_data = self._data_in.copy() - if len(out) > 0 and (isinstance(out[0], DataFrame) or isinstance(out[0], array)): + if len(self._module_config["plugin"]["methods"]["_order"]) > 0 and len(out) > 0 and (isinstance(out[0], DataFrame) or isinstance(out[0], array)): self.output_data.data[list(out[1])[0]] = out[0] def get_result(self) -> DataInterface: diff --git a/src/vai_lab/DataProcessing/plugins/RGBprocessing.py b/src/vai_lab/DataProcessing/plugins/RGBprocessing.py index 46d0fac3..23471e13 100644 --- a/src/vai_lab/DataProcessing/plugins/RGBprocessing.py +++ b/src/vai_lab/DataProcessing/plugins/RGBprocessing.py @@ -11,6 +11,7 @@ from scipy.integrate import simps import numpy as np from vai_lab._plugin_templates import DataProcessingT +from vai_lab._import_helper import rel_to_abs _PLUGIN_READABLE_NAMES = {"RGBprocessing": "default", "rgbprocessing": "alias",} # type:ignore @@ -64,7 +65,23 @@ def __init__(self, folder, compositions, cutoff = None, is_calibrated = True, is else: filenames = ['sample_Ll.csv', 'sample_La.csv', 'sample_Lb.csv'] - os.chdir(folder) + if type(compositions) is str: + if os.path.isabs(compositions): + try: + compositions = pd.read_csv(compositions).get("Sample") + except Exception as exc: + print('The plugin encountered an error trying to read the provided path to compositions: \"' + +compositions+'\"') + raise + else: + try: + compositions = pd.read_csv(rel_to_abs(compositions)).get("Sample") + except Exception as exc: + print('The plugin encountered an error trying to read the provided path to compositions: \"' + +compositions+'\"') + raise + + os.chdir(rel_to_abs(folder)) self.compositions = compositions compositions = pd.Series(compositions) @@ -89,7 +106,7 @@ def __init__(self, folder, compositions, cutoff = None, is_calibrated = True, is self.green = self.green.iloc[:self.time.shape[0],:] def preprocess(self, normalize = None): - time_col = pd.DataFrame(pd.np.tile(self.time.values, (self.red.shape[1], 1))) + time_col = pd.DataFrame(np.tile(self.time.values, (self.red.shape[1], 1))) red = self.red.melt(var_name='columns') green = self.green.melt(var_name='columns') blue = self.blue.melt(var_name='columns') diff --git a/src/vai_lab/examples/xml_files/materialdesign_processing_demo.xml b/src/vai_lab/examples/xml_files/materialdesign_processing_demo.xml index fc4c5ea9..98324e48 100644 --- a/src/vai_lab/examples/xml_files/materialdesign_processing_demo.xml +++ b/src/vai_lab/examples/xml_files/materialdesign_processing_demo.xml @@ -8,7 +8,6 @@ - @@ -19,9 +18,28 @@ [(350.0, 350.0), 2, {0: 'd0-u2'}] + + + + .\examples\crystalDesign\20190606-R1-JT\BMP\RGB\Calibrated + + + .\examples\crystalDesign\20190606-R1-JT\BMP\RGB\Calibrated\Samples.csv + + + + + + + + + area + + + + - @@ -31,5 +49,15 @@ [(350.0, 650), 1, {2: 'd2-u1'}] + + + + Data Processing + + + .\examples\results\output.pkl + + +