1010import pandas as pd
1111
1212from wfdb .io import _header , _signal , _url , download , header , util
13- from wfdb .io ._coreio import CLOUD_PROTOCOLS
13+ from wfdb .io ._coreio import CLOUD_PROTOCOLS , _join_path , _split_path
1414from wfdb .io .archive import WFDBArchive , archive_for_writing , is_archive_path
1515
1616# -------------- WFDB Signal Calibration and Classification ---------- #
@@ -169,8 +169,8 @@ class BaseRecord:
169169 files are searched for locally, or when `record_name` is a
170170 supported cloud URI, they are read directly from cloud storage
171171 via `fsspec`. Supported URIs: `s3://`, `gs://`, `az://`,
172- `azureml://`. Install the appropriate `fsspec` backend
173- (e.g., `s3fs`, `gcsfs`, `adlfs`).
172+ `azureml://`, `memory://`. Other than for `memory://`, install the
173+ appropriate `fsspec` backend (e.g., `s3fs`, `gcsfs`, `adlfs`).
174174 n_sig : int, optional
175175 Total number of signals.
176176 fs : int, float, optional
@@ -700,8 +700,8 @@ class Record(BaseRecord, _header.HeaderMixin, _signal.SignalMixin):
700700 files are searched for locally, or when `record_name` is a
701701 supported cloud URI, they are read directly from cloud storage
702702 via `fsspec`. Supported URIs: `s3://`, `gs://`, `az://`,
703- `azureml://`. Install the appropriate `fsspec` backend
704- (e.g., `s3fs`, `gcsfs`, `adlfs`).
703+ `azureml://`, `memory://`. Other than for `memory://`, install the
704+ appropriate `fsspec` backend (e.g., `s3fs`, `gcsfs`, `adlfs`).
705705 n_sig : int, optional
706706 Total number of signals.
707707 fs : float, optional
@@ -1080,8 +1080,8 @@ class MultiRecord(BaseRecord, _header.MultiHeaderMixin):
10801080 files are searched for locally, or when `record_name` is a
10811081 supported cloud URI, they are read directly from cloud storage
10821082 via `fsspec`. Supported URIs: `s3://`, `gs://`, `az://`,
1083- `azureml://`. Install the appropriate `fsspec` backend
1084- (e.g., `s3fs`, `gcsfs`, `adlfs`).
1083+ `azureml://`, `memory://`. Other than for `memory://`, install the
1084+ appropriate `fsspec` backend (e.g., `s3fs`, `gcsfs`, `adlfs`).
10851085 n_sig : int, optional
10861086 Total number of signals.
10871087 fs : int, float, optional
@@ -1837,10 +1837,10 @@ def rdheader(record_name, pn_dir=None, rd_segments=False):
18371837 files are searched for locally, or when `record_name` is a
18381838 supported cloud URI, they are read directly from cloud storage
18391839 via `fsspec`. Supported URIs: `s3://`, `gs://`, `az://`,
1840- `azureml://`. Install the appropriate `fsspec` backend
1841- (e.g., `s3fs`, `gcsfs`, `adlfs`). To read the header from a
1842- local .wfdb archive, pass the path of the archive including the
1843- .wfdb extension.
1840+ `azureml://`, `memory://`. Other than for `memory://`, install the
1841+ appropriate `fsspec` backend (e.g., `s3fs`, `gcsfs`, `adlfs`).
1842+ To read the header from a local .wfdb archive, pass the path of
1843+ the archive including the .wfdb extension.
18441844 pn_dir : str, optional
18451845 Option used to stream data from Physionet. The Physionet
18461846 database directory from which to find the required record files.
@@ -1861,7 +1861,7 @@ def rdheader(record_name, pn_dir=None, rd_segments=False):
18611861 >>> ecg_record = wfdb.rdheader('100', pn_dir='mitdb')
18621862
18631863 """
1864- dir_name , base_record_name = os . path . split (record_name )
1864+ dir_name , base_record_name = _split_path (record_name )
18651865 file_name = f"{ base_record_name } .hea"
18661866
18671867 # Read the header, and any segment headers, from a .wfdb archive
@@ -1873,10 +1873,9 @@ def rdheader(record_name, pn_dir=None, rd_segments=False):
18731873 _read_segment_headers (record , dir_name , pn_dir , archive )
18741874 return record
18751875
1876- # If this is a cloud path, use posixpath to construct the path and fsspec to open
1877- # file
1876+ # If this is a cloud path, use fsspec to open the file
18781877 if any (dir_name .startswith (proto ) for proto in CLOUD_PROTOCOLS ):
1879- with fsspec .open (posixpath . join (dir_name , file_name ), mode = "r" ) as f :
1878+ with fsspec .open (_join_path (dir_name , file_name ), mode = "r" ) as f :
18801879 header_content = f .read ()
18811880
18821881 # If the PhysioNet database path is provided, construct the download path using the
@@ -1942,7 +1941,7 @@ def _read_record_header(record_name, dir_name, pn_dir, wfdb_archive):
19421941 """
19431942 if wfdb_archive is not None :
19441943 return _parse_header_content (wfdb_archive .read_header (record_name ))
1945- return rdheader (os . path . join (dir_name , record_name ), pn_dir = pn_dir )
1944+ return rdheader (_join_path (dir_name , record_name ), pn_dir = pn_dir )
19461945
19471946
19481947def _read_segment_headers (record , dir_name , pn_dir , wfdb_archive ):
@@ -2069,10 +2068,10 @@ def rdrecord(
20692068 files are searched for locally, or when `record_name` is a
20702069 supported cloud URI, they are read directly from cloud storage
20712070 via `fsspec`. Supported URIs: `s3://`, `gs://`, `az://`,
2072- `azureml://`. Install the appropriate `fsspec` backend
2073- (e.g., `s3fs`, `gcsfs`, `adlfs`). To read a record from a local
2074- .wfdb archive, pass the path of the archive including the .wfdb
2075- extension.
2071+ `azureml://`, `memory://`. Other than for `memory://`, install the
2072+ appropriate `fsspec` backend (e.g., `s3fs`, `gcsfs`, `adlfs`).
2073+ To read a record from a local .wfdb archive, pass the path of
2074+ the archive including the .wfdb extension.
20762075 sampfrom : int, optional
20772076 The starting sample number to read for all channels.
20782077 sampto : int, 'end', optional
@@ -2201,7 +2200,7 @@ def _rdrecord(
22012200 archive.
22022201
22032202 """
2204- dir_name , base_record_name = os . path . split (record_name )
2203+ dir_name , base_record_name = _split_path (record_name )
22052204 # Update the dir_name using abspath unless it is a cloud path
22062205 if not any (dir_name .startswith (proto ) for proto in CLOUD_PROTOCOLS ):
22072206 dir_name = os .path .abspath (dir_name )
@@ -2409,7 +2408,7 @@ def _rdrecord(
24092408 )
24102409 else :
24112410 record .segments [seg_num ] = rdrecord (
2412- os . path . join (dir_name , record .seg_name [seg_num ]),
2411+ _join_path (dir_name , record .seg_name [seg_num ]),
24132412 sampfrom = seg_ranges [i ][0 ],
24142413 sampto = seg_ranges [i ][1 ],
24152414 channels = seg_channels [i ],
@@ -2470,8 +2469,8 @@ def rdsamp(
24702469 files are searched for locally, or when `record_name` is a
24712470 supported cloud URI, they are read directly from cloud storage
24722471 via `fsspec`. Supported URIs: `s3://`, `gs://`, `az://`,
2473- `azureml://`. Install the appropriate `fsspec` backend
2474- (e.g., `s3fs`, `gcsfs`, `adlfs`).
2472+ `azureml://`, `memory://`. Other than for `memory://`, install the
2473+ appropriate `fsspec` backend (e.g., `s3fs`, `gcsfs`, `adlfs`).
24752474 sampfrom : int, optional
24762475 The starting sample number to read for all channels.
24772476 sampto : int, 'end', optional
@@ -2590,8 +2589,8 @@ def sampfreq(record_name, pn_dir=None):
25902589 files are searched for locally, or when `record_name` is a
25912590 supported cloud URI, they are read directly from cloud storage
25922591 via `fsspec`. Supported URIs: `s3://`, `gs://`, `az://`,
2593- `azureml://`. Install the appropriate `fsspec` backend
2594- (e.g., `s3fs`, `gcsfs`, `adlfs`).
2592+ `azureml://`, `memory://`. Other than for `memory://`, install the
2593+ appropriate `fsspec` backend (e.g., `s3fs`, `gcsfs`, `adlfs`).
25952594 pn_dir : str, optional
25962595 Option used to stream data from Physionet. The Physionet
25972596 database directory from which to find the required record files.
@@ -2640,8 +2639,8 @@ def signame(record_name, pn_dir=None, sig_nums=[]):
26402639 files are searched for locally, or when `record_name` is a
26412640 supported cloud URI, they are read directly from cloud storage
26422641 via `fsspec`. Supported URIs: `s3://`, `gs://`, `az://`,
2643- `azureml://`. Install the appropriate `fsspec` backend
2644- (e.g., `s3fs`, `gcsfs`, `adlfs`).
2642+ `azureml://`, `memory://`. Other than for `memory://`, install the
2643+ appropriate `fsspec` backend (e.g., `s3fs`, `gcsfs`, `adlfs`).
26452644 pn_dir : str, optional
26462645 Option used to stream data from Physionet. The Physionet
26472646 database directory from which to find the required record files.
@@ -2699,8 +2698,8 @@ def wfdbdesc(record_name, pn_dir=None):
26992698 files are searched for locally, or when `record_name` is a
27002699 supported cloud URI, they are read directly from cloud storage
27012700 via `fsspec`. Supported URIs: `s3://`, `gs://`, `az://`,
2702- `azureml://`. Install the appropriate `fsspec` backend
2703- (e.g., `s3fs`, `gcsfs`, `adlfs`).
2701+ `azureml://`, `memory://`. Other than for `memory://`, install the
2702+ appropriate `fsspec` backend (e.g., `s3fs`, `gcsfs`, `adlfs`).
27042703 pn_dir : str, optional
27052704 Option used to stream data from Physionet. The Physionet
27062705 database directory from which to find the required record files.
@@ -2833,8 +2832,8 @@ def wfdbtime(record_name, input_times, pn_dir=None):
28332832 files are searched for locally, or when `record_name` is a
28342833 supported cloud URI, they are read directly from cloud storage
28352834 via `fsspec`. Supported URIs: `s3://`, `gs://`, `az://`,
2836- `azureml://`. Install the appropriate `fsspec` backend
2837- (e.g., `s3fs`, `gcsfs`, `adlfs`).
2835+ `azureml://`, `memory://`. Other than for `memory://`, install the
2836+ appropriate `fsspec` backend (e.g., `s3fs`, `gcsfs`, `adlfs`).
28382837 input_times : str, list
28392838 The desired times (or samples) to be converted and displayed for the
28402839 chosen record. This can either be a single string, or a list of
0 commit comments