// file: $(NEDC_NFC)/class/cpp/Wfdb/Wfdb.h // // Revision History: // // 20240409 (JP): initial version // make sure definitions are only made once // #ifndef NEDC_WFDB #define NEDC_WFDB // include nedc classes // #include #include // set up associated namespaces // using namespace boost::numeric::ublas; // Wfdb: a class that supports manipulation of Wfdb data // class Wfdb { //-------------------------------------------------------------------------- // // public constants // //-------------------------------------------------------------------------- public: // define the class name // static const char* CLASS_NAME; // declare important constants // static const long EDF_HSIZE = (long)256; // header block size (fixed) static const long EDF_DMAX = 32767; // Edf digital max static const char* EXT_HEA; // header file extension static const char* EDF_BLANK; // blank field value static const char* EDF_UNITS; // voltage scale static const long MAX_NUM_CLASSES = 19; // max num classes static const long MAX_NUM_CHANNELS = 22; // max num signal channels static const long MAX_NSAMPS_PER_CHAN = 9999; // max num samples per channel static const long MAX_DEBUG_OUTPUT = 10; // max number to print // define information to locate annotations in the annotation database // static const long ANN_OFFSET = 4; // location of annotations static const long MD_SIZE = 5; // size of non-annotation lbls //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // define debug level and verbosity level // Dbgl dbgl_d; Vrbl vrbl_d; // an Edf object for file writing // Edf edf_d; // define variables to hold the header of the annotation database // long num_patients_d; long num_classes_d; char lbl_id_exam_d[Itgl::MAX_SSTR_LENGTH];; char lbl_id_patient_d[Itgl::MAX_SSTR_LENGTH]; char lbl_age_d[Itgl::MAX_SSTR_LENGTH]; char lbl_sex_d[Itgl::MAX_SSTR_LENGTH]; char labels_d[MAX_NUM_CLASSES][Itgl::MAX_SSTR_LENGTH]; char lbl_date_exam_d[Itgl::MAX_SSTR_LENGTH]; // define variables used to hold each annotation record // long* id_exam_d; long* id_patient_d; long* age_d; char** sex_d; long** annotations_d; char** date_exam_d; // define variables used to hold the first line of the header file // char hdr_fname_d[Itgl::MAX_LSTR_LENGTH]; long hdr_id_exam_d; long hdr_num_channels_d; float hdr_sample_frequency_d; long hdr_num_samples_per_channel_d; char hdr_start_time_d[Itgl::MAX_SSTR_LENGTH]; char hdr_exam_date_d[Itgl::MAX_SSTR_LENGTH]; // define variables used to hold the channel-specific lines of the header // char hdr_fnames_d[MAX_NUM_CHANNELS][Itgl::MAX_LSTR_LENGTH]; long hdr_fid_exam_d[MAX_NUM_CHANNELS]; long hdr_adc_nbits_d[MAX_NUM_CHANNELS]; float hdr_adc_gain_d[MAX_NUM_CHANNELS]; char hdr_units_d[MAX_NUM_CHANNELS][Itgl::MAX_SSTR_LENGTH]; long hdr_adc_resolution_d[MAX_NUM_CHANNELS]; float hdr_adc_offset_d[MAX_NUM_CHANNELS]; long hdr_initial_value_d[MAX_NUM_CHANNELS]; long hdr_checksum_d[MAX_NUM_CHANNELS]; long hdr_block_size_d[MAX_NUM_CHANNELS]; char hdr_channel_label_d[MAX_NUM_CHANNELS][Itgl::MAX_SSTR_LENGTH];; // define variables used to hold a data record // // define variables used to hold signal data // VVectorDouble sig_d; //--------------------------------------------------------------------------- // // required public methods (wfdb_00) // //--------------------------------------------------------------------------- public: // method: name // static const char* name() { return CLASS_NAME; } // method: default constructor // Wfdb(); // method: destructor // ~Wfdb(); //--------------------------------------------------------------------------- // // public methods: infrastructure methods (wfdb_00) // //--------------------------------------------------------------------------- public: //--------------------------------------------------------------------------- // // public methods: header-related methods (wfdb_01) // //--------------------------------------------------------------------------- public: // define load methods // bool load_db_tnmg(const char* fname); bool load_header_tnmg(const char* fname_hea); bool load_data_tnmg(const char* fname_dat); // define print methods // bool print_db_tnmg(const char* id = (char*)NULL, FILE* fp = stdout); bool print_header_tnmg(const char* id = (char*)NULL, FILE* fp = stdout); bool print_data_tnmg(const char* id = (char*)NULL, FILE* fp = stdout); // define check id methods // long check_ids(const char* iname); // define get methods // long get_num_classes() { return num_classes_d; } long* get_annotation(const long id); // define make Edf methods // bool make_edf(const char* oname, const char* iname); //--------------------------------------------------------------------------- // // private methods (wfdb_02) // //--------------------------------------------------------------------------- private: // define general purpose functions // bool convert_date(char* odate1, char* odate2, char* idate); bool convert_time(char* otime, char* itime); // // end of class }; // end of include file // #endif