Kengashga kiritilgan


Download 403.93 Kb.
bet3/3
Sana26.05.2020
Hajmi403.93 Kb.
#110332
1   2   3


EMG *new_EMG( uint16_t sample_frequency_,

float qator_,

uint16_t min_EMG_frequency_,

uint16_t max_EMG_frequency_,

EMG_OPTIONS remove_low_frequency_,

EMG_OPTIONS reference_available_);

Dasturda alohida konstruktorlar hosil qilib olinadi.

int filter_EMG_r(EMG *self, int data, int reference_data);

filter funksiyasi yordamida silliqlash algortimlarini qollaymiz va signalni filtrlaymiz.



#include "ecg.h"









#include




#include




#include




#include









struct ECG_ {




PkPk *signal_tracker;




Moving_Average *samples_between_beats;









uint16_t sample_frequency;




ECG_OPTIONS reference_availability;









uint16_t initialization_period;




uint16_t init_counter;




int init_sum;




int average_pkpk;




int BPM;









float pkpk_threshold_ratio;




float autodetect_ratio;




uint16_t data_samples_since_beat;




bool first_beat;









ECG_OPTIONS autodetect;




Moving_Average *init_maxs;




int init_maxs_average;




//Moving_Average *init_mins;




//int init_mins_average;




};









ECG *new_ECG( uint16_t sample_frequency_,




float pkpk_threshold_ratio_,




ECG_OPTIONS reference_availability_,




ECG_OPTIONS autodetect_)




{




ECG *to_return = (ECG *)malloc(sizeof(ECG));









if (to_return == NULL) {




puts("Not enough memory to allocate for ECG");




return NULL;




}









to_return->signal_tracker = new_pkpk(sample_frequency_, sample_frequency_ / 20, sample_frequency_ / 8);




to_return->samples_between_beats = new_moving_average(2); //used to be 3









if (to_return->signal_tracker == NULL || to_return->samples_between_beats == NULL) {




puts("Not enough memory for ECG internal data structures");




return NULL;




}









to_return->sample_frequency = sample_frequency_;




to_return->reference_availability = reference_availability_;









to_return->initialization_period = sample_frequency_ * 3;




to_return->init_counter = 0;




to_return->init_sum = 0;




to_return->average_pkpk = -1;




to_return->BPM = -1;









to_return->pkpk_threshold_ratio = pkpk_threshold_ratio_; //2.0 is a good value for this




to_return->autodetect_ratio = 0.4;




to_return->data_samples_since_beat = 0;




to_return->first_beat = true;









to_return->autodetect = autodetect_;




if (to_return->autodetect == AUTODETECT_THRESHOLD_ON) {




to_return->init_maxs = new_moving_average(sample_frequency_ / 40);




//to_return->init_mins = new_moving_average(sample_frequency_ / 40);




} else {




to_return->init_maxs = NULL;




//to_return->init_mins = NULL;




}









to_return->init_maxs_average = 0;




//to_return->init_mins_average = 0;









return to_return;




}

Download 403.93 Kb.

Do'stlaringiz bilan baham:
1   2   3




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling