audrey06100 commited on
Commit
d92d76f
·
1 Parent(s): bc1a907
Files changed (2) hide show
  1. app_utils.py +6 -6
  2. utils.py +1 -2
app_utils.py CHANGED
@@ -334,13 +334,13 @@ def reorder_data(idx_order, orig_flags, inputname, filename):
334
  new_data = np.zeros((30, raw_data.shape[1]))
335
 
336
  zero_arr = np.zeros((1, raw_data.shape[1]))
337
- for i, (idx_set, flag) in enumerate(zip(idx_order, orig_flags)):
338
  if flag == True:
339
- new_data[i, :] = raw_data[idx_set[0], :]
340
- elif idx_set == [None]:
341
  new_data[i, :] = zero_arr
342
  else:
343
- tmp_data = [raw_data[j, :] for j in idx_set]
344
  new_data[i, :] = np.mean(tmp_data, axis=0)
345
 
346
  utils.save_data(new_data, filename)
@@ -355,9 +355,9 @@ def restore_order(batch_cnt, raw_data_shape, idx_order, orig_flags, filename, ou
355
  else:
356
  new_data = utils.read_train_data(outputname)
357
 
358
- for i, (idx_set, flag) in enumerate(zip(idx_order, orig_flags)):
359
  if flag == True:
360
- new_data[idx_set[0], :] = d_data[i, :]
361
 
362
  utils.save_data(new_data, outputname)
363
  return
 
334
  new_data = np.zeros((30, raw_data.shape[1]))
335
 
336
  zero_arr = np.zeros((1, raw_data.shape[1]))
337
+ for i, (indices, flag) in enumerate(zip(idx_order, orig_flags)):
338
  if flag == True:
339
+ new_data[i, :] = raw_data[indices[0], :]
340
+ elif indices == [None]:
341
  new_data[i, :] = zero_arr
342
  else:
343
+ tmp_data = [raw_data[j, :] for j in indices]
344
  new_data[i, :] = np.mean(tmp_data, axis=0)
345
 
346
  utils.save_data(new_data, filename)
 
355
  else:
356
  new_data = utils.read_train_data(outputname)
357
 
358
+ for i, (indices, flag) in enumerate(zip(idx_order, orig_flags)):
359
  if flag == True:
360
+ new_data[indices[0], :] = d_data[i, :]
361
 
362
  utils.save_data(new_data, outputname)
363
  return
utils.py CHANGED
@@ -42,7 +42,6 @@ def resample(signal, fs):
42
 
43
  return signal_new
44
 
45
- # "original to 256Hz" or "256Hz to original"
46
  def resample_(signal, current_fs, target_fs):
47
  fs = current_fs
48
  # downsample the signal to the target sample rate
@@ -261,7 +260,7 @@ def reconstruct(model_name, total, filepath, outputfile, samplerate):
261
  # -------------------delete_data---------------------------
262
  dataDelete(filepath+"temp2/")
263
  # --------------------resample-----------------------------
264
- signal = resample_(signal, 256, samplerate) # 256Hz to original sampling rate
265
  #print(signal.shape)
266
  # --------------------save_data----------------------------
267
  save_data(signal, filepath+outputfile)
 
42
 
43
  return signal_new
44
 
 
45
  def resample_(signal, current_fs, target_fs):
46
  fs = current_fs
47
  # downsample the signal to the target sample rate
 
260
  # -------------------delete_data---------------------------
261
  dataDelete(filepath+"temp2/")
262
  # --------------------resample-----------------------------
263
+ signal = resample_(signal, 256, samplerate)
264
  #print(signal.shape)
265
  # --------------------save_data----------------------------
266
  save_data(signal, filepath+outputfile)