A kind of the R wave extracting method and system of electrocardiosignal
Technical field
The invention belongs to medicine technology field more particularly to the R wave extracting methods and system of a kind of electrocardiosignal.
Background technique
Electrocardiogram (electrocardiogram, ECG) is the electrical activity process for reflecting cardiac excitation, its base to heart
There is important reference value in terms of this function and its case research.Electrocardiogram can analyze and identify various arrhythmia cordis,
Can reflecting myocardium impaired degree and atrial ventricle's functional structure situation, instructing openheart surgery to carry out and indicating at necessary drug
Also there is certain reference value in reason.
The electrocardiogram mainly interference by following several noises: myoelectricity interference, Hz noise, skin surface electrodes movement are drawn
Baseline drift caused by the breathing of the motion artifacts and measurand that rise or limb activity etc..Such as: in cardiac monitoring system
In system, the electrocardiogram (ECG) data of acquisition will appear serious drift due to daily routines (such as breathing) interference by guardianship,
Conventional electrocardiogram is recorded again after being stablized with isobase, and when there is great state of an illness sudden change, waiting will indulge in
Accidentally rescue opportunity, so the baseline drift of electrocardiographic wave handle in real time online it is very necessary.
QRS wave is the main feature of electrocardiosignal, lower only after determining QRS complex to calculate heart rate, detection heart rate
Variation, and further detect the other details of electrocardiosignal.Small wave converting method is generallyd use at present to detect R wave, and small echo becomes
Although it is fine to the extraction effect of R wave to change method, operation is big, and operation is complicated.
Summary of the invention
The embodiment of the invention provides the R wave extracting methods and system of a kind of electrocardiosignal, it is intended to solve R in the prior art
The more complex problem of the operation of wave detection.
The embodiments of the present invention are implemented as follows, a kind of R wave extracting method of electrocardiosignal, comprising:
Acquire original electrocardiosignal;
The electrocardiosignal of acquisition is filtered, processing signal is obtained;
R wave is extracted from the corresponding sequence of the processing signal using adaptive thresholding algorithm.
Preferably, the use adaptive thresholding algorithm extracts R wave from the corresponding sequence of the processing signal and specifically wraps
It includes:
Whether judgement has currently extracted at least two R waves;
If currently extracted at least two R waves, baseline threshold is obtained based on the corresponding range value of the first two R wave, and mention
Take current R wave;
When there is also next R wave, the R wave currently to extract is based on the first two R back to aforementioned as previous R wave
The corresponding range value of wave obtains baseline threshold, continues the step of extracting next R wave.
Preferably, if it is described currently when having extracted at least two R waves, base is obtained based on the corresponding range value of the first two R wave
Quasi- threshold value, and extract current R wave and specifically include:
Compare the corresponding range value of the first two R wave, based on comparative result calculating benchmark threshold value;
Current R wave is extracted based on the baseline threshold.
Preferably, the corresponding range value of relatively the first two R wave, calculating benchmark threshold value is specifically wrapped based on comparative result
It includes:
Using the corresponding range value of first formula comparison the first two R wave, first formula are as follows: y (index (i-1)) > y
(index (i-2))/0.8, wherein the index (i-1) and index (i-2) are respectively the first two R wave position, the y
(index (i-1)) and y (index (i-2)) respectively indicate the corresponding range value of the first two R wave, and the i is the nature greater than 0
Number;
When first formula is set up, using y (index (i-2))/0.8 as baseline threshold;
When first formula is invalid, using y (index (i-1)) * 0.8 as baseline threshold.
Preferably, described to be specifically included based on the current R wave of baseline threshold extraction:
Initial threshold, the first predetermined sequence section are obtained based on the baseline threshold and the first predetermined sequence section are as follows: from
The position (i-1) index is to the sequence between the position index (i-1)+0.28 (index (i-1)-index (i-2))
Section;
Current R wave, the second predetermined sequence section are extracted in the second predetermined sequence section based on the initial threshold are as follows: from
The position index (i) to the position index (i)+0.05fs, wherein the index (i) is current R wave position,
Fs is sample frequency, and the i is the natural number more than or equal to 2.
It is preferably based on the baseline threshold and the first predetermined sequence section obtains initial threshold and specifically includes:
Judge to whether there is the point greater than the baseline threshold in the first predetermined sequence section;
If it exists, then select the value greater than the baseline threshold as initial threshold;
If it does not exist, then select the baseline threshold as initial threshold.
Preferably, described to extract current R wave in the second predetermined sequence section based on the initial threshold and specifically include:
Judge in the second predetermined sequence section with the presence or absence of the point greater than the initial threshold;
If it exists, then using the point position greater than the initial threshold as current R wave position;
If it does not exist, then using the initial threshold position as R wave position.
Preferably, after whether the judgement has currently extracted at least two R waves further include:
If currently do not extract at least two R waves, preset threshold is obtained in third predetermined sequence section, based on described default
Threshold value extracts R wave, the third predetermined sequence section are as follows: from the position index (i) to the position index (i)+1.5fs,
The index (i) is current R wave position, and fs is sample frequency, and the i is the natural number less than 2.
Preferably, if currently do not extract at least two R waves, initial threshold is obtained in third predetermined sequence section, is based on
The initial threshold is extracted R wave and is specifically included:
Maximum value is obtained in the third predetermined sequence section, and obtains the correction value of maximum value;
Judge the point for being greater than the correction value with the presence or absence of range value in the 4th predetermined sequence section;
If it exists, then using the point as the position where current R wave;
If it does not exist, then using corresponding position of the maximum value as the position where current R wave.
Preferably, the electrocardiosignal of acquisition is filtered, obtains processing signal specifically: use three cascade numbers
It learns kenel filter to be filtered electrocardiosignal collected, the three cascade mathematics kenel filter includes three-level
Filter construction is respectively as follows: 5 points of quarter window, 30 points of Hanning window and 90 points of quarter window.
The present invention also provides a kind of R wave extraction systems of electrocardiosignal, comprising: acquisition module connects with the acquisition module
The processing module connect, the extraction module being connect with the processing module, in which:
Acquisition module, for acquiring original electrocardiosignal;
Processing module obtains processing signal for being filtered to the electrocardiosignal of acquisition;
Extraction module, for extracting R wave from the corresponding sequence of the processing signal using adaptive thresholding algorithm.
In embodiments of the present invention, R wave, i.e. the reference threshold base of subsequent extracted R wave are extracted using adaptive thresholding algorithm
It is adjusted in the parameter of previous R wave, the accuracy for extracting R wave can be improved to a certain extent;It is filtered before extracting R wave
Processing, can effectively eliminate noise existing for initial electrocardiosignal and avoid the problem that baseline drift, further increase and extract R wave
Precision.
Detailed description of the invention
Fig. 1 is a kind of flow chart of the R wave extracting method for electrocardiosignal that first embodiment of the invention provides;
Fig. 2 is the specific stream of the step S3 of the R wave extracting method for electrocardiosignal that first embodiment of the invention provides a kind of
Cheng Tu;
Fig. 3 is the specific stream of the step S32 of the R wave extracting method for electrocardiosignal that first embodiment of the invention provides a kind of
Cheng Tu;
Fig. 4 is a kind of the specific of the step S322 of the R wave extracting method for electrocardiosignal that first embodiment of the invention provides
Flow chart;
Fig. 5 is a kind of the specific of the step S401 of the R wave extracting method for electrocardiosignal that first embodiment of the invention provides
Flow chart;
Fig. 6 is a kind of the specific of the step S402 of the R wave extracting method for electrocardiosignal that first embodiment of the invention provides
Flow chart;
Fig. 7 is the specific stream of the step S33 of the R wave extracting method for electrocardiosignal that first embodiment of the invention provides a kind of
Cheng Tu;
Fig. 8 is a kind of structure chart of the R wave extraction system for electrocardiosignal that second embodiment of the invention provides;
Fig. 9 is a kind of the specific of the extraction module 3 of the R wave extraction system for electrocardiosignal that second embodiment of the invention improves
Structure chart;
Figure 10 is a kind of the first extraction unit 32 of the R wave extraction system for electrocardiosignal that second embodiment of the invention improves
Concrete structure diagram;
Figure 11 is a kind of the second extraction unit 33 of the R wave extraction system for electrocardiosignal that second embodiment of the invention provides
Concrete structure diagram.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, right
The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and
It is not used in the restriction present invention.
In the embodiment of the present invention, a kind of R wave extracting method of electrocardiosignal, comprising: acquire original electrocardiosignal;To adopting
The electrocardiosignal of collection is filtered, and obtains processing signal;It is corresponding from the processing signal using adaptive thresholding algorithm
R wave is extracted in sequence.
In order to illustrate technical solutions according to the invention, the following is a description of specific embodiments.
Embodiment one:
Fig. 1 shows a kind of flow chart of the R wave extracting method of electrocardiosignal of first embodiment of the invention offer, packet
It includes:
Step S1, original electrocardiosignal is acquired;
Wherein, original electrocardiosignal is acquired, frequency acquisition fs can be set according to the actual situation, it is preferable that the present embodiment
Sample frequency fs be 250Hz.Specifically, the electrocardiosignal of acquisition includes several sampled points, the corresponding width of each sampled point
Angle value and time point, and sampled point may be the R wave for needing to extract, i.e., each R wave carries respective amplitude value and the number at time point
According to.
Step S2, the electrocardiosignal of acquisition is filtered, obtains processing signal;
Specifically, due to original electrocardiosignal collected may because various external or internal factor (such as breathing, body
Body situation etc.) it interferes and deviates, it is therefore desirable to the original electrocardiosignal of acquisition is filtered.The present embodiment
In, filter can be used and carry out cancelling noise.
Further, the frequency of the electrocardiosignal is set as fM, sample frequency fS, the number that is obtained by analog signal
Signal period length (data points) is M=fS/fM, filter construction member length is N, selects the signal of different cycles length logical
The filter for crossing different structure member length, as ratio K=N/M increases, the attenuation amplitude of signal increases, particularly, work as K >
0.5, i.e., the transverse width that the lateral dimension (element number) of structural element is greater than or equal to the component that filter removing (samples
Number), signal will be filtered out (A=- ∞) completely, the attenuation amplitude of signal by signal numerical frequency and structural elements length ratio
Value is unique to be determined.
In a preferred embodiment of this embodiment, it is filtered using corrosion and expansion algorithm, specifically:
If f (n), (n=0,1 ..., N-1) and k (m), (m=0,1 ..., M-1) is respectively one-dimensional discrete function, N > > M, N
And M is the natural number greater than 0, the f (n) is electrocardiosignal sequence to be processed, and k (m) is structural element.
Erosion operation using f (n) about k (m), erosion algorithm areIts
In,
Then the dilation operation of f (n) about k (m), operational formula are carried out are as follows:
Wherein, the n=M-1, M ..., N-1.
It should be noted that the present embodiment is not limited to carry out dilation operation after first carrying out erosion operation, can be first swollen
Swollen operation post-etching operation or erosion operation carry out simultaneously with dilation operation, herein with no restriction to this.
In another deformation scheme of the present embodiment, using following processing mode:
Opening operation of the f (n) about k (m):And
Closed operation of the f (n) about k (m):
Specifically, opening operation and closed operation are the following above and moving structure element in electrocardiosignal respectively, and every
The highs and lows of some interrecord structure elements.Opening operation can wave crest in cancellation signal, closed operation can be filled in signal
Trough.
In the another deformation scheme of the present embodiment, electrocardio collected is believed using three cascade mathematics kenel filters
It number is filtered, the three cascade mathematics kenel filter includes three-level filtering device structure, is respectively as follows: 5 points of triangle
Window, 30 points of Hanning window and 90 points of quarter window.
Specifically, using opening and closing and the combination of make and break filter:
The OC is opening and closing kenel, and the CO is make and break kenel, and the f is to be processed
The sequence of signal, k are structural element.
Combine corresponding algorithm as follows using above-mentioned opening and closing and closure filter:
In the present embodiment, the shrinkage of opening operation makes the output amplitude of opening-closing Filter smaller, the dilatancy of closed operation
So that the output amplitude of make and break filter is larger, electrocardiosignal can be effectively suppressed and the phenomenon that unidirectional offset occur.Further, since the heart
The ingredient being actually filtered out in electric signal is related with structural element employed in operation, if the width of structural element is M, signal
The width of medium wave peak or trough is N, then has N > M, and signal is retained;N < M, signal are filtered out.Using above-mentioned opening and closing and closure filter
Wave device combines the both positive and negative impulsive noise that can be removed simultaneously in signal.
Step S3, R wave is extracted from the corresponding sequence of the processing signal using adaptive thresholding algorithm.
Preferably, as shown in Fig. 2, being a kind of R wave extracting method for electrocardiosignal that first embodiment of the invention provides
The specific flow chart of step S3, above-mentioned steps S3 are specifically included:
Step S31, whether judgement has currently extracted at least two R waves, goes to step when if currently having extracted at least two R waves
Otherwise rapid S32 goes to step S33;
Step S32, baseline threshold is obtained based on the corresponding range value of the first two R wave, and extracts current R wave;
Step S33, R wave is extracted based on preset threshold.
In a preferred embodiment of this embodiment, may also include that after above-mentioned steps S32
Step S34 judges whether to go to step S32 when it is present there is also next R wave, continue mentioning for next R wave
It takes, otherwise terminates process.
Specifically, the quantity of the statistics available sampled point currently traversed, sampled point quantity corresponding with electrocardiosignal are compared
Compared with if the sampled point currently traversed is the last one sampled point, then it represents that next R wave is not present, if the sampling currently traversed
Point is not belonging to the last one sampled point, then it represents that there may be next R waves, go to step S32.
It should be noted that the method that step S33 can be used in the extraction of the first two R wave is extracted from when starting to extract R wave,
And third R wave starts then to extract using the method for step S32, and it is subsequent to traverse one by one, until extracting completely, i.e. subsequent extracted R
The process of wave is consistent with step S32's, is all based on the data such as the range value of the first two R wave of current R wave and is worked as to extract
Preceding R wave, subsequent processes then extract each R wave according to the sampled point of identical extracting method traversal subsequent sequence section, until
It extracts and completes.
Preferably, as shown in figure 3, being a kind of R wave extracting method for electrocardiosignal that first embodiment of the invention provides
The specific flow chart of step S32, above-mentioned steps S32 are specifically included:
Step S321, compare the corresponding range value of the first two R wave, based on comparative result calculating benchmark threshold value;
Specifically, due to current extracted two or more R wave, first formula comparison the first two R wave pair can be used at this time
The range value answered, first formula are as follows: y (index (i-1)) > y (index (i-2))/0.8, wherein index (i) is current
R wave position, and the index (i-1) and index (i-2) are respectively the first two R wave position, i.e. the first two R wave
Before time interval between (index (i-1) and index (i-2)), y (index (i-1)) and y (index (i-2)) are respectively indicated
The corresponding range value of two R waves, i at this time are the natural number greater than 2;
When first formula is set up, using y (index (i-2))/0.8 as baseline threshold, that is, previous R wave is selected
The corresponding range value of previous R wave index (i-2) of index (i-1), and the range value is modified, obtain y (index
(i-2))/0.8, using revised numerical value as baseline threshold;
When first formula is invalid, using y (index (i-1)) * 0.8 as baseline threshold, and the previous R of selection
The corresponding range value of wave index (i-1), and the range value is modified, y (index (i-1))/0.8 is obtained, after amendment
Numerical value as baseline threshold;
In another preferred embodiment of the present embodiment, when first formula is invalid, with y (index (i-1)) *
0.7 is used as baseline threshold, and the corresponding range value of the previous R wave index (i-1) of selection, and is modified to the range value, obtains
To y (index (i-1))/0.7, using revised numerical value as baseline threshold.
Step S322, current R wave is extracted based on the baseline threshold.
As shown in figure 4, being a kind of step S322 of the R wave extracting method for electrocardiosignal that first embodiment of the invention provides
Specific flow chart, above-mentioned steps S322 specifically includes:
Step S401, initial threshold is obtained based on baseline threshold and the first predetermined sequence section;
Specifically, the first predetermined sequence section are as follows: from the position (i-1) index to index (i-1)+0.28
Tract between the position (index (i-1)-index (i-2)), i.e. index (i-1) arrive index (i-1)+0.28
Time interval between (index (i-1)-index (i-2)).
Step S402, current R wave is extracted in the second predetermined sequence section based on initial threshold;
The second predetermined sequence section are as follows: from the position index (i) to the position index (i)+0.05fs, i.e.,
Time interval between index (i) and index (i)+0.05fs, by above range to the corresponding range value of each sampled point
It is compared with acquired initial threshold, current R wave is extracted in the time interval.Wherein, the index (i) is current R
Wave position, fs are sample frequency, and i at this time is the natural number more than or equal to 2.
As shown in figure 5, being a kind of step S401 of the R wave extracting method for electrocardiosignal that first embodiment of the invention provides
Specific flow chart, above-mentioned steps S401 specifically includes:
Step S4011, judge to whether there is the point greater than the baseline threshold in the first predetermined sequence section, go to if it exists
Otherwise step S4012 goes to step S4013;
Specifically, from the position (i-1) index to index (i-1)+0.28 (index (i-1)-index (i-2)) institute
Obtain the corresponding range value of each sampled point in tract between position, the maximum sampled point of selecting range value, most by this
Substantially angle value is compared with said reference threshold value, judges whether the maximum amplitude value is greater than the initial threshold, when judgement is greater than
When, step S4012 is gone to, step S4013 is otherwise gone to;
Step S4012, select the range value greater than the baseline threshold as initial threshold;
There is the range value for being greater than baseline threshold at this time, then selects the range value as initial threshold, be used for subsequent extracted R
Wave.
Step S4013, select the baseline threshold as initial threshold.
Indicate that max-thresholds are less than or equal to baseline threshold when it be not present, then using the baseline threshold as initial threshold,
For subsequent extracted R wave.
As shown in fig. 6, being a kind of step S402 of the R wave extracting method for electrocardiosignal that first embodiment of the invention provides
Specific flow chart, above-mentioned steps S402 specifically includes:
Step S4021, judge in the second predetermined sequence section with the presence or absence of the point greater than initial threshold;
Specifically, from the position index (i) to the corresponding tract of the position index (i)+0.05fs range
It is middle to obtain the corresponding range value of all sampled points, the range value greater than above-mentioned initial threshold is judged whether there is, goes to step if it exists
Otherwise rapid S4022 goes to step S4023.
Step S4022, using the point position greater than initial threshold as current R wave position;
Specifically, when it is present, above-mentioned range value is selected to be greater than the sampled point position of initial threshold as current R wave
Position.
Step S4023, using initial threshold position as R wave position.
Specifically, when it be not present, illustrate that there is no the sampled points that range value is greater than the initial threshold in above range, then
The initial threshold is selected to correspond to sampled point position as current R wave position.
It is in place using the corresponding point of the range value as current R wave institute when there are the point that range value is greater than the initial threshold
It sets, when range value is greater than the sampled point of the initial threshold if it does not exist, is made with the corresponding sampled point position of the initial threshold
For current R wave position, current R wave is extracted.
Above-mentioned steps S33 specifically: obtain preset threshold in third predetermined sequence section, R is extracted based on the preset threshold
Wave, the third predetermined sequence section are as follows: from the position index (i) to the position index (i)+1.5fs, the index
It (i) is current R wave position, fs is sample frequency, and i at this time is the natural number less than 2.
By taking fs is 250Hz as an example, when i is equal to 0, index (i) is starting point, such as sample frequency fs is 250Hz, from
The range of the position index (i) to the position index (i)+1.5fs is 1.5fs, as 375 sampled points, from above-mentioned
R wave is obtained in 375 sampled points.
As shown in fig. 7, being a kind of step S33 of the R wave extracting method for electrocardiosignal that first embodiment of the invention provides
Specific flow chart, above-mentioned steps S33 specifically includes:
Step S331, maximum value is obtained in third predetermined sequence section, and obtains the correction value of maximum value;
Specifically, the sampled point with maximum amplitude value max (1) is obtained in above-mentioned 375 sampled points, and to the maximum
Range value is modified.Preferably, correction factor 0.8, i.e. 0.8max (1) are correction value.
Step S332, the point for being greater than the correction value with the presence or absence of range value in the 4th predetermined sequence section is judged, if depositing
Step S333 is being gone to, step S334 is otherwise gone to;
Specifically, the 4th position predetermined sequence Duan Weicong index (i) is in place to index (i)+0.05fs institute
It sets, i.e. the time interval between index (i) to index (i)+0.05fs, wherein the index (i) is current R wave place
Position, fs are sample frequency, and i at this time is the natural number less than 2.In the present embodiment, sample frequency fs is 250Hz, 0.05fs
For 12.5 sampled points (being rounded to 13 sampled points), the 4th predetermined sequence section is past from current R wave position
The segment between 13 sampled points afterwards.If going to step there are the sampled point that range value is greater than correction value in the section
Otherwise S333 goes to step S334.
Step S333, using the position where the sampled point as current R wave;
Specifically, when there are the sampled point that range value is greater than correction value, using the sampled point position as current R wave
The R wave is extracted in position.
Step S334, using the corresponding sampled point position of maximum value as the position where current R wave.
Specifically, when there is no the sampled point that range value is greater than correction value, then in above-mentioned third predetermined sequence section
The R wave is extracted as R wave position in the corresponding sampled point position of maximum amplitude value.
It should be noted that the case where step S33 was not for currently extracting R wave or being only extracted a R wave, when not
When extracting R wave, third predetermined sequence section is that the starting point of electrocardiosignal corresponding sequence starts (to use frequency fs for 250Hz to 375
When) section between a sampled point, and when an extracted R wave, third predetermined sequence section is first R wave position
Start to calculate, the section between the 375th sampled point, but the method for extracting first and secondary R wave use is consistent.
It should be noted that the process for extracting R wave is specific as follows: being extracted first using identical method (such as step S33)
First R involves secondary R wave, then using other method (such as step S32) extract third, the 4th,, i-th,
Third R wave starts then to adjust threshold value according to the first two R wave self-adaption, extracts R wave according to the threshold value of adjustment.
In the present embodiment, R wave is extracted using adaptive thresholding algorithm, i.e. the reference threshold of subsequent extracted R wave is based on previous
The parameter of a R wave adjusts, and can improve the accuracy for extracting R wave to a certain extent;It is filtered before extracting R wave,
Noise existing for initial electrocardiosignal can effectively be eliminated and avoid the problem that baseline drift, further increase the essence for extracting R wave
Degree.
In addition, the algorithm for extracting R wave is simple, it is related to comparing and adds and subtracts, calculating process is simple, improves R wave extraction efficiency.
Furthermore electrocardiosignal collected is filtered using three cascade mathematics kenel filters, can be eliminated
Initially phenomena such as the baseline drift in electrocardiosignal, impulsive noise, above-mentioned phenomenon interference R wave is avoided to extract, to a certain degree raising R
The accuracy that wave extracts.
Embodiment two:
Fig. 8 shows a kind of structure chart of the R wave extraction system of electrocardiosignal of second embodiment of the invention offer, packet
It includes: acquisition module 1, the filter module 2 being connect with acquisition module 1, the extraction module 3 being connect with filter module 2, in which:
Acquisition module 1, for acquiring original electrocardiosignal;
Wherein, original electrocardiosignal is acquired, frequency acquisition fs can be set according to the actual situation, it is preferable that the present embodiment
Sample frequency fs be 250Hz.Specifically, the electrocardiosignal of acquisition includes several sampled points, the corresponding width of each sampled point
Angle value and time point, and sampled point may be the R wave for needing to extract, i.e., each R wave carries respective amplitude value and the number at time point
According to.
First obtains module 2, for being filtered to the electrocardiosignal of acquisition, obtains processing signal;
Specifically, due to original electrocardiosignal collected may because various external or internal factor (such as breathing, body
Body situation etc.) it interferes and deviates, it is therefore desirable to the original electrocardiosignal of acquisition is filtered.The present embodiment
In, filter can be used and carry out cancelling noise.
Further, the frequency of the electrocardiosignal is set as fM, sample frequency fS, the number that is obtained by analog signal
Signal period length (data points) is M=fS/fM, filter construction member length is N, selects the signal of different cycles length logical
The filter for crossing different structure member length, as ratio K=N/M increases, the attenuation amplitude of signal increases, particularly, work as K >
0.5, i.e., the transverse width that the lateral dimension (element number) of structural element is greater than or equal to the component that filter removing (samples
Number), signal will be filtered out (A=- ∞) completely, the attenuation amplitude of signal by signal numerical frequency and structural elements length ratio
Value is unique to be determined.
In a preferred embodiment of this embodiment, it is filtered using corrosion and expansion algorithm, specifically:
If f (n), (n=0,1 ..., N-1) and k (m), (m=0,1 ..., M-1) is respectively one-dimensional discrete function, N > > M, N
And M is the natural number greater than 0, the f (n) is electrocardiosignal sequence to be processed, and k (m) is structural element.
Erosion operation using f (n) about k (m), erosion algorithm are
Then the dilation operation of f (n) about k (m), operational formula are carried out are as follows:Wherein, the n=M-1, M ..., N-1.
It should be noted that the present embodiment is not limited to carry out dilation operation after first carrying out erosion operation, can be first swollen
Swollen operation post-etching operation or erosion operation carry out simultaneously with dilation operation, herein with no restriction to this.
In another deformation scheme of the present embodiment, using following processing mode:
Opening operation of the f (n) about k (m):And
Closed operation of the f (n) about k (m):
Specifically, opening operation and closed operation are the following above and moving structure element in electrocardiosignal respectively, and every
The highs and lows of some interrecord structure elements.Opening operation can wave crest in cancellation signal, closed operation can be filled in signal
Trough.
In the another deformation scheme of the present embodiment, electrocardio collected is believed using three cascade mathematics kenel filters
It number is filtered, the three cascade mathematics kenel filter includes three-level filtering device structure, is respectively as follows: 5 points of triangle
Window, 30 points of Hanning window and 90 points of quarter window.
Specifically, using opening and closing and the combination of make and break filter:
The OC is opening and closing kenel, and the CO is make and break kenel, and the f is to be processed
The sequence of signal, k are structural element.
Combine corresponding algorithm as follows using above-mentioned opening and closing and closure filter:
In the present embodiment, the shrinkage of opening operation makes the output amplitude of opening-closing Filter smaller, the dilatancy of closed operation
So that the output amplitude of make and break filter is larger, electrocardiosignal can be effectively suppressed and the phenomenon that unidirectional offset occur.Further, since the heart
The ingredient being actually filtered out in electric signal is related with structural element employed in operation, if the width of structural element is M, signal
The width of medium wave peak or trough is N, then has N > M, and signal is retained;N < M, signal are filtered out.Using above-mentioned opening and closing and closure filter
Wave device combines the both positive and negative impulsive noise that can be removed simultaneously in signal.
Extraction module 3, for extracting R wave from the corresponding sequence of the processing signal using adaptive thresholding algorithm.
Preferably, as shown in figure 9, being a kind of R wave extraction system for electrocardiosignal that second embodiment of the invention improves
The concrete structure diagram of extraction module 3, said extracted module 3 specifically include: quantity judging unit 31 connects with quantity judging unit 31
The first extraction unit 32 and the second extraction unit 33 connect, in which:
Quantity judging unit 31, when having extracted, feeds back to for judging currently whether extracted at least two R waves
Otherwise one extraction module 32 is fed back to the second extraction module 33;
First extraction unit 32, for it is corresponding to be based on the first two R wave when currently whether having extracted at least two R waves
Range value obtains baseline threshold, and extracts current R wave;
Second extraction unit 33, for extracting R wave based on preset threshold when not extract at least two R waves.
In a preferred embodiment of this embodiment, above-mentioned R wave extraction system can include:
The R wave judging unit 34 connecting with the first extraction unit 32 and the second extraction unit 33, is also deposited for judging whether
In next R wave, the first extraction unit 32 is fed back to when it is present, is continued the extraction of next R wave, is otherwise terminated process.
Specifically, the quantity of the statistics available sampled point currently traversed, sampled point quantity corresponding with electrocardiosignal are compared
Compared with if the sampled point currently traversed is the last one sampled point, then it represents that next R wave is not present, if the sampling currently traversed
Point is not belonging to the last one sampled point, then it represents that there may be next R waves, feed back to the first extraction unit 32.
It should be noted that the second extraction unit 33 can be used to mention for the extraction of the first two R wave from when starting to extract R wave
It takes, and third R wave starts, and is extracted using the first extraction unit 32, it is subsequent to traverse one by one, it is until extracting completely, i.e., subsequent
The process for extracting R wave is consistent, and is all based on the data such as the range value of the first two R wave of current R wave to extract current R wave,
Subsequent processes then traverse the sampled point of subsequent sequence section according to identical extracting method to extract each R wave, until having extracted
At.
Preferably, as shown in Figure 10, a kind of R wave extraction system of the electrocardiosignal improved for second embodiment of the invention
The concrete structure diagram of first extraction unit 32, first extraction unit 32 specifically include: comparing subunit 321, the sub- list compared with
The first of 321 connection of member extracts subelement 322, in which:
Comparing subunit 321, for comparing the corresponding range value of the first two R wave, calculating benchmark threshold value based on comparative result;
Specifically, due to current extracted two or more R wave, first formula comparison the first two R wave pair can be used at this time
The range value answered, first formula are as follows: y (index (i-1)) > y (index (i-2))/0.8, wherein index (i) is current
R wave position, and the index (i-1) and index (i-2) they are respectively the first two R wave position, i.e. index (i-1)
With the time interval between index (i-2), y (index (i-1)) and y (index (i-2)) respectively indicate the first two R wave and correspond to
Range value, i is natural number greater than 2;
When first formula is set up, using y (index (i-2))/0.8 as baseline threshold, that is, previous R wave is selected
The corresponding range value of previous R wave index (i-2) of index (i-1), and the range value is modified, obtain y (index
(i-2))/0.8, using revised numerical value as baseline threshold;
When first formula is invalid, using y (index (i-1)) * 0.8 as baseline threshold, and the previous R of selection
The corresponding range value of wave index (i-1), and the range value is modified, y (index (i-1))/0.8 is obtained, after amendment
Numerical value as baseline threshold.
First extracts subelement 322, for extracting current R wave based on the baseline threshold.
Specifically, which specifically includes: initial threshold obtains subelement and obtains with initial threshold
The R wave of subelement connection extracts subelement, in which:
Initial threshold obtains subelement, for obtaining initial threshold based on the baseline threshold and the first predetermined sequence section,
The first predetermined sequence section are as follows: from the position (i-1) index to (index (the i-1)-index of index (i-1)+0.28
(i-2)) tract between position, i.e. index (i-1) arrive index (i-1)+0.28 (index (i-1)-index (i-
2) time interval between).
R wave extracts subelement, for extracting current R wave in the second predetermined sequence section based on the initial threshold;It is described
Second predetermined sequence section are as follows: from the position index (i) to the position index (i)+0.05fs, i.e. index (i) with
Time interval between index (i)+0.05fs, by above range to the corresponding range value of each sampled point and acquired
Initial threshold is compared, and current R wave is extracted in the time interval.Wherein, the index (i) is in place for current R wave institute
It sets, fs is sample frequency, and i at this time is the natural number more than or equal to 2.
In a preferred embodiment of this embodiment, above-mentioned initial threshold obtains subelement and specifically includes: threshold value comparison
Unit and the selection subelement being connect with the threshold value comparison subelement, in which:
Threshold value comparison subelement whether there is the point greater than the baseline threshold in the first predetermined sequence section for judging;
Subelement is selected, when for there is the sampled point greater than the baseline threshold in the first predetermined sequence section, selection is big
In the baseline threshold range value as initial threshold;And it is greater than the baseline threshold for being not present in the first predetermined sequence section
Sampled point when, select the baseline threshold as initial threshold.
In another preferred embodiment of the present embodiment, above-mentioned R wave extracts subelement and specifically includes: threshold decision subelement and
R wave connected to it confirms subelement, in which:
Threshold decision subelement, for judging in the second predetermined sequence section with the presence or absence of greater than the initial threshold
Point;
Specifically, from the position index (i) to the corresponding tract of the position index (i)+0.05fs range
It is middle to obtain the corresponding range value of all sampled points, and judge whether there is the range value greater than above-mentioned initial threshold;
R wave confirm subelement, in the second predetermined sequence section there are range value be greater than initial threshold sampled point when,
Confirm using the sampled point position greater than the initial threshold as current R wave position;It is also used in the second default sequence
It is in place using the initial threshold position as R wave institute when sampled point of the range value greater than initial threshold being not present in column section
It sets.
I.e. when there are the point that range value is greater than the initial threshold, where using the corresponding point of the range value as current R wave
Position, when range value is greater than the sampled point of the initial threshold if it does not exist, with the corresponding sampled point position of the initial threshold
As current R wave position, current R wave is extracted.
In the present embodiment, the second extraction module 33 is specifically used for: obtaining preset threshold in third predetermined sequence section, is based on
The preset threshold extracts R wave, the third predetermined sequence section are as follows: from the position index (i) to index (i)+1.5fs institute
In position, the index (i) is current R wave position, and fs is sample frequency, and i at this time is the natural number less than 2.
By taking fs is 250Hz as an example, when i is equal to 0, index (i) is starting point, such as sample frequency fs is 250Hz, from
The range of the position index (i) to the position index (i)+1.5fs is 1.5fs, as 375 sampled points, from above-mentioned
R wave is obtained in 375 sampled points.
Preferably, as shown in figure 11, a kind of R wave extraction system of the electrocardiosignal provided for second embodiment of the invention
The concrete structure diagram of second extraction unit 33, second extraction unit 33 specifically include: correction value obtain subelement 331 and with this
It is fixed that correction value obtains the range value judgment sub-unit 332 of the connection of subelement 331, the R wave connecting with range value judgment sub-unit 332
Seat unit 333, in which:
Correction value obtains subelement 331, for obtaining maximum value in the third predetermined sequence section, and obtains maximum value
Correction value;
Specifically, the sampled point with maximum amplitude value max (1) is obtained in above-mentioned 375 sampled points, and to the maximum
Range value is modified.Preferably, correction factor 0.8, i.e. 0.8max (1) are correction value.
Range value judgment sub-unit 332, it is described for judging to be greater than in the 4th predetermined sequence section with the presence or absence of range value
The point of correction value;Specifically, where the 4th position predetermined sequence Duan Weicong index (i) to index (i)+0.05fs
Position, the i.e. time interval between index (i) to index (i)+0.05fs.Wherein, the index (i) is current R wave institute
In position, fs is sample frequency, and the i is the natural number less than 2.In the present embodiment, sample frequency fs is 250Hz, 0.05fs
For 12.5 sampled points (being rounded to 13 sampled points), the 4th predetermined sequence section is past from current R wave position
The segment between 13 sampled points afterwards.
R wave locator unit 333, if for, there are when the sampled point that range value is greater than correction value, being adopted in the section with this
Sampling point is as the position where current R wave;When being also used to that sampled point of the range value greater than correction value is not present in the section, with
Corresponding position of the maximum value is as the position where current R wave.
Specifically, when there are the sampled point that range value is greater than correction value, using the sampled point position as current R wave
The R wave is extracted in position, when there is no the sampled point that range value is greater than correction value, then with above-mentioned third predetermined sequence section
In the corresponding sampled point position of maximum amplitude value as R wave position, extract the R wave.
Currently R wave was not extracted or is only extracted the feelings of a R wave it should be noted that the second extraction unit 33 is directed to
Condition, when not extracting R wave, third predetermined sequence section is that the starting point of electrocardiosignal corresponding sequence starts to 375 (using frequency fs
When for 250Hz) section between a sampled point, and when an extracted R wave, third predetermined sequence section is first R wave
Position starts to calculate, the section between the 375th sampled point, but the method for extracting first and secondary R wave use
Unanimously.
It should be noted that the process for extracting R wave is specific as follows: extracting first R first with the second extraction unit 33
Involve secondary R wave, then using the first extraction unit 32 extract third, the 4th,, i-th, third R wave starts then
Threshold value is adjusted according to the first two R wave self-adaption, R wave is extracted according to the threshold value of adjustment.
In the present embodiment, R wave is extracted using adaptive thresholding algorithm, i.e. the reference threshold of subsequent extracted R wave is based on previous
The parameter of a R wave adjusts, and can improve the accuracy for extracting R wave to a certain extent;It is filtered before extracting R wave,
Noise existing for initial electrocardiosignal can effectively be eliminated and avoid the problem that baseline drift, further increase the essence for extracting R wave
Degree.
In addition, the algorithm for extracting R wave is simple, it is related to comparing and adds and subtracts, calculating process is simple, improves R wave extraction efficiency.
Furthermore electrocardiosignal collected is filtered using three cascade mathematics kenel filters, can be eliminated
Initially phenomena such as the baseline drift in electrocardiosignal, impulsive noise, above-mentioned phenomenon interference R wave is avoided to extract, to a certain degree raising R
The accuracy that wave extracts.Those of ordinary skill in the art may be aware that described in conjunction with the examples disclosed in this document each
Exemplary unit and algorithm steps can be realized with the combination of electronic hardware or computer software and electronic hardware.These
Function is implemented in hardware or software actually, the specific application and design constraint depending on technical solution.
Professional technician can use different methods to achieve the described function each specific application, still
Such implementation should not be considered as beyond the scope of the present invention.The above description is merely a specific embodiment, but of the invention
Protection scope is not limited thereto, and anyone skilled in the art in the technical scope disclosed by the present invention, can
Change or replacement are readily occurred in, should be covered by the protection scope of the present invention.Therefore, protection scope of the present invention is answered described
It is subject to the protection scope in claims.