1
1
import datetime
2
2
import multiprocessing .dummy
3
- import posixpath
4
3
import os
4
+ import posixpath
5
5
import re
6
6
7
7
import fsspec
8
8
import numpy as np
9
9
import pandas as pd
10
10
11
- from wfdb .io import _header
12
- from wfdb .io import _signal
13
- from wfdb .io import _url
14
- from wfdb .io .archive import get_archive
15
- from wfdb .io import download
16
- from wfdb .io import header
17
- from wfdb .io import util
11
+ from wfdb .io import _header , _signal , _url , download , header , util
18
12
from wfdb .io ._coreio import CLOUD_PROTOCOLS
19
-
13
+ from wfdb . io . archive import get_archive
20
14
21
15
# -------------- WFDB Signal Calibration and Classification ---------- #
22
16
@@ -935,13 +929,17 @@ def wrsamp(self, expanded=False, write_dir="", wfdb_archive=None):
935
929
936
930
# Perform field validity and cohesion checks, and write the
937
931
# header file.
938
- self .wrheader (write_dir = write_dir , expanded = expanded ,
939
- wfdb_archive = wfdb_archive )
932
+ self .wrheader (
933
+ write_dir = write_dir , expanded = expanded , wfdb_archive = wfdb_archive
934
+ )
940
935
if self .n_sig > 0 :
941
936
# Perform signal validity and cohesion checks, and write the
942
937
# associated dat files.
943
- self .wr_dats (expanded = expanded , write_dir = write_dir ,
944
- wfdb_archive = wfdb_archive )
938
+ self .wr_dats (
939
+ expanded = expanded ,
940
+ write_dir = write_dir ,
941
+ wfdb_archive = wfdb_archive ,
942
+ )
945
943
946
944
def _arrange_fields (self , channels , sampfrom , smooth_frames ):
947
945
"""
@@ -2046,10 +2044,13 @@ def rdrecord(
2046
2044
hea_file = os .path .basename (record_base ) + ".hea"
2047
2045
2048
2046
import tempfile
2047
+
2049
2048
with wfdb_archive .open (hea_file , "r" ) as f :
2050
2049
header_str = f .read ()
2051
2050
2052
- with tempfile .NamedTemporaryFile ("w+" , suffix = ".hea" , delete = False ) as tmpf :
2051
+ with tempfile .NamedTemporaryFile (
2052
+ "w+" , suffix = ".hea" , delete = False
2053
+ ) as tmpf :
2053
2054
tmpf .write (header_str )
2054
2055
tmpf .flush ()
2055
2056
record = rdheader (tmpf .name )
@@ -2074,7 +2075,9 @@ def rdrecord(
2074
2075
if "." not in pn_dir :
2075
2076
dir_list = pn_dir .split ("/" )
2076
2077
pn_dir = posixpath .join (
2077
- dir_list [0 ], download .get_version (dir_list [0 ]), * dir_list [1 :]
2078
+ dir_list [0 ],
2079
+ download .get_version (dir_list [0 ]),
2080
+ * dir_list [1 :],
2078
2081
)
2079
2082
2080
2083
record = rdheader (record_name , pn_dir = pn_dir , rd_segments = False )
@@ -2783,7 +2786,9 @@ def wfdbtime(record_name, input_times, pn_dir=None):
2783
2786
)
2784
2787
if not times .startswith ("s" ):
2785
2788
sample_num = int (
2786
- sum (x * 60 ** i for i , x in enumerate ([seconds , minutes , hours ]))
2789
+ sum (
2790
+ x * 60 ** i for i , x in enumerate ([seconds , minutes , hours ])
2791
+ )
2787
2792
* record .fs
2788
2793
)
2789
2794
sample_num = "s" + str (sample_num )
@@ -3080,11 +3085,14 @@ def wrsamp(
3080
3085
expanded = False
3081
3086
3082
3087
if wfdb_archive :
3083
- wfdb_archive = get_archive (os .path .join (write_dir , record_name ),
3084
- mode = "w" )
3088
+ wfdb_archive = get_archive (
3089
+ os .path .join (write_dir , record_name ), mode = "w"
3090
+ )
3085
3091
3086
3092
# Write the record files - header and associated dat
3087
- record .wrsamp (write_dir = write_dir , expanded = expanded , wfdb_archive = wfdb_archive )
3093
+ record .wrsamp (
3094
+ write_dir = write_dir , expanded = expanded , wfdb_archive = wfdb_archive
3095
+ )
3088
3096
3089
3097
3090
3098
def dl_database (
0 commit comments