Skip to content

Commit

Permalink
misc1
Browse files Browse the repository at this point in the history
  • Loading branch information
remnrem committed Nov 13, 2024
1 parent 100a603 commit ee94eda
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
5 changes: 5 additions & 0 deletions annot/annot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3511,6 +3511,11 @@ bool annotation_set_t::dummy_sleep_stage( const timeline_t & tl ,
}


void annotation_set_t::clear_sleep_stage()
{
clear( "SleepStage" );
}

bool annotation_set_t::make_sleep_stage( const timeline_t & tl ,
const bool force_remake ,
const std::string & a_wake ,
Expand Down
3 changes: 2 additions & 1 deletion annot/annot.h
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,8 @@ struct annotation_set_t

bool dummy_sleep_stage( const timeline_t & tl ,
const std::string & stg = "W" );


void clear_sleep_stage();

};

Expand Down
16 changes: 10 additions & 6 deletions edf/edf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ std::set<int> edf_header_t::read( FILE * file , edfz_t * edfz , const std::set<s
// Read start of header into the buffer
//


size_t rdsz;

if ( file ) {
Expand All @@ -648,6 +649,7 @@ std::set<int> edf_header_t::read( FILE * file , edfz_t * edfz , const std::set<s
nbytes_header = edf_t::get_int( &q , 8 );
reserved = edf_t::get_bytes( &q , 44 );


// allow US mm-dd-yy EDF field? if so, change immediately (i.e. internally, it always dd-mm-yy)
if ( globals::read_edf_date_format == MDY )
{
Expand Down Expand Up @@ -726,6 +728,7 @@ std::set<int> edf_header_t::read( FILE * file , edfz_t * edfz , const std::set<s
edfplus = false;
continuous = true;
}


// check whether we are forcing EDF format
if ( globals::force_edf )
Expand Down Expand Up @@ -767,15 +770,15 @@ std::set<int> edf_header_t::read( FILE * file , edfz_t * edfz , const std::set<s
delete [] q0;



//
// at this point, we now know the number of signals: check that the file is
// large enough to contain the full (expected) header: 256 + ns * 256
//

uint64_t expected_header_size = 256 + ns_all * 256;

if ( expected_header_size > edf_t::get_filesize( file ) )

// notimplemented for EDFZ
if ( file && expected_header_size > edf_t::get_filesize( file ) )
{
Helper::vmode_halt( "corrupt EDF header" );
return channels;
Expand All @@ -785,7 +788,6 @@ std::set<int> edf_header_t::read( FILE * file , edfz_t * edfz , const std::set<s
//
// Per-signal header information
//


// read next 256 bytes per signal, i.e. overwriting existing buffer
byte_t * p = new byte_t[ hdrSz * ns_all ];
Expand Down Expand Up @@ -1576,7 +1578,7 @@ bool edf_t::attach( const std::string & f ,
const std::set<std::string> * inp_signals ,
const bool silent )
{

//
// Store filename and ID
//
Expand Down Expand Up @@ -1611,6 +1613,7 @@ bool edf_t::attach( const std::string & f ,
}
else
{

edfz = new edfz_t;

// this also looks for the .idx, which sets the record size
Expand All @@ -1627,7 +1630,7 @@ bool edf_t::attach( const std::string & f ,
//
// Does this look like a valid EDF (i.e. at least contains a header?)
//

uint64_t fileSize = 0 ;

// for EDF
Expand All @@ -1652,6 +1655,7 @@ bool edf_t::attach( const std::string & f ,

inp_signals_n = header.read( file , edfz , inp_signals );


//
// check that a problem was not detected when reading header (i.e. if truncated)
//
Expand Down
16 changes: 14 additions & 2 deletions pops/indiv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ pops_indiv_t::pops_indiv_t( edf_t & edf ,

writer.level( pops_opt_t::equiv_label , "CHEQ" );

logger << " processing equivalent channel set " << pops_opt_t::equiv_label << "\n";
logger << "\n processing equivalent channel set " << pops_opt_t::equiv_label << "\n";

}

Expand Down Expand Up @@ -555,7 +555,7 @@ bool pops_indiv_t::staging( edf_t & edf , param_t & param )

// this allow for lights off/on logic to be applied
has_staging = edf.timeline.hypnogram.construct( &(edf.timeline) , param , false );

// but still note that we do not have valid staging
has_staging = false;
}
Expand All @@ -574,6 +574,10 @@ bool pops_indiv_t::staging( edf_t & edf , param_t & param )
if ( trainer && ! has_staging )
{
logger << " *** no valid staging for trainer " << edf.id << " ( -- skipping -- )\n";

// as we added dummy W staging above
edf.timeline.annotations.clear_sleep_stage();

return false;
}

Expand Down Expand Up @@ -654,6 +658,14 @@ bool pops_indiv_t::staging( edf_t & edf , param_t & param )

} // next epoch

//
// clear up dummy staging
//

if ( ! has_staging )
edf.timeline.annotations.clear_sleep_stage();


//
// copy original staging (i.e. as S is set to POPS_UNKNOWN for bad signals, trimming etc)
//
Expand Down

0 comments on commit ee94eda

Please sign in to comment.