Metadata-Version: 2.4
Name: biotechpy
Version: 0.3.0
Summary: Library for biosignal processing.
License-Expression: MIT
Keywords: ECG,QRS detection,ECG denoising
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: scipy
Requires-Dist: matplotlib
Requires-Dist: PyWavelets
Dynamic: license-file

# BioTechPy
A library that provides functions for ECG processing.

## Installation
```python
pip install biotechpy
```

## Requirements
NumPy, SciPy, Matplotlib, PyWavelets.

## License
MIT.

## Functions
### 1. Implementation of the Pan–Tompkins QRS detection algorithm (qrs_detection_pantompkins1985)
*Description:*  
The function is an exact implementation of the QRS detection algorithm described in the article and its corrections:  
> Pan J., Tompkins W.J. A real-time QRS detection algorithm. IEEE Transactions on Biomedical Engineering. 1985. Vol. 32, iss. 3. Pp. 230–236. DOI: 10.1109/TBME.1985.325532.

> Errata (http://www.engr.wisc.edu/bme/faculty/tompkins_willis/Errata_Pan-Tompkins.pdf).

*Citation:*  
If you use this function in your work, please cite:  
> Seleznev K.K. Open-Source Implementation of the Pan-Tompkins QRS Detection Algorithm. System Informatics. 2026. Iss. 32. Pp 1-16.

```python
# Usage:
import biotechpy
import matplotlib.pyplot as plt
qrs_coords = biotechpy.qrs_detection_pantompkins1985(signal=ecg_lead, fs=fs, visualisation=True)
plt.show()
```

### 2. Implementation of the ECG denoising algorithm (ecg_fs360hz_denoising_lilin2009)
*Description:* 
ECG denoising algorithm that works correctly only for signals with a sampling rate of 360 Hz. The algorithm is implemented according to the paper:
> S. Li, J. Lin. The optimal de-noising algorithm for ECG using stationary wavelet transform. 2009 World Congress on Computer Science and Information Engineering. 2009. Pp. 469 - 473. DOI: 10.1109/CSIE.2009.999.

The empirical Bayes threshold is implemented according to the paper cited in the references of (Li, Lin, 2009):
> I.M. Johnstone, B.W. Silverman. EbayesThresh: R Programs for Empirical Bayes Thresholding. Journal of Statistical Software. 2005. Vol. 12, iss. 8. DOI: 10.18637/jss.v012.i08.

```python
# Usage:
import biotechpy
import matplotlib.pyplot as plt
ecg_denoised = biotechpy.ecg_fs360hz_denoising_lilin2009(signal=ecg_lead, visualisation=True)
plt.show()
```

### 3. Heart rhythm analysis
#### 3.1. Calculation of heart rate trend (hr_trend_calculate)
*Description:*  
Function for calculating arrays to plot the heart rate trend (horizontal axis in samples).  

```python
# Usage:
import biotechpy
import matplotlib.pyplot as plt
hr_trend_x, hr_trend_y = biotechpy.hr_trend_calculate(r_coord, fs)
plt.plot(hr_trend_x, hr_trend_y)
plt.show()
```

#### 3.2. Calculation of RR interval trend (rr_trend_calculate)
*Description:*  
Function for calculating arrays to plot the RR interval trend (horizontal axis in samples).  

```python
# Usage:
import biotechpy
import matplotlib.pyplot as plt
rr_trend_x, rr_trend_y = biotechpy.rr_trend_calculate(r_coord, fs)
plt.plot(rr_trend_x, rr_trend_y)
plt.show()
```

#### 3.3. Calculation of heart rate parameters (hr_parameters_calculate)
*Description:*  
Function for calculating mean HR, standard deviation of HR, maximum HR, time index of maximum HR (in samples), minimum HR, and time index of minimum HR (in samples).  

```python
# Usage:
import biotechpy
hr_mean, hr_std, hr_max, hr_max_x, hr_min, hr_min_x = biotechpy.hr_parameters_calculate(hr_trend_x, hr_trend_y)
```

#### 3.4. Calculation of RR interval parameters (rr_parameters_calculate)
*Description:*  
Function for calculating mean RR interval, standard deviation of RR interval, maximum RR interval, time index of maximum RR interval (in samples), minimum RR interval, and time index of minimum RR interval (in samples).  

```python
# Usage:
import biotechpy
rr_mean, rr_std, rr_max, rr_max_x, rr_min, rr_min_x = biotechpy.rr_parameters_calculate(rr_trend_x, rr_trend_y)
```
