Skip to content

Commit

Permalink
Adapt RGB to template
Browse files Browse the repository at this point in the history
  • Loading branch information
sevisal committed Dec 8, 2023
1 parent 0c403e3 commit a474399
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/vai_lab/DataProcessing/DataProcessing_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 19 additions & 2 deletions src/vai_lab/DataProcessing/plugins/RGBprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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')
Expand Down
32 changes: 30 additions & 2 deletions src/vai_lab/examples/xml_files/materialdesign_processing_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
</coordinates>
</Initialiser>
<DataProcessing name="Data Processing">
<plugin type="" />
<inputdata>
<X module="Initialiser" />
</inputdata>
Expand All @@ -19,9 +18,28 @@
<coordinates>
[(350.0, 350.0), 2, {0: 'd0-u2'}]
</coordinates>
<plugin type="RGBprocessing">
<options>
<folder>
.\examples\crystalDesign\20190606-R1-JT\BMP\RGB\Calibrated
</folder>
<compositions>
.\examples\crystalDesign\20190606-R1-JT\BMP\RGB\Calibrated\Samples.csv
</compositions>
</options>
<method type="fit">
<options />
</method>
<method type="transform">
<options>
<method>
area
</method>
</options>
</method>
</plugin>
</DataProcessing>
<Output name="Output">
<plugin type="" />
<inputdata>
<X module="Data Processing" />
</inputdata>
Expand All @@ -31,5 +49,15 @@
<coordinates>
[(350.0, 650), 1, {2: 'd2-u1'}]
</coordinates>
<plugin type="Output">
<options>
<outdata>
Data Processing
</outdata>
<outpath>
.\examples\results\output.pkl
</outpath>
</options>
</plugin>
</Output>
</pipeline>

0 comments on commit a474399

Please sign in to comment.