|
14 | 14 |
|
15 | 15 | from wfdb.io import _header |
16 | 16 | from wfdb.io import _signal |
| 17 | +from wfdb.io import _url |
17 | 18 | from wfdb.io import download |
18 | 19 | from wfdb.io import annotation |
19 | 20 |
|
@@ -1466,8 +1467,8 @@ def edf2mit(record_name, pn_dir=None, delete_file=True, record_only=True, |
1466 | 1467 | file_url = posixpath.join(download.PN_INDEX_URL, pn_dir, record_name) |
1467 | 1468 | # Currently must download file for MNE to read it though can give the |
1468 | 1469 | # user the option to delete it immediately afterwards |
1469 | | - r = requests.get(file_url, allow_redirects=False) |
1470 | | - open(record_name, 'wb').write(r.content) |
| 1470 | + with _url.openurl(file_url, 'rb') as f: |
| 1471 | + open(record_name, 'wb').write(f.read()) |
1471 | 1472 |
|
1472 | 1473 | # Open the desired file |
1473 | 1474 | edf_file = open(record_name, mode='rb') |
@@ -2380,8 +2381,8 @@ def wav2mit(record_name, pn_dir=None, delete_file=True, record_only=False): |
2380 | 2381 | file_url = posixpath.join(download.PN_INDEX_URL, pn_dir, record_name) |
2381 | 2382 | # Currently must download file to read it though can give the |
2382 | 2383 | # user the option to delete it immediately afterwards |
2383 | | - r = requests.get(file_url, allow_redirects=False) |
2384 | | - open(record_name, 'wb').write(r.content) |
| 2384 | + with _url.openurl(file_url, 'rb') as f: |
| 2385 | + open(record_name, 'wb').write(f.read()) |
2385 | 2386 |
|
2386 | 2387 | wave_file = open(record_name, mode='rb') |
2387 | 2388 | record_name_out = record_name.split(os.sep)[-1].replace('-','_').replace('.wav','') |
|
0 commit comments