Skip to content

Commit

Permalink
enh: several improvements regarding metadata handling
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Jan 31, 2020
1 parent 60524bb commit c8b67c9
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 80 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
0.6.8
- setup: bump afmformats from 0.5.1 to 0.7.0 (improved metadata view
in info tab)
- setup: bump nanite from 1.4.1 to 1.5.1 (compatibility to afmformats)
- enh: fit results and parameter export dialog now supports new groups
in afmformats 0.7.0
- enh: autosave now only stores fit results and rating parameters
0.6.7
- setup: bump nanite from 1.4.0 to 1.4.1
(baseline is now a free parameter by default)
Expand Down
Binary file modified docs/scrots/ui_fd_tab_info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 16 additions & 10 deletions docs/sec_interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,8 @@ Tab: Info
The info tab shows metadata related to the currently shown curve.
Unknown values are indicated as *nan*.

Dataset:
All information related to the dataset on disk and of the curve
relative to this dataset.

Experiment:
All information on the actual experiment.

QMap:
If the curve is part of a quantiative map (2D FD scan), then
the scan grid properties and the curve position are listed.
Acquisition:
Settings of the acquisition software

Ancillaries:
Ancillary parameters are computed for each model. Here, the
Expand All @@ -189,6 +181,20 @@ Ancillaries:
the fitted curve has its maximum. Fit models may have their own
specific ancillary parameters.

Dataset:
Measurement parameters of the dataset

QMap:
If the curve is part of a quantiative map (2D FD scan), then
the scan grid properties and the curve position are listed.

Setup:
Information about the AFM setup used

Storage:
Information about the data file, which are not particularly important
for the experiment, but allow to identify a dataset or curve

.. _sec_ui_fd_tab_qmap:

Tab: QMap
Expand Down
4 changes: 3 additions & 1 deletion pyjibe/fd/dlg_export_vals.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ def done(self, r):
if not fname.endswith(".tsv"):
fname += ".tsv"
user_choices = {
"acquisition": self.checkBox_acquisition,
"dataset": self.checkBox_dataset,
"experiment": self.checkBox_experiment,
"qmap": self.checkBox_qmap,
"setup": self.checkBox_setup,
"storage": self.checkBox_storage,
"params_initial": self.checkBox_initial,
"params_fitted": self.checkBox_fitted,
"params_ancillary": self.checkBox_ancillary,
Expand Down
45 changes: 34 additions & 11 deletions pyjibe/fd/dlg_export_vals.ui
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,34 @@
<property name="title">
<string>Metadata</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QCheckBox" name="checkBox_qmap">
<property name="toolTip">
<string>Grid position, shape, etc. (if applicable)</string>
</property>
<property name="text">
<string>QMap</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox_acquisition">
<property name="toolTip">
<string>AFM acquisition settings</string>
</property>
<property name="text">
<string>Acquisition</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_dataset">
<property name="toolTip">
<string>Path, identifier, etc.</string>
<string>Dataset parameters</string>
</property>
<property name="text">
<string>Dataset</string>
Expand All @@ -40,23 +63,23 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_experiment">
<item row="0" column="1">
<widget class="QCheckBox" name="checkBox_setup">
<property name="toolTip">
<string>Duration, spring constant, etc.</string>
<string>AFM setup</string>
</property>
<property name="text">
<string>Experiment</string>
<string>Setup</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_qmap">
<item row="1" column="1">
<widget class="QCheckBox" name="checkBox_storage">
<property name="toolTip">
<string>Grid position, shape, etc. (if applicable)</string>
<string>File names, dates, ...</string>
</property>
<property name="text">
<string>QMap</string>
<string>Storage</string>
</property>
</widget>
</item>
Expand Down
38 changes: 19 additions & 19 deletions pyjibe/fd/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@
from .. import units

#: Valid export choices in `save_tsv_metadata_results`
EXPORT_CHOICES = [
"dataset",
"experiment",
EXPORT_CHOICES = list(meta.META_FIELDS.keys()) + [
"params_ancillary",
"params_fitted",
"params_initial",
"qmap",
"rating"]


Expand Down Expand Up @@ -69,25 +66,28 @@ def save_tsv_metadata_results(filename, fdist_list, which=EXPORT_CHOICES):
if "params_initial" in fdist.fit_properties:
fp = fdist.fit_properties["params_initial"]
for ki in fp:
label, hrvalue = get_unitname_value(
name=nmodel.get_parm_name(model_key, ki),
value=fp[ki].value,
unit=nmodel.get_parm_unit(model_key, ki))
if label not in columns:
columns[label] = [np.nan] * len(fdist_list)
columns[label][ii] = hrvalue

if not fp[ki].vary:
label, hrvalue = get_unitname_value(
name=nmodel.get_parm_name(model_key, ki),
value=fp[ki].value,
unit=nmodel.get_parm_unit(model_key, ki))
if label not in columns:
columns[label] = [np.nan] * len(fdist_list)
columns[label][ii] = hrvalue

# Fitted
if "params_fitted" in which:
if "params_fitted" in fdist.fit_properties:
fp = fdist.fit_properties["params_fitted"]
for ki in fp:
label, hrvalue = get_unitname_value(
name=nmodel.get_parm_name(model_key, ki),
value=fp[ki].value,
unit=nmodel.get_parm_unit(model_key, ki))
if label not in columns:
columns[label] = [np.nan] * len(fdist_list)
columns[label][ii] = hrvalue
if fp[ki].vary:
label, hrvalue = get_unitname_value(
name=nmodel.get_parm_name(model_key, ki),
value=fp[ki].value,
unit=nmodel.get_parm_unit(model_key, ki))
if label not in columns:
columns[label] = [np.nan] * len(fdist_list)
columns[label][ii] = hrvalue

# Additional fit parameters
props = {"xmin": ("Fit interval minimum", "m"),
Expand Down
5 changes: 3 additions & 2 deletions pyjibe/fd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ def autosave(self, fdist):
)
fname = os.path.join(adir, newbase)
# Export data
which = export.EXPORT_CHOICES.copy()
which.remove("params_ancillary")
which = ["params_fitted", "rating"]
export.save_tsv_metadata_results(filename=fname,
fdist_list=exp_curv,
which=which)
Expand Down Expand Up @@ -331,6 +330,8 @@ def on_curve_list(self):
self.tab_qmap.mpl_qmap_update()
# Display edelta
self.tab_edelta.mpl_edelta_update()
# Autosave
self.autosave(fdist)

def on_curve_list_item_changed(self, item):
"""An item in the curve list was changed
Expand Down
58 changes: 22 additions & 36 deletions pyjibe/fd/tab_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,54 +17,40 @@ def __init__(self, *args, **kwargs):
uic.loadUi(path_ui, self)

def update_info(self, fdist):
msum = fdist.metadata.get_summary()

text = []
hr_info = {}

# Dataset
text.append("<b>Dataset</b>")
for kk in msum["dataset"]:
text.append(get_string_rep_meta(kk, msum["dataset"][kk]))

# Experiment
text.append("")
text.append("<b>Experiment:</b>")
texte = []
for kk in msum["experiment"]:
texte.append(get_string_rep_meta(kk, msum["experiment"][kk]))
text += sorted(texte)

# QMap
if msum["qmap"] and not has_all_nans(msum["qmap"]):
text.append("")
text.append("<b>QMap:</b>")
textq = []
for kk in msum["qmap"]:
textq.append(get_string_rep_meta(kk, msum["qmap"][kk]))
text += sorted(textq)

# Analysis
if msum["analysis"] and not has_all_nans(msum["analysis"]):
text.append("")
text.append("<b>Analysis:</b>")
texta = []
for kk in msum["analysis"]:
texta.append(get_string_rep_meta(kk, msum["analysis"][kk]))
text += sorted(texta)
# Metadata
msum = fdist.metadata.get_summary()
for sec in msum:
if sec == "qmap":
if msum["qmap"] and not has_all_nans(msum["qmap"]):
textq = []
for kk in msum["qmap"]:
textq.append(get_string_rep_meta(kk, msum["qmap"][kk]))
hr_info["QMap"] = textq
else:
atext = []
for kk in msum[sec]:
atext.append(get_string_rep_meta(kk, msum[sec][kk]))
hr_info[sec.capitalize()] = atext

# Ancillaries
anc_dict = fdist.get_ancillary_parameters()
if anc_dict:
text.append("")
text.append("<b>Ancillaries:</b>")
text_meta = []
model_key = fdist.fit_properties["model_key"]
for kk in anc_dict:
text_meta.append(
get_string_rep(name=model.get_parm_name(model_key, kk),
value=anc_dict[kk],
unit=model.get_parm_unit(model_key, kk)))
text += sorted(text_meta)
hr_info["Ancillaries"] = text_meta

text = []
for sec in sorted(hr_info.keys()):
text.append("<b>{}:</b>".format(sec))
text += sorted(hr_info[sec])
text.append("")

textstring = "<br>".join(text)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
license="GPL v3",
description=description,
long_description=open('README.rst').read() if exists('README.rst') else '',
install_requires=["afmformats>=0.5.1",
install_requires=["afmformats>=0.7.0",
"appdirs",
"nanite>=1.4.1",
"matplotlib",
Expand Down

0 comments on commit c8b67c9

Please sign in to comment.