nabeelraza commited on
Commit
e2c21d9
·
1 Parent(s): 15c3075

resolving the encoding issue

Browse files
Files changed (2) hide show
  1. make_predictions.py +1 -1
  2. read_data.py +4 -9
make_predictions.py CHANGED
@@ -1,5 +1,5 @@
1
  import numpy as np
2
- from read_data import prepare_all_leads, visualize_sig
3
  from postprocessing import make_predictions_indi, labels_map
4
  from scipy import stats as st
5
  import warnings
 
1
  import numpy as np
2
+ from read_data import prepare_all_leads
3
  from postprocessing import make_predictions_indi, labels_map
4
  from scipy import stats as st
5
  import warnings
read_data.py CHANGED
@@ -2,21 +2,16 @@ import numpy as np
2
  from scipy.signal import resample
3
  from baseline_wander_removal import bw_remover
4
  import pywt
5
- import matplotlib.pyplot as plt
 
6
 
7
  def normalize(sig):
8
  return 2*((sig-np.min(sig))/(np.max(sig)-np.min(sig)))
9
 
10
- def visualize_sig(sig):
11
- fig, ax = plt.subplots(3, 1, figsize=(10, 10))
12
- ax[0].plot(sig[0][:500])
13
- ax[1].plot(sig[1][:500])
14
- ax[2].plot(sig[2][:500])
15
- plt.show()
16
-
17
  def prepare_all_leads(path):
18
  if path.endswith(".txt"):
19
- sig = np.loadtxt(path, delimiter=',', unpack=True, encoding=None)
 
20
  elif path.endswith(".npy"):
21
  sig = np.load(path, allow_pickle=True)
22
  x = pywt.wavedec(sig[0], 'db6', level=2)[0]
 
2
  from scipy.signal import resample
3
  from baseline_wander_removal import bw_remover
4
  import pywt
5
+ # import matplotlib.pyplot as plt
6
+ import codecs
7
 
8
  def normalize(sig):
9
  return 2*((sig-np.min(sig))/(np.max(sig)-np.min(sig)))
10
 
 
 
 
 
 
 
 
11
  def prepare_all_leads(path):
12
  if path.endswith(".txt"):
13
+ filecp = codecs.open(path, "r", encoding="base64")
14
+ sig = np.loadtxt(filecp, delimiter=',', unpack=True, encoding=None)
15
  elif path.endswith(".npy"):
16
  sig = np.load(path, allow_pickle=True)
17
  x = pywt.wavedec(sig[0], 'db6', level=2)[0]