raphaelvallat / yasa

YASA (Yet Another Spindle Algorithm): a Python package to analyze polysomnographic sleep recordings.
https://raphaelvallat.com/yasa/
BSD 3-Clause "New" or "Revised" License
417 stars 113 forks source link

data in uV ; summary error #77

Closed apoorva6262 closed 2 years ago

apoorva6262 commented 2 years ago

Hi @raphaelvallat , I am trying detect spindles in this rem dataset. The unit of the data is 0.4781623844622306V. I converted this to uV but then I am getting this error. Also, why am I getting an error for the summary?

sig *= 478162.384462230606 spindles= yasa.spindles_detect(sig, sf=Fs, ch_names=['C3','C4'],freq_sp=(11, 15), freq_broad=(2, 30), duration=(0.5, 2), min_distance=500, thresh={'rel_pow': 0.2, 'corr': 0.65, 'rms': 1.5}, multi_only=False, remove_outliers=False, verbose=False) spindles.summary(grp_chan=True, grp_stage=True)

Screenshot 2022-06-13 at 16 11 09
raphaelvallat commented 2 years ago

Hi @apoorva6262,

I think that the conversion did not work, the unit of your data is too large (standard deviation 17352) and therefore the spindles_detection function failed. As a result, YASA returns None for the spindles detection and calling None.summary leads to the above error.

Please make sure that the unit of your data is micro-Volts. The standard deviation of the data should be <1000 uV. You may want to rescale, filter and/or remove extreme values from your data. Please also make sure to visualize your data, I recommend the free software EDFBrowser.

Thanks, Raphael

apoorva6262 commented 2 years ago

Thanks @raphaelvallat . How do you rescale it ? I tried to just convert it first to mV (code below) and then to uV. The value is still large. I am doubting if the format of the file itself is in a different scale. some_edf_channels = ['C3','C4'] chan_data = epochs.get_data(some_edf_channels) print(np.sum(np.abs(chan_data))/chan_data.size)#mV Here is the plot of the data (40uv) and then I zoomed out to 14000000uv.

Screenshot 2022-06-13 at 17 45 28 Screenshot 2022-06-13 at 17 44 05
raphaelvallat commented 2 years ago

Try

chan_data = epochs.get_data(some_edf_channels, units="uV")
apoorva6262 commented 2 years ago

That works! Thanks!