Skip to content

Commit

Permalink
tweaks for l1
Browse files Browse the repository at this point in the history
  • Loading branch information
remnrem committed Aug 9, 2024
1 parent 31446cf commit 9ee871d
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 16 deletions.
57 changes: 47 additions & 10 deletions eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1443,26 +1443,63 @@ void proc_lzw( edf_t & edf , param_t & param )
void proc_self_suds( edf_t & edf , param_t & param )
{

// set options
suds_t::set_options( param );
// two modes:
// - if using the default model, and multiple signals, run once
// for each
// - otherwise, force signal

// if multiple channels specified, run once for each
signal_list_t signals = edf.header.signal_list( param.value( "sig" ) );

if ( signals.size() == 0 )
Helper::halt( "no signals found matching " + param.value( "sig" ) );

// force a reload (used in moonlight/R mode)
if ( param.has( "force-reload" ) )
suds_t::model.init();

// load model, if not already done
// or, in R mode, force load each time...

if ( ! suds_t::model.loaded() )
// set options
suds_t::set_options( param );

const int ns = signals.size();

for (int s=0; s<ns; s++)
{

if ( edf.header.is_annotation_channel( signals(s) ) ) continue;

logger << " ------------------------------------------------------------\n"
<< " fitting SOAP model for single channel " << signals.label(s) << "\n";

writer.level( signals.label(s) , globals::signal_strat );

// force reload either way
suds_t::model.init();

// load model, if not already done
// or, in R mode, force load each time...
// if ( ! suds_t::model.loaded() )
// {

// suds_t::model.read( param.has( "model" ) ? param.value( "model" ) : "_1" ,
// param.has( "read-weights" ) ? param.value( "read-weights" ) : "" ,
// param.has( "write-weights" ) ? param.value( "write-weights" ) : "" ,
// param.has( "sig" ) && param.value( "sig" ) != "*" ? param.value( "sig") : "C4_M1" ) ;

suds_t::model.read( param.has( "model" ) ? param.value( "model" ) : "_1" ,
param.has( "read-weights" ) ? param.value( "read-weights" ) : "" ,
param.has( "write-weights" ) ? param.value( "write-weights" ) : "" ,
param.has( "sig" ) && param.value( "sig" ) != "*" ? param.value( "sig") : "C4_M1" ) ;
signals.label(s) );

suds_indiv_t self;

self.evaluate( edf , param );

// next channel
}
suds_indiv_t self;
self.evaluate( edf , param );

writer.unlevel( globals::signal_strat );

}


Expand Down
22 changes: 21 additions & 1 deletion miscmath/qdynam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ void qdynam_t::proc_all()
{

logger << " running dynam submodule for " << osequences.size() << " distinct strata\n";

// save current fac/lvl state so we can return to it
// i.e. here we will iterate over different faclvls (as saved in osequences)
// and so we have to level()/unlevel() each;

// but we don't want to unlevel any faclvl that was still present at the start of this
// call (e.g. if a TAG was set); thus save these now to make sure we can return
// everything as expected at the end

std::map<std::string,std::string> curr_faclvl = writer.faclvl_notime();

// iterate over each fac/lvl/var in the store

Expand Down Expand Up @@ -355,7 +365,17 @@ void qdynam_t::proc_all()
++fff;
}



//
// return to original (e.g. any TAGs or CHs that might be present)
//

std::map<std::string,std::string>::const_iterator oo = curr_faclvl.begin();
while ( oo != curr_faclvl.end() )
{
writer.level( oo->second , oo->first );
++oo;
}

//
// next varaiable
Expand Down
7 changes: 6 additions & 1 deletion spectral/welch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -984,8 +984,13 @@ annot_t * spectral_power( edf_t & edf ,
if ( ! suppress_output )
{
writer.value( "PSD" , x );
writer.value( "RELPSD" , x / tot_pow_denom );

// if dB scaled, return difference between logs
// if ( dB )
// writer.value( "RELPSD" , pow(10, x/10) / tot_pow_denom );
// else
// writer.value( "RELPSD" , x / tot_pow_denom );

if ( aggregate_psd_med && ne_min > 2 )
writer.value( "PSD_MD" , bin_med.bspec[i] );

Expand Down
15 changes: 11 additions & 4 deletions utils/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ struct options_t {
bool print_cmd_name; // -n
bool long_format; // -l
double prec; // -p
std::string prepend; // -a
bool full; // -f
bool show_progress; // -
bool cmd_hash;

char strata_delim;
char faclvl_delim;

Expand All @@ -55,7 +56,8 @@ struct options_t {
print_empty_rows( false ) ,
print_cmd_name( false ) ,
long_format( false ) ,
prec(3) ,
prec(3) ,
prepend( "" ),
full( true ) ,
cmd_hash( false ) ,
strata_delim( '.' ) ,
Expand Down Expand Up @@ -300,6 +302,7 @@ int main(int argc , char ** argv )
else if ( strcmp( argv[i] , "-e" ) == 0 ) { options.print_empty_rows = true; mode = '0'; }

else if ( strcmp( argv[i] , "-f" ) == 0 ) mode = 'D'; // database
else if ( strcmp( argv[i] , "-a" ) == 0 ) mode = 'A'; // add prepend
else if ( strcmp( argv[i] , "-s" ) == 0 ) { any_opt = true; mode = 'S'; } // luna statement
else if ( strcmp( argv[i] , "-r" ) == 0 ) { any_opt = true; mode = 'R'; } // row-stratifier
else if ( strcmp( argv[i] , "-c" ) == 0 ) { any_opt = true; mode = 'C'; } // col-stratifier
Expand Down Expand Up @@ -352,7 +355,11 @@ int main(int argc , char ** argv )
mode = '0';

}


if ( mode == 'A' )
{
options.prepend = argv[i];
}

if ( mode == 'D' )
{
Expand Down Expand Up @@ -1662,7 +1669,7 @@ void display()
while ( vv != o_var.end() )
{

const std::string & var_name = *vv;
const std::string & var_name = options.prepend + *vv;

if ( o_col.size() == 0 )
std::cout << "\t" << var_name;
Expand Down

0 comments on commit 9ee871d

Please sign in to comment.