tom-beer / Arrhythmia-CNN

Arrhythmia detection using deep convolutional neural network with long duration ECG signals
23 stars 10 forks source link

Changing the value of desired_segment_len gives error in creating target value #2

Open karimkhanvi opened 2 years ago

karimkhanvi commented 2 years ago

First of all thanks for doing nice work on slicing MIT-BIH data

I wanted to test the code with the 30s and 60s slices of ecg. I am able to create slices and get aux labels.

But it gives me error. That is obvious because I have different value in df.

target:N, num: 283
 len df: 326
target:L, num: 103
 len df: 56
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/var/folders/sc/2rv_t51115d2c6tn41s_7phc0000gq/T/ipykernel_14390/3835309512.py in <module>
     78 for cls, num in num_labels_we_have.items():
     79     print(f'target:{cls}, num: {num}')
---> 80     idx, sample_df_target, signals_target = sample_per_sym(seg_df, cls, num)
     81     sample_df.append(sample_df_target)
     82     signals.append(signals_target)

/var/folders/sc/2rv_t51115d2c6tn41s_7phc0000gq/T/ipykernel_14390/3835309512.py in sample_per_sym(seg_df, cls, num)
     65     # sample
     66     print(f' len df: {len(target_df)}')
---> 67     sample_df = target_df.sample(n=num)
     68 
     69     # add the index at the begining of the signal

~/Documents/avidhrt_ml_venv/lib/python3.7/site-packages/pandas/core/generic.py in sample(self, n, frac, replace, weights, random_state, axis)
   4863                              "provide positive value.")
   4864 
-> 4865         locs = rs.choice(axis_length, size=n, replace=replace, p=weights)
   4866         return self.take(locs, axis=axis, is_copy=False)
   4867 

mtrand.pyx in numpy.random.mtrand.RandomState.choice()

ValueError: Cannot take a larger sample than population when 'replace=False'

If I understand how you decided num_labels_dict value I can fix it for 30/60s strips. I checked your research paper and codes but did not get any clue.

Really appreciate your reply.