Skip to content

Commit

Permalink
lunapi 0.0.6 adds
Browse files Browse the repository at this point in the history
  • Loading branch information
remnrem committed Apr 26, 2024
1 parent 79ab062 commit 240a623
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
43 changes: 40 additions & 3 deletions lunapi/lunapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,14 +1193,51 @@ std::vector<std::string> lunapi_inst_t::channels()
return chs;
}

std::vector<std::string> lunapi_inst_t::annots() const

std::vector<bool> lunapi_inst_t::has_channels( const std::vector<std::string> & chs )
{
if ( state != 1 ) return std::vector<std::string>(0);
return edf.timeline.annotations.names();
std::vector<bool> res;
if ( state != 1 ) return res;
res.resize( chs.size() );
const int ns = chs.size();
for (int s=0;s<ns;s++)
res[s] = edf.header.has_signal( chs[s] );
return res;
}


std::vector<bool> lunapi_inst_t::has_annots( const std::vector<std::string> & anns )
{
std::vector<bool> res;
if ( state != 1 ) return res;
res.resize( anns.size() );
const int ns = anns.size();
for (int s=0;s<ns;s++)
res[s] = edf.timeline.annotations.find( anns[s] ) != NULL;
return res;
}

bool lunapi_inst_t::has_staging()
{
// get staging
edf.timeline.annotations.make_sleep_stage( edf.timeline );

// valid?
param_t empty_param;
bool has_staging = edf.timeline.hypnogram.construct( &(edf.timeline) , empty_param , false );

// valid, but empty?
if ( has_staging && edf.timeline.hypnogram.empty() )
has_staging = false;

return has_staging;
}

std::vector<std::string> lunapi_inst_t::annots() const
{
if ( state != 1 ) return std::vector<std::string>(0);
return edf.timeline.annotations.names();
}


//
Expand Down
7 changes: 7 additions & 0 deletions lunapi/lunapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,15 @@ struct lunapi_inst_t {

std::vector<std::string> channels();

std::vector<bool> has_channels( const std::vector<std::string> & );

std::vector<std::string> annots() const;

std::vector<bool> has_annots( const std::vector<std::string> & );

bool has_staging();


//
// data slices
//
Expand Down

0 comments on commit 240a623

Please sign in to comment.