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.
@@ -29,7 +29,8 @@ At this point, you can score the recordings manually.
29
29
  5. Score all recordings automatically using the classifier
30
30
 
31
31
  By default, there are three brain state options: REM, wake, and NREM.
32
- If you want to change this configuration, click the "Settings" tab.
32
+ If you want to change this configuration, click the "Settings" tab and
33
+ choose "Brain states" from the drop-down menu.
33
34
  Note that if you change the configuration, you might be unable to load
34
35
  existing labels and calibration data, and you may need to train a new
35
36
  classification model.
@@ -18,7 +18,7 @@ from accusleepy.constants import (
18
18
  MIN_WINDOW_LEN,
19
19
  UPPER_FREQ,
20
20
  )
21
- from accusleepy.fileio import Recording, load_labels, load_recording
21
+ from accusleepy.fileio import Recording, load_labels, load_recording, EMGFilter
22
22
  from accusleepy.multitaper import spectrogram
23
23
 
24
24
  # note: scipy is lazily imported
@@ -172,7 +172,10 @@ def create_spectrogram(
172
172
 
173
173
 
174
174
  def get_emg_power(
175
- emg: np.array, sampling_rate: int | float, epoch_length: int | float
175
+ emg: np.array,
176
+ sampling_rate: int | float,
177
+ epoch_length: int | float,
178
+ emg_filter: EMGFilter,
176
179
  ) -> np.array:
177
180
  """Calculate EMG power for each epoch
178
181
 
@@ -182,18 +185,14 @@ def get_emg_power(
182
185
  :param emg: EMG signal
183
186
  :param sampling_rate: sampling rate, in Hz
184
187
  :param epoch_length: epoch length, in seconds
188
+ :param emg_filter: EMG filter parameters
185
189
  :return: EMG "power" for each epoch
186
190
  """
187
191
  from scipy.signal import butter, filtfilt
188
192
 
189
- # filter parameters
190
- order = 8
191
- bp_lower = 20
192
- bp_upper = 50
193
-
194
193
  b, a = butter(
195
- N=order,
196
- Wn=[bp_lower, bp_upper],
194
+ N=emg_filter.order,
195
+ Wn=[emg_filter.bp_lower, emg_filter.bp_upper],
197
196
  btype="bandpass",
198
197
  output="ba",
199
198
  fs=sampling_rate,
@@ -216,6 +215,7 @@ def create_eeg_emg_image(
216
215
  emg: np.array,
217
216
  sampling_rate: int | float,
218
217
  epoch_length: int | float,
218
+ emg_filter: EMGFilter,
219
219
  ) -> np.array:
220
220
  """Stack EEG spectrogram and EMG power into an image
221
221
 
@@ -227,6 +227,7 @@ def create_eeg_emg_image(
227
227
  :param emg: EMG signal
228
228
  :param sampling_rate: sampling rate, in Hz
229
229
  :param epoch_length: epoch length, in seconds
230
+ :param emg_filter: EMG filter parameters
230
231
  :return: combined EEG + EMG image for a recording
231
232
  """
232
233
  spec, f = create_spectrogram(eeg, sampling_rate, epoch_length)
@@ -242,7 +243,7 @@ def create_eeg_emg_image(
242
243
  ]
243
244
  )
244
245
 
245
- emg_log_rms = get_emg_power(emg, sampling_rate, epoch_length)
246
+ emg_log_rms = get_emg_power(emg, sampling_rate, epoch_length, emg_filter)
246
247
  output = np.concatenate(
247
248
  [modified_spectrogram, np.tile(emg_log_rms, (EMG_COPIES, 1))]
248
249
  )
@@ -371,6 +372,7 @@ def create_training_images(
371
372
  brain_state_set: BrainStateSet,
372
373
  model_type: str,
373
374
  calibration_fraction: float,
375
+ emg_filter: EMGFilter,
374
376
  ) -> list[int]:
375
377
  """Create training dataset
376
378
 
@@ -385,6 +387,7 @@ def create_training_images(
385
387
  :param brain_state_set: set of brain state options
386
388
  :param model_type: default or real-time
387
389
  :param calibration_fraction: fraction of training data to use for calibration
390
+ :param emg_filter: EMG filter parameters
388
391
  :return: list of the names of any recordings that could not
389
392
  be used to create training images.
390
393
  """
@@ -409,7 +412,9 @@ def create_training_images(
409
412
 
410
413
  labels, _ = load_labels(recording.label_file)
411
414
  labels = brain_state_set.convert_digit_to_class(labels)
412
- img = create_eeg_emg_image(eeg, emg, sampling_rate, epoch_length)
415
+ img = create_eeg_emg_image(
416
+ eeg, emg, sampling_rate, epoch_length, emg_filter
417
+ )
413
418
  img = mixture_z_score_img(
414
419
  img=img, brain_state_set=brain_state_set, labels=labels
415
420
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: accusleepy
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: Python implementation of AccuSleep
5
5
  License: GPL-3.0-only
6
6
  Author: Zeke Barger
@@ -39,6 +39,7 @@ It offers the following improvements over the MATLAB version (AccuSleep):
39
39
  - Model files contain useful metadata (brain state configuration,
40
40
  epoch length, number of epochs)
41
41
  - Models optimized for real-time scoring can be trained
42
+ - Confidence scores can be saved and visualized
42
43
  - Lists of recordings can be imported and exported for repeatable batch processing
43
44
  - Undo/redo functionality in the manual scoring interface
44
45
 
@@ -75,6 +76,7 @@ to the [config file](accusleepy/config.json).
75
76
 
76
77
  ## Changelog
77
78
 
79
+ - 0.7.0: More settings can be configured in the UI
78
80
  - 0.6.0: Confidence scores can now be displayed and saved. Retraining your models is recommended
79
81
  since the new calibration feature will make the confidence scores more accurate.
80
82
  - 0.5.0: Performance improvements
@@ -2,10 +2,10 @@ accusleepy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  accusleepy/__main__.py,sha256=dKzl2N2Hg9lD264CWYNxThRyDKzWwyMwHRXmJxOmMis,104
3
3
  accusleepy/bouts.py,sha256=F_y6DxnpKFfImYb7vCZluZ2eD5I_33gZXmRM8mvebsg,5679
4
4
  accusleepy/brain_state_set.py,sha256=fRkrArHLIbEKimub804yt_mUXoyfsjJEfiJnTjeCMkY,3233
5
- accusleepy/classification.py,sha256=wg0EoUrXAYqdUWr6SyJDl_5Jzx7lck9ta3-dsGzD208,9180
6
- accusleepy/config.json,sha256=n-CTGn7hljHQ7MKRMvGvwCAzcjWmUuqzAWrnXnk2pGU,501
7
- accusleepy/constants.py,sha256=0gIzZY544Y1tL-n0HxFsCMzBdprOKNYVYlNxF45o3kw,1652
8
- accusleepy/fileio.py,sha256=z6Cuhue__-RL7s3jjY23IjMl8nhow3P1mDx7j_rRLo4,5441
5
+ accusleepy/classification.py,sha256=mF35xMrD9QXGldSnl3vkdHbm7CAptPUNjHxUA_agOTA,9778
6
+ accusleepy/config.json,sha256=Ip0qTMAn2LZfof9GVA_azOvpXP0WKnqLCZeSaya1sss,819
7
+ accusleepy/constants.py,sha256=t7x-wzncJ_wVm0Oj6LiUzGukpsTsxfhO0KJiAAsuMN4,2244
8
+ accusleepy/fileio.py,sha256=woIF0zgJt6Lx6T9KBXAQ-AlbQAwOK1_RUmVF710nltI,7383
9
9
  accusleepy/gui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  accusleepy/gui/icons/brightness_down.png,sha256=PLT1fb83RHIhSRuU7MMMx0G7oJAY7o9wUcnqM8veZfM,12432
11
11
  accusleepy/gui/icons/brightness_up.png,sha256=64GnUqgPvN5xZ6Um3wOzwqvUmdAWYZT6eFmWpBsHyks,12989
@@ -18,25 +18,24 @@ accusleepy/gui/icons/save.png,sha256=J3EA8iU1BqLYRSsrq_OdoZlqrv2yfL7oV54DklTy_DI
18
18
  accusleepy/gui/icons/up_arrow.png,sha256=V9yF9t1WgjPaUu-mF1YGe_DfaRHg2dUpR_sUVVcvVvY,3329
19
19
  accusleepy/gui/icons/zoom_in.png,sha256=MFWnKZp7Rvh4bLPq4Cqo4sB_jQYedUUtT8-ZO8tNYyc,13589
20
20
  accusleepy/gui/icons/zoom_out.png,sha256=IB8Jecb3i0U4qjWRR46ridjLpvLCSe7PozBaLqQqYSw,13055
21
- accusleepy/gui/images/primary_window.png,sha256=rlEflF0w3IdwQKDo3tejqSmfNp8omoxgI8sVDqF3hto,600458
21
+ accusleepy/gui/images/primary_window.png,sha256=ABu49UXTBfI5UwNHrpWPhJoTC7zhyLVvbsbywIuu1nc,602640
22
22
  accusleepy/gui/images/viewer_window.png,sha256=b_B7m9WSLMAOzNjctq76SyekO1WfC6qYZVNnYfhjPe8,977197
23
23
  accusleepy/gui/images/viewer_window_annotated.png,sha256=uMNUmsZIdzDlQpyoiS3lJGoWlg_T325Oj5hDZhM3Y14,146817
24
- accusleepy/gui/main.py,sha256=npQbJ11fV3lpKaoChdjRI-KsgneM-IQRrWZkSDHBkWI,57737
25
- accusleepy/gui/manual_scoring.py,sha256=QD3T-0vEH5E08Vw6YAzp7eBETsNTRU4BGuyzm-3oMfI,40635
24
+ accusleepy/gui/main.py,sha256=Ywk3XwfwMjAZL76qwDnZRHQ96L7T1DWyMCU8la0N5Qg,62447
25
+ accusleepy/gui/manual_scoring.py,sha256=xk0TERVbH33owj4QYJkMA2LF_qR8jtS5W2enq36_njk,40907
26
26
  accusleepy/gui/mplwidget.py,sha256=rJSTtWmLjHn8r3c9Kb23Rc4XzXl3i9B-JrjNjjlNnmQ,13492
27
- accusleepy/gui/primary_window.py,sha256=N-hEI39lQdGSEGq1quxSPLIMuNqhTkGWKM89BL3KgVM,108377
28
- accusleepy/gui/primary_window.ui,sha256=5bSa6c5idYCpnwWZ5Vt3ecrJsC8hiD0JTPLSf_20H2g,153744
27
+ accusleepy/gui/primary_window.py,sha256=sVIsZXnszBsq3ZUC9OIOwB13jPQRcisaxi0Vg-O6A-8,135475
28
+ accusleepy/gui/primary_window.ui,sha256=_SorGY7qJG2B6e45UNt51OheeYLkpzAxxezX1hEfI3Y,201341
29
29
  accusleepy/gui/resources.qrc,sha256=wqPendnTLAuKfVI6v2lKHiRqAWM0oaz2ZuF5cucJdS4,803
30
30
  accusleepy/gui/resources_rc.py,sha256=Z2e34h30U4snJjnYdZVV9B6yjATKxxfvgTRt5uXtQdo,329727
31
- accusleepy/gui/text/config_guide.txt,sha256=xYnVTojDXKph13QBj7mpfjQYa-xmpLkhF19G_bz3xbA,1027
32
- accusleepy/gui/text/main_guide.md,sha256=bl5RDSh-kD44Ch3bVo_Hl7Cn3n8dfh9xHjKKH4ORgS8,8238
31
+ accusleepy/gui/text/main_guide.md,sha256=iZDRp5OWyQX9LV7CMeUFIYv2ryKlIcGALRLXjxR8HpI,8288
33
32
  accusleepy/gui/text/manual_scoring_guide.md,sha256=ow_RMSjFy05NupEDSCuJtu-V65-BPnIkrZqtssFoZCQ,999
34
33
  accusleepy/gui/viewer_window.py,sha256=O4ceqLMYdahxQ9s6DYhloUnNESim-cqIZxFeXEiRjog,24444
35
34
  accusleepy/gui/viewer_window.ui,sha256=jsjydsSSyN49AwJw4nVS2mEJ2JBIUTXesAJsij1JNV0,31530
36
35
  accusleepy/models.py,sha256=15VjtFoWaYXblyGPbtYgp0yJdyUfGu7t3zCShdtr_7c,3799
37
36
  accusleepy/multitaper.py,sha256=D5-iglwkFBRciL5tKSNcunMtcq0rM3zHwRHUVPgem1U,25679
38
- accusleepy/signal_processing.py,sha256=sEol01SlwOVwBmKHR-saVhneAA0jr98pcZZ-02uUy2Q,16739
37
+ accusleepy/signal_processing.py,sha256=NOkQuLmUVINd0tFvt48RXRxSl4TDjV42m54XWc_EB9s,16987
39
38
  accusleepy/temperature_scaling.py,sha256=glvPcvxHpBdFjwjGfZdNku9L_BozycEmdqZhKKUCCNg,5749
40
- accusleepy-0.6.0.dist-info/METADATA,sha256=D2BHcAVQmF4M7ZkCwEiBjIQ6q6aMgcEQghNNtZFb2c8,4437
41
- accusleepy-0.6.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
42
- accusleepy-0.6.0.dist-info/RECORD,,
39
+ accusleepy-0.7.0.dist-info/METADATA,sha256=yLkBaWfg1wrN7DevZlLLg881Yq9hhGoTsqHSgCJ0IYk,4536
40
+ accusleepy-0.7.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
41
+ accusleepy-0.7.0.dist-info/RECORD,,
@@ -1,27 +0,0 @@
1
- This is the current brain state configuration.
2
- If you make changes, click 'Save' to store them.
3
-
4
- Each brain state has several attributes:
5
-
6
- - Digit: how the brain state is represented in label files,
7
- and the key on the keyboard that, during manual scoring,
8
- sets an epoch to this brain state.
9
-
10
- - Enabled: whether a brain state for this digit exists.
11
-
12
- - Name: unique name of the brain state (e.g., REM).
13
-
14
- - Scored: whether a classification model should output this
15
- brain state. If you have a state that corresponds to
16
- missing or corrupted data, for example, you would
17
- probably want to uncheck this box.
18
-
19
- - Frequency: approximate relative frequency of this brain
20
- state. Does not need to be very accurate, but it can
21
- influence classification accuracy slightly. The values
22
- for all scored brain states must sum to 1.
23
-
24
- Important notes:
25
- - Changing these settings can invalidate existing label files,
26
- calibration files, and trained models!
27
- - Reinstalling AccuSleePy will overwrite this configuration.