breathfinder
A python3 library designed to locate individual breaths within a PSG using the thoracic RIP signal.
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.5%) to scientific vocabulary
Repository
A python3 library designed to locate individual breaths within a PSG using the thoracic RIP signal.
Basic Info
- Host: GitHub
- Owner: benedikthth
- License: mit
- Language: Python
- Default Branch: main
- Size: 37.1 KB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
- Releases: 0
Metadata Files
README.md
BreathFinder

A python3 module implemented an algorithm designed to locate individual breaths within a PSG using the thoracic RIP signal. The algorithm was validated on a thoracic RIP signal that was sampled with 25hz sampling frequency. Currently, the algorithm is un-validated on any other sampling frequency.
The result of the evaluation was that this algorithm found around 94\% of breaths correctly, with only 5\% of predictions being false positives.
Installation
```console bla@bla:~$ git clone git@github.com:benedikthth/BreathFinder.git
bla@bla:~$ cd BreathFinder
bla@bla:~$ pip install -e . ```
Currently, the package is in development, and is not released on PiPy. The installation was tested on an ubuntu 20 system.
Usage
Basic use case
The following use cases assume that you have loaded a thoracic RIP signal in the form of a python list into the variable signal, and that you stored the sampling frequency of the signal in the variable sampling_frequency.
```python import BreathFinder as BF breathlocations = BF.findbreaths(signal, sampling_freuency)
output is a list of breaths in the format [start, duration]
where start is the timestamp of the breath-start in seconds
since the signal start, and duration is the
duration of the breath in seconds.
breath_locations = [[1, 2], ...]
```
Run-time Estimation
The BreathFinder run time can be estimated using the estimate_run_time function.
python
import BreathFinder as BF
et = BF.estimate_run_time(signal, sampling_frequency)
print(f'The algorithm is estimated to process this recording in {et/60} minutes')
This is just an estimation however, the algorithm may take more, or less time to locate the breaths within the signal.
Parallelization
BreathFinder does not support multiprocessing as part of the package. However, a potential workaround for that is to split the signal up into smaller segments, and process each segment individually. The following code is a template for how to accomplish this, but there may still be some issues associated with this approach, as currently, this package does not support multiprocessing natively.
```python import BreathFinder as BF from multiprocessing import Pool
calculate how many samples are in a 10 minute window
window_size = int(1060fs)
split signal into 10 minute segments
We prepare a list of (signal, sampling_frequency, offset)
tuples, this is necessary in order to use multiprocessing correctly.
signals = [ (signal[i:i+windowsize, fs, i)] for i in range(0, len(signal), windowsize)]
Define a function that handles a single signal segment
def mapBF(signal, fs, offset): # calculate the offset in seconds. offsetseconds = offset/fs # run BF breaths = BF.findbreats(signal, fs) # fix offset for breaths breaths = [(b[0]+offsetseconds, b[1]) for b in breaths] return breaths
use 4 processes
with Pool(4) as p: # This returns a list of lists containing individual breaths breathslistlist = p.starmap(map_BF, signals)
flatten the breaths list
breaths = [breath for breathlist in breathslistlist for breath in breathlist]
Now you might have issues with the fact that
depending on how the signal is split up the
algorithm migth miss the first breath, last
breath, or both. It might be useful to include
some seconds of overlap between the windows.
and then deal with the double-detections.
For dealing with double detections, you can do the following:
breaths = BF.postprocess(breaths, signal, fs)
This is not tested, and if you find that there
are issues with this approach, please let me know
```
Contact information
If there are any issues with the installation, running the algorithm, or general questions, please send me a message at b@spock.is
Owner
- Name: Benedikt Hólm Þórðarson
- Login: benedikthth
- Kind: user
- Location: Iceland
- Website: http://www.spock.is
- Repositories: 41
- Profile: https://github.com/benedikthth
Icelandic computer networks nerd, born in 1993. Working on my MSc in computer science at Reykjavik University focused on sleep research & machine learning
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: Holm
given-names: Benedikt
orcid: https://orcid.org/0000-0001-7213-2035
title: "BreathFinder"
version: 1.0.0
#doi: coming soon
date-released: 2020-08-1
GitHub Events
Total
Last Year
Committers
Last synced: over 3 years ago
All Time
- Total Commits: 16
- Total Committers: 1
- Avg Commits per committer: 16.0
- Development Distribution Score (DDS): 0.0
Top Committers
| Name | Commits | |
|---|---|---|
| Your Name | b****h@g****m | 16 |
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 1
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 1
- Total pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- benedikthth (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- numpy *
- scipy *
- sklearn *