Skip to content

Commit

Permalink
Adding new org of .md
Browse files Browse the repository at this point in the history
  • Loading branch information
lcsrodriguez committed Jul 22, 2022
1 parent c5a6eb5 commit eee6b9a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 55 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ data/
__pycache__
.idea/
out/*
*.xlsx
*.xlsx
PRIVATE_NOTES
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,7 @@ If you choose the cloning method, please perform a prelinimary step: installing

## Resources

Here are some useful online resources in order to get a clear understanding of the .hea/.dat files format:
- https://www.physionet.org/physiotools/wag/header-5.htm
- https://archive.physionet.org/tutorials/creating-records.shtml
- https://archive.physionet.org/faq.shtml#wfdbdigitalorphysical
- https://www.physionet.org/physiotools/wag/wag.pdf

See [RESOURCES](docs/RESOURCES.md).

## Acknowledgement

Expand Down
7 changes: 7 additions & 0 deletions docs/RESOURCES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Technical resources regarding `wfdb` files

Here are some useful online resources in order to get a clear understanding of the .hea/.dat files format:
- https://www.physionet.org/physiotools/wag/header-5.htm
- https://archive.physionet.org/tutorials/creating-records.shtml
- https://archive.physionet.org/faq.shtml#wfdbdigitalorphysical
- https://www.physionet.org/physiotools/wag/wag.pdf
53 changes: 6 additions & 47 deletions headat/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ def __init__(self, record: str = "", title: str = "") -> None:
if not isinstance(record, str) or not isinstance(title, str):
raise TypeError("Record and title must be string values.")
if record == "":
print(f"No record has been submitted.\n Please consider adding one to the view by doing .add_record("
f"record_name)")
#print(f"No record has been submitted.\nPlease consider adding one to the view by doing .add_record("
# f"record_name)")
pass
else:
# Registering the record name
if not self.add_record(record):
Expand Down Expand Up @@ -122,14 +123,12 @@ def download_sources(self, url_parent_folder: str = "") -> bool:
# Creation of a dedicated sub-folder named "samples/"
path_filename = f"{self.folder_name}samples/"
self.samples_foldername = path_filename
print("ok")
if not os.path.isdir(path_filename) or not os.path.exists(path_filename):
try:
os.mkdir(path_filename)
except Exception as e:
raise Exception("An error has occured during the sub-folder creation process.\nError details: {e}")

print(path_filename)
# Processing the URL
# Checking if the record name is an URL
if validators.url(url_parent_folder):
Expand All @@ -155,7 +154,7 @@ def download_sources(self, url_parent_folder: str = "") -> bool:
}

# Downloading the files
for file, link in tqdm.tqdm(links.items()):
for file, link in tqdm.tqdm(links.items(), colour="blue"):
tqdm.tqdm.write(f"Processing link : {link}")
wget.download(url=link,
out=f"{self.samples_foldername}{file}",
Expand All @@ -170,12 +169,11 @@ def download_sources(self, url_parent_folder: str = "") -> bool:
raise ValueError("Headat only covers HTTPS protocol for web resources.")
except Exception as e:
raise Exception(f"An exception has occured during ")

# If not, it's a local file and we simply read it using wfdb
else:
raise ValueError("The argument specified is not a valid URL.")

# TODO : pour add record, on peut spécifier une URL également pointant vers un .hea en ligne (puis on s'occupe de récupérer les fichiers respectifs grâce à la méthode précédente

def add_record(self, record: str = None) -> bool:
"""
Function allowing user to add a record to the view
Expand All @@ -190,8 +188,6 @@ def add_record(self, record: str = None) -> bool:
# Increment the number of initialized views in order to get a count
HDView.VIEWS_INITIALIZED_COUNTER += 1

# TODO Add a split method in case which the record_name contains any extension (.hea, .dat, ...)

# Checking if the record name is an URL
if validators.url(record):
url = urlparse(record)
Expand Down Expand Up @@ -219,7 +215,6 @@ def add_record(self, record: str = None) -> bool:
# We have the path to a .hea file
record = record.split(".")[0]

print(record)
# Reading the file
read_rec = wf.rdsamp(record)

Expand Down Expand Up @@ -536,7 +531,7 @@ def t_sql(self, **kwargs) -> bool:
:rtype: bool
:return: Boolean set to True if conversion has been successfully performed
"""
# TODO
# TODO To be implemented
pass

def t_matlab(self, **kwargs) -> bool:
Expand Down Expand Up @@ -639,39 +634,3 @@ def t_hdf5(self, **kwargs) -> bool:
except Exception as e:
print(e)
return False

# ----------------------------------------------------------------
# GENERIC METHODS

def get_records_hashes(self):
"""
Function computing and returning the different hashes of the record files.
:return:
"""
import hashlib
BLOCKSIZE = 65536
hasher = hashlib.md5()
# TODO : Complete function (check Twitter post)

"""
1 record <-> 1 or more signals
------------------------------------------------
1 record <-> 1 HDView
- useful for extracting entire or partial signals and entire records or selected signals from 1 record
- importing them as numpy array or pandas DataFrame, series, dictionnary, Python list
- exporting them to specific formats:
- csv, xlsx, json, xml
- text file with specific extension (.txt, .out, .dat, ...)
- latex, markdown, html
- pickle
- parquet
- hdfs
- sqlite
- matlab
- wav
- extracting useful information
------------------------------------------------
1 or more records <-> 1 HDGroup ==> Goal: statistical comparison
- do the same as with 1 HDView but concat the multiple records side-by-side
"""
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

a = HDView()
#a.add_record(file)
a.add_record("samples/aami3a")
a.add_record("https://physionet.org/files/cebsdb/1.0.0/b001.hea")
a.t_html()
#a.add_record("https://physionet.org/files/aami-ec13/1.0.0/")
#a.t_html()
Expand Down

0 comments on commit eee6b9a

Please sign in to comment.