我正在尝试预处理我的数据,而我决定做的一件事是纠正数据中的异常值。因此,基本上超过 ±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", line 85, 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()
关于我如何可能简化这个或为什么我得到这个错误的任何想法。