[med-svn] [SCM] aghermann branch, master, updated. 4f7a3b774136ffffbaf9b05d90bd568347bc5461
Andrei Zavada
johnhommer at gmail.com
Fri Nov 16 00:50:13 UTC 2012
The following commit has been merged in the master branch:
commit 0701b3697d50fc8be66b592bc1c3127d6a45de9d
Author: Andrei Zavada <johnhommer at gmail.com>
Date: Sun Oct 14 01:49:02 2012 +0300
extend, use SUIVarCollection in SF dialogs
diff --git a/src/sigproc/sigproc.hh b/src/sigproc/sigproc.hh
index 844e4cd..1d0c90c 100644
--- a/src/sigproc/sigproc.hh
+++ b/src/sigproc/sigproc.hh
@@ -122,13 +122,11 @@ dzcdf( const valarray<T>& in,
struct SPatternParamPack {
- unsigned short
- bwf_order;
- float bwf_cutoff;
- float dzcdf_step,
+ int bwf_order;
+ double bwf_cutoff;
+ double dzcdf_step,
dzcdf_sigma;
- unsigned short
- dzcdf_smooth,
+ int dzcdf_smooth,
env_tightness;
bool operator==( const SPatternParamPack& rv) const // cannot be defaulted!
{
diff --git a/src/ui/expdesign.hh b/src/ui/expdesign.hh
index 11558e8..153686a 100644
--- a/src/ui/expdesign.hh
+++ b/src/ui/expdesign.hh
@@ -284,7 +284,7 @@ class SExpDesignUI
// fft_params_saved; // members not represented in widgets as is
sigfile::SMCParamSet
mc_params_saved;
- SUICollection
+ SUIVarCollection
W_V;
// status bar bits
diff --git a/src/ui/scoring-facility-artifacts.cc b/src/ui/scoring-facility-artifacts.cc
index c90dd58..bfd1fdc 100644
--- a/src/ui/scoring-facility-artifacts.cc
+++ b/src/ui/scoring-facility-artifacts.cc
@@ -17,31 +17,28 @@
using namespace std;
-aghui::SScoringFacility::SChannel::SDetectArtifactsParams
-aghui::SScoringFacility::get_mc_params_from_SFAD_widgets() const
+aghui::SScoringFacility::SArtifactDetectionDialog::
+SArtifactDetectionDialog (aghui::SScoringFacility& p_)
+ : P (),
+ _p (p_)
{
- return SChannel::SDetectArtifactsParams {
- (float)gtk_spin_button_get_value( eSFADScope),
- (float)gtk_spin_button_get_value( eSFADUpperThr),
- (float)gtk_spin_button_get_value( eSFADLowerThr),
- (float)gtk_spin_button_get_value( eSFADF0),
- (float)gtk_spin_button_get_value( eSFADFc),
- (float)gtk_spin_button_get_value( eSFADBandwidth),
- (float)gtk_spin_button_get_value( eSFADMCGain),
- (float)gtk_spin_button_get_value( eSFADBackpolate),
-
- gtk_toggle_button_get_active( (GtkToggleButton*)eSFADEstimateE)
- ? INFINITY
- : (float)gtk_spin_button_get_value( eSFADEValue),
-
- (float)gtk_spin_button_get_value( eSFADHistRangeMin),
- (float)gtk_spin_button_get_value( eSFADHistRangeMax),
- (size_t)round(gtk_spin_button_get_value( eSFADHistBins)),
-
- (size_t)round(gtk_spin_button_get_value( eSFADSmoothSide)),
-
- (bool)gtk_toggle_button_get_active( (GtkToggleButton*)eSFADUseThisRange)
- };
+ W_V.reg( _p.eSFADScope, &P.scope);
+ W_V.reg( _p.eSFADUpperThr, &P.upper_thr);
+ W_V.reg( _p.eSFADLowerThr, &P.lower_thr);
+ W_V.reg( _p.eSFADF0, &P.f0);
+ W_V.reg( _p.eSFADFc, &P.fc);
+ W_V.reg( _p.eSFADBandwidth, &P.bandwidth);
+ W_V.reg( _p.eSFADMCGain, &P.mc_gain);
+ W_V.reg( _p.eSFADBackpolate, &P.iir_backpolate);
+ W_V.reg( _p.eSFADEstimateE, &P.estimate_e);
+ W_V.reg( _p.eSFADEValue, &P.E);
+ W_V.reg( _p.eSFADHistRangeMin, &P.dmin);
+ W_V.reg( _p.eSFADHistRangeMax, &P.dmax);
+ W_V.reg( _p.eSFADHistBins, (int*)&P.sssu_hist_size);
+ W_V.reg( _p.eSFADSmoothSide, (int*)&P.smooth_side);
+ W_V.reg( _p.eSFADUseThisRange, &P.use_range);
+
+ W_V.up();
}
// eof
diff --git a/src/ui/scoring-facility-artifacts_cb.cc b/src/ui/scoring-facility-artifacts_cb.cc
index 4450717..e827ff9 100644
--- a/src/ui/scoring-facility-artifacts_cb.cc
+++ b/src/ui/scoring-facility-artifacts_cb.cc
@@ -98,8 +98,7 @@ bSFADPreview_toggled_cb( GtkToggleButton *b, gpointer userdata)
if ( gtk_toggle_button_get_active(b) ) {
aghui::SBusyBlock bb (SF.wSFArtifactDetectionSetup);
SF.artifacts_backup = SF.using_channel->artifacts;
- SF.using_channel -> detect_artifacts(
- SF.get_mc_params_from_SFAD_widgets());
+ SF.using_channel -> detect_artifacts( (AD.W_V.down(), AD.P));
gtk_widget_set_sensitive( (GtkWidget*)SF.bSFADApply, TRUE);
if ( gtk_toggle_button_get_active( (GtkToggleButton*)SF.eSFADSingleChannelPreview) ) {
diff --git a/src/ui/scoring-facility-channel.cc b/src/ui/scoring-facility-channel.cc
index 23e794b..a01e9ed 100644
--- a/src/ui/scoring-facility-channel.cc
+++ b/src/ui/scoring-facility-channel.cc
@@ -340,7 +340,7 @@ calculate_dirty_percent()
void
aghui::SScoringFacility::SChannel::
-detect_artifacts( SDetectArtifactsParams P)
+detect_artifacts( SDetectArtifactsParamPack P)
{
auto sssu =
sigfile::CBinnedMC::do_sssu_reduction(
@@ -526,8 +526,8 @@ aghui::SScoringFacility::SChannel::
_put_selection()
{
if ( selection_end_time - selection_start_time > 1. ) {
- auto P =
- _p.get_mc_params_from_SFAD_widgets();
+ _p.artifact_detection_dialog.W_V.down();
+ auto& P = _p.artifact_detection_dialog.P;
auto sssu =
sigfile::CBinnedMC::do_sssu_reduction(
signal_filtered[ slice (selection_start, (selection_end - selection_start), 1) ],
diff --git a/src/ui/scoring-facility-patterns.cc b/src/ui/scoring-facility-patterns.cc
index 56f3538..f7d879b 100644
--- a/src/ui/scoring-facility-patterns.cc
+++ b/src/ui/scoring-facility-patterns.cc
@@ -35,6 +35,15 @@ SFindDialog (SScoringFacility& parent)
draw_details (true),
_p (parent)
{
+ W_V.reg( _p.ePatternEnvTightness, ¶ms.env_tightness);
+ W_V.reg( _p.ePatternFilterOrder, ¶ms.bwf_order);
+ W_V.reg( _p.ePatternFilterCutoff, ¶ms.bwf_cutoff);
+ W_V.reg( _p.ePatternDZCDFStep, ¶ms.dzcdf_step);
+ W_V.reg( _p.ePatternDZCDFSigma, ¶ms.dzcdf_sigma);
+ W_V.reg( _p.ePatternDZCDFSmooth, ¶ms.dzcdf_smooth);
+ W_V.reg( _p.ePatternParameterA, &tolerance_a);
+ W_V.reg( _p.ePatternParameterB, &tolerance_b);
+ W_V.reg( _p.ePatternParameterC, &tolerance_c);
}
aghui::SScoringFacility::SFindDialog::
@@ -256,7 +265,7 @@ load_pattern( const char *label, bool do_globally)
if ( fd ) {
size_t full_sample;
if ( fscanf( fd,
- "%hu %hu %g %g %g %hu %g %g %g\n"
+ "%u %u %lg %lg %lg %u %lg %lg %lg\n"
"%zu %zu %zu %zu\n",
¶ms.env_tightness,
¶ms.bwf_order, ¶ms.bwf_cutoff,
@@ -280,7 +289,7 @@ load_pattern( const char *label, bool do_globally)
}
display_scale = field_channel->signal_display_scale;
- update_displayed_parameters();
+ W_V.up();
set_pattern_da_width( full_sample / field_channel->spp());
} else
@@ -311,7 +320,6 @@ save_pattern( const char *label, bool do_globally)
}
FILE *fd = fopen( __buf__, "w");
if ( fd ) {
- //acquire_parameters();
fprintf( fd,
"%u %u %g %g %g %u %g %g %g\n"
"%zu %zu %zu %zu\n",
@@ -378,39 +386,6 @@ search( ssize_t from)
-void
-aghui::SScoringFacility::SFindDialog::
-acquire_parameters()
-{
- params.env_tightness = gtk_spin_button_get_value( _p.ePatternEnvTightness);
- params.bwf_order = gtk_spin_button_get_value( _p.ePatternFilterOrder);
- params.bwf_cutoff = gtk_spin_button_get_value( _p.ePatternFilterCutoff);
- params.dzcdf_step = gtk_spin_button_get_value( _p.ePatternDZCDFStep);
- params.dzcdf_sigma = gtk_spin_button_get_value( _p.ePatternDZCDFSigma);
- params.dzcdf_smooth = gtk_spin_button_get_value( _p.ePatternDZCDFSmooth);
-
- tolerance_a = gtk_spin_button_get_value( _p.ePatternParameterA);
- tolerance_b = gtk_spin_button_get_value( _p.ePatternParameterB);
- tolerance_c = gtk_spin_button_get_value( _p.ePatternParameterC);
-
- // field_channel is set immediately in the ePatternChannel_changed_cb()
-}
-
-void
-aghui::SScoringFacility::SFindDialog::
-update_displayed_parameters()
-{
- gtk_spin_button_set_value( _p.ePatternEnvTightness, params.env_tightness);
- gtk_spin_button_set_value( _p.ePatternFilterCutoff, params.bwf_cutoff );
- gtk_spin_button_set_value( _p.ePatternFilterOrder, params.bwf_order );
- gtk_spin_button_set_value( _p.ePatternDZCDFStep, params.dzcdf_step );
- gtk_spin_button_set_value( _p.ePatternDZCDFSigma, params.dzcdf_sigma );
- gtk_spin_button_set_value( _p.ePatternDZCDFSmooth, params.dzcdf_smooth );
-
- gtk_spin_button_set_value( _p.ePatternParameterA, tolerance_a );
- gtk_spin_button_set_value( _p.ePatternParameterB, tolerance_b );
- gtk_spin_button_set_value( _p.ePatternParameterC, tolerance_c );
-}
void
aghui::SScoringFacility::SFindDialog::
diff --git a/src/ui/scoring-facility-patterns_cb.cc b/src/ui/scoring-facility-patterns_cb.cc
index 79963ea..cefac58 100644
--- a/src/ui/scoring-facility-patterns_cb.cc
+++ b/src/ui/scoring-facility-patterns_cb.cc
@@ -28,7 +28,7 @@ daPatternSelection_draw_cb( GtkWidget *wid, cairo_t *cr, gpointer userdata)
{
auto& SF = *(SScoringFacility*)userdata;
auto& FD = SF.find_dialog;
- FD.acquire_parameters();
+ FD.W_V.down();
FD.draw( cr);
@@ -233,7 +233,7 @@ wPattern_show_cb( GtkWidget *widget, gpointer userdata)
auto& SF = *(SScoringFacility*)userdata;
auto& FD = SF.find_dialog;
- FD.update_displayed_parameters();
+ FD.W_V.up();
FD.enumerate_patterns_to_combo();
if ( FD._p.using_channel == NULL ) // not invoked for a preselected signal via a menu
diff --git a/src/ui/scoring-facility.cc b/src/ui/scoring-facility.cc
index 442d783..ef6b001 100644
--- a/src/ui/scoring-facility.cc
+++ b/src/ui/scoring-facility.cc
@@ -86,6 +86,7 @@ SScoringFacility (agh::CSubject& J,
find_dialog (*this),
filters_dialog (*this),
phasediff_dialog (*this),
+ artifact_detection_dialog (*this),
using_channel (nullptr),
da_ht (NAN) // bad value, to be estimated unless previously saved
{
diff --git a/src/ui/scoring-facility.hh b/src/ui/scoring-facility.hh
index 182e05c..ed9e890 100644
--- a/src/ui/scoring-facility.hh
+++ b/src/ui/scoring-facility.hh
@@ -23,6 +23,7 @@
#include "../expdesign/primaries.hh"
#include "../ica/ica.hh"
#include "globals.hh"
+#include "ui++.hh"
#include "expdesign.hh"
#include "scoring-facility-widgets.hh"
@@ -104,17 +105,27 @@ class SScoringFacility
// artifacts
float calculate_dirty_percent();
float percent_dirty;
- struct SDetectArtifactsParams {
- float scope,
+ struct SDetectArtifactsParamPack {
+ double scope,
upper_thr, lower_thr,
f0, fc, bandwidth,
mc_gain, iir_backpolate;
- float E, dmin, dmax;
+ double E, dmin, dmax;
size_t sssu_hist_size,
smooth_side;
- bool use_range:1;
+ bool estimate_e,
+ use_range;
+ SDetectArtifactsParamPack ()
+ : scope (4.),
+ upper_thr (9.), lower_thr (-9.),
+ f0 (1.), fc (1.8), bandwidth (1.5),
+ mc_gain (10.), iir_backpolate (.5),
+ E (4.), dmin (-10), dmax (20),
+ sssu_hist_size (100), smooth_side (0),
+ estimate_e (true), use_range (false)
+ {}
};
- void detect_artifacts( SDetectArtifactsParams);
+ void detect_artifacts( SDetectArtifactsParamPack);
// annotations
list<sigfile::SAnnotation*>
@@ -167,7 +178,7 @@ class SScoringFacility
struct SProfilePSD {
valarray<TFloat>
course; // can possibly live outside in core, no?
- float from, upto;
+ double from, upto;
double display_scale; // saved via libconfig, requiring it to be double
array<valarray<TFloat>, sigfile::TBand::_total>
course_in_bands;
@@ -509,7 +520,7 @@ class SScoringFacility
params,
params_saved;
- float tolerance_a,
+ double tolerance_a,
tolerance_b,
tolerance_c;
@@ -550,8 +561,8 @@ class SScoringFacility
void preselect_entry( const char*, bool globally);
void preselect_channel( const char*);
void enable_controls( bool);
- void acquire_parameters();
- void update_displayed_parameters();
+ SUIVarCollection
+ W_V;
float display_scale;
@@ -580,6 +591,9 @@ class SScoringFacility
: _p (parent)
{}
+ SUIVarCollection
+ W_V;
+
SScoringFacility&
_p;
};
@@ -589,6 +603,9 @@ class SScoringFacility
struct SPhasediffDialog {
DELETE_DEFAULT_METHODS (SPhasediffDialog);
+ SPhasediffDialog (SScoringFacility&);
+ ~SPhasediffDialog ();
+
const SChannel
*channel1,
*channel2;
@@ -611,23 +628,35 @@ class SScoringFacility
void draw( cairo_t* cr, int wd, int ht);
- SPhasediffDialog (SScoringFacility&);
- ~SPhasediffDialog ();
+ bool suspend_draw;
SScoringFacility&
_p;
-
- bool suspend_draw;
};
SPhasediffDialog
phasediff_dialog;
- // alternative way to do away with member proliferation
- SChannel::SDetectArtifactsParams
- get_mc_params_from_SFAD_widgets() const;
- sigfile::SArtifacts artifacts_backup;
- list<pair<SChannel*, bool>> channels_visible_backup;
- bool suppress_preview_handler;
+ // artifacts
+ struct SArtifactDetectionDialog {
+ DELETE_DEFAULT_METHODS (SArtifactDetectionDialog);
+
+ SArtifactDetectionDialog (SScoringFacility&);
+
+ SChannel::SDetectArtifactsParamPack
+ P;
+ sigfile::SArtifacts
+ artifacts_backup;
+ list<pair<SChannel*, bool>>
+ channels_visible_backup;
+ bool suppress_preview_handler;
+ SUIVarCollection
+ W_V;
+
+ SScoringFacility&
+ _p;
+ };
+ SArtifactDetectionDialog
+ artifact_detection_dialog;
// menu support
SChannel
diff --git a/src/ui/ui++.hh b/src/ui/ui++.hh
index c58e3ce..6485d27 100644
--- a/src/ui/ui++.hh
+++ b/src/ui/ui++.hh
@@ -123,15 +123,20 @@ template <> inline void
SUIVar_<GtkCheckButton, bool>::down() const { *v = gtk_toggle_button_get_active( (GtkToggleButton*)w); }
template <> inline void
+SUIVar_<GtkRadioButton, bool>::up() const { gtk_toggle_button_set_active( (GtkToggleButton*)w, *v); }
+template <> inline void
+SUIVar_<GtkRadioButton, bool>::down() const { *v = gtk_toggle_button_get_active( (GtkToggleButton*)w); }
+
+template <> inline void
SUIVar_<GtkEntry, string>::up() const { gtk_entry_set_text( w, v->c_str()); }
template <> inline void
SUIVar_<GtkEntry, string>::down() const { v->assign( gtk_entry_get_text( w)); }
-class SUICollection {
+class SUIVarCollection {
public:
- ~SUICollection ()
+ ~SUIVarCollection ()
{
for ( auto& A : c )
delete A;
@@ -153,6 +158,10 @@ class SUICollection {
{
c.push_back( new SUIVar_<GtkCheckButton, bool> (w, v));
}
+ void reg( GtkRadioButton *w, bool* v)
+ {
+ c.push_back( new SUIVar_<GtkRadioButton, bool> (w, v));
+ }
void reg( GtkEntry *w, string* v)
{
c.push_back( new SUIVar_<GtkEntry, string> (w, v));
--
Sleep experiment manager
More information about the debian-med-commit
mailing list