accusleepy 0.6.0__py3-none-any.whl → 0.7.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,7 +32,7 @@ from PySide6.QtWidgets import (
32
32
  )
33
33
 
34
34
  from accusleepy.constants import UNDEFINED_LABEL
35
- from accusleepy.fileio import load_config, save_labels
35
+ from accusleepy.fileio import load_config, save_labels, EMGFilter
36
36
  from accusleepy.gui.mplwidget import resample_x_ticks
37
37
  from accusleepy.gui.viewer_window import Ui_ViewerWindow
38
38
  from accusleepy.signal_processing import create_spectrogram, get_emg_power
@@ -102,6 +102,7 @@ class ManualScoringWindow(QDialog):
102
102
  confidence_scores: np.array,
103
103
  sampling_rate: int | float,
104
104
  epoch_length: int | float,
105
+ emg_filter: EMGFilter,
105
106
  ):
106
107
  """Initialize the manual scoring window
107
108
 
@@ -112,6 +113,7 @@ class ManualScoringWindow(QDialog):
112
113
  :param confidence_scores: confidence scores
113
114
  :param sampling_rate: sampling rate, in Hz
114
115
  :param epoch_length: epoch length, in seconds
116
+ :param emg_filter: EMG filter parameters
115
117
  """
116
118
  super(ManualScoringWindow, self).__init__()
117
119
 
@@ -122,6 +124,7 @@ class ManualScoringWindow(QDialog):
122
124
  self.confidence_scores = confidence_scores
123
125
  self.sampling_rate = sampling_rate
124
126
  self.epoch_length = epoch_length
127
+ self.emg_filter = emg_filter
125
128
 
126
129
  self.n_epochs = len(self.labels)
127
130
 
@@ -131,7 +134,7 @@ class ManualScoringWindow(QDialog):
131
134
  self.setWindowTitle("AccuSleePy manual scoring window")
132
135
 
133
136
  # load set of valid brain states
134
- self.brain_state_set, _, _ = load_config()
137
+ self.brain_state_set, _, _, _, _, _, _ = load_config()
135
138
 
136
139
  # initial setting for number of epochs to show in the lower plot
137
140
  self.epochs_to_show = 5
@@ -153,7 +156,7 @@ class ManualScoringWindow(QDialog):
153
156
 
154
157
  # calculate RMS of EMG for each epoch and apply a ceiling
155
158
  self.upper_emg = create_upper_emg_signal(
156
- self.emg, self.sampling_rate, self.epoch_length
159
+ self.emg, self.sampling_rate, self.epoch_length, self.emg_filter
157
160
  )
158
161
 
159
162
  # center and scale the EEG and EMG signals to fit the display
@@ -1063,21 +1066,26 @@ def create_confidence_img(confidence_scores: np.array) -> np.array:
1063
1066
 
1064
1067
 
1065
1068
  def create_upper_emg_signal(
1066
- emg: np.array, sampling_rate: int | float, epoch_length: int | float
1069
+ emg: np.array,
1070
+ sampling_rate: int | float,
1071
+ epoch_length: int | float,
1072
+ emg_filter: EMGFilter,
1067
1073
  ) -> np.array:
1068
1074
  """Calculate RMS of EMG for each epoch and apply a ceiling
1069
1075
 
1070
1076
  :param emg: EMG signal
1071
1077
  :param sampling_rate: sampling rate, in Hz
1072
1078
  :param epoch_length: epoch length, in seconds
1079
+ :param emg_filter: EMG filter parameters
1073
1080
  :return: processed EMG signal
1074
1081
  """
1075
1082
  emg_rms = get_emg_power(
1076
1083
  emg,
1077
1084
  sampling_rate,
1078
1085
  epoch_length,
1086
+ emg_filter,
1079
1087
  )
1080
- return np.clip(emg_rms, 0, np.mean(emg_rms) + np.std(emg_rms) * 2.5)
1088
+ return np.clip(emg_rms, np.min(emg_rms), np.mean(emg_rms) + np.std(emg_rms) * 2.5)
1081
1089
 
1082
1090
 
1083
1091
  def transform_eeg_emg(eeg: np.array, emg: np.array) -> (np.array, np.array):