问题描述
我正在尝试预处理我的数据,我决定做的一件事是纠正数据中的异常值。所以基本上超过±mult_std的样本值,其中mult_std是任何给定电压轨迹的标准偏差,被设置为±mult_std以纠正电压异常值。
唯一的问题是当我运行这段代码时
# Rectifying Outliers
for epoch in epoched:
epoch_mean = np.mean(epoch)
epoch_std = np.std(epoch)
a.append(epoch_std)
epoched_corrected.append(np.array([i - epoch_std * mult_std if i > epoch_mean + epoch_std * mult_std
else i + epoch_std * mult_std if i < epoch_mean - epoch_std * mult_std
else i for i in epoch]))
corrected_epoched_eeg_data.append(epoched_corrected)
我收到此错误:
(BCI_env) (base) mikaelhaji@Mikaels-MacBook-Pro mi % /Users/mikaelhaji/Environments/BCI_env/bin/python /Users/mikaelhaji/Desktop/mi/Preprocessing_MotorImagery.py
/Users/mikaelhaji/Desktop/mi/Preprocessing_MotorImagery.py:76: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this,you must specify 'dtype=object' when creating the ndarray.
epoched = np.array(array_epochs)
Traceback (most recent call last):
File "/Users/mikaelhaji/Desktop/mi/Preprocessing_MotorImagery.py",line 85,in <module>
epoched_corrected.append(np.array([i - epoch_std * mult_std if i > epoch_mean + epoch_std * mult_std
File "/Users/mikaelhaji/Desktop/mi/Preprocessing_MotorImagery.py",in <listcomp>
epoched_corrected.append(np.array([i - epoch_std * mult_std if i > epoch_mean + epoch_std * mult_std
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
关于我如何可能简化这个或为什么我会收到这个错误的任何想法。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)