From 59bb62ea7a7d69c8aa96feef23126847423efac2 Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Sun, 28 Apr 2019 20:24:26 +0200 Subject: [PATCH] added descriptions for parmeters to output file --- ideas.md | 2 +- mtor/dataproc.py | 7 +++++++ mtor/parameters.py | 13 +++++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ideas.md b/ideas.md index ad679a6..57b5316 100644 --- a/ideas.md +++ b/ideas.md @@ -1,4 +1,4 @@ -Furhter Ideas: +Further Ideas: - color the roi - create a movie diff --git a/mtor/dataproc.py b/mtor/dataproc.py index 834abee..a80f67d 100644 --- a/mtor/dataproc.py +++ b/mtor/dataproc.py @@ -382,6 +382,13 @@ def save_data(data_frame, selected_df, extremas_df, parameters): k: [v] for k, v in parameters.items() if k not in ignore_parameters } tmp_setings_df = pandas.DataFrame(tmp_parameters).T + all_descriptions = parameters.get_descriptions() + matched_descritions = { + key: value + for key, value in all_descriptions.items() + if key in tmp_parameters + } + tmp_setings_df["Descriptions"] = pandas.Series(matched_descritions) tmp_setings_df.to_excel(writer, sheet_name="parameters") writer.save() diff --git a/mtor/parameters.py b/mtor/parameters.py index 06c36de..09baac7 100644 --- a/mtor/parameters.py +++ b/mtor/parameters.py @@ -8,7 +8,7 @@ from .commons import RE_DIGITS, OUTPUT_FOLDER_NAMES, TifImage class Parameters(dict): """ namespacing the parameters for a analysis with nice access - the following parameters are used: + parmeters used for analysing the images boost: linear factor for brightness on color coded images charts_y_limit: common scale for the y axis in graphs @@ -42,7 +42,7 @@ class Parameters(dict): right_guard_column: name of the most used left guard value column right_guard_name: right guard value group name roi_bottom: bottom edge of the ROI - roi_column: + roi_column: name for the ROI roi_left: bottom left of the ROI roi_name: roi value group name roi_right: bottom right of the ROI @@ -177,3 +177,12 @@ class Parameters(dict): self.cut_bottom = max(0, bottom + self.cut_pad_y) self.cut_right = min(self.image_width, right + self.cut_pad_x) self.cut_left = max(0, left - self.cut_pad_x) + + def get_descriptions(self): + docs = type(self).__doc__ + lines = (line.strip() for line in docs.split("\n")) + has_colon = (line for line in lines if ":" in line) + pairs = (line.split(":") for line in has_colon) + pairs_cleanup = ((k.strip(), v.strip()) for k, v in pairs) + non_empty = ((k, v) for k, v in pairs_cleanup if k and v) + return dict(non_empty)