sig_txt: [45 67 83 32767 101 90 50]
idx_rr:[101] // index after 32767
sig: [45 67 83 101 90 50] // all the elements except 32767
Basically what happens is from the original array, all except the element whose value is equal to 32767 is passed to the sig array. And idx_rr gets the value immediate after 32767. I have written a python for the same. But I am getting this error:
"'int' object does not support item assignment"
when I am trying to plot the idx_rr value of sig. Can I get some help on this.
R_peak = False
j = 0
k = 0
idx_rr = []
sig = []
for i in range (len(sig_txt)):
if (sig_txt[i] == 32767):
idx_rr = i+1
idx_rr[j] = np.array(sig_txt[i+1])
sig = i+1
sig[k] = np.array(sig_txt[i+1])
k = k + 1
j = j + 1
print(idx_rr)
R_peak = True
else:
if (R_peak == False):
sig = i
sig[k] = np.array(sig_txt[i])
k = k + 1
else:
R_peak = False
plt.figure(figsize=(20,8))
plt.plot(sig)
plt.scatter([idx_rr], [sig[idx_rr]], c='g')
plt.show()
TypeError Traceback (most recent call last)
<ipython-input-1474-dcea2717b9f2> in <module>
----> 1 get_intervals('/home/yasaswini/hp2-notebooks/ecg_data
/Recorded_Data_Patch_Simulator/TXT_Files
/ECG_data_128Hz_Simulator_Patch_Normal_data.txt',128)
<ipython-input-1471-5a6b384defd1> in get_intervals(fname,sampling_rate)
22 if (R_peak == False):
23 sig = i
---> 24 sig[k] = np.array(sig_txt[i])
25 k = k + 1
26
TypeError: 'int' object does not support item assignment
idx_rr = i+1is assigning the index after 32767 to idx_rr.