misleep 0.2.2__tar.gz → 0.2.3__tar.gz

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.
Files changed (67) hide show
  1. {misleep-0.2.2 → misleep-0.2.3}/PKG-INFO +2 -2
  2. {misleep-0.2.2 → misleep-0.2.3}/README.md +1 -1
  3. {misleep-0.2.2 → misleep-0.2.3}/misleep/analysis/auto_stage.py +24 -2
  4. {misleep-0.2.2 → misleep-0.2.3}/misleep/config.ini +1 -1
  5. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/dialog.py +1 -0
  6. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/main_window.py +2 -2
  7. {misleep-0.2.2 → misleep-0.2.3}/misleep.egg-info/PKG-INFO +2 -2
  8. {misleep-0.2.2 → misleep-0.2.3}/setup.py +1 -1
  9. {misleep-0.2.2 → misleep-0.2.3}/LICENSE +0 -0
  10. {misleep-0.2.2 → misleep-0.2.3}/misleep/__init__.py +0 -0
  11. {misleep-0.2.2 → misleep-0.2.3}/misleep/__main__.py +0 -0
  12. {misleep-0.2.2 → misleep-0.2.3}/misleep/analysis/__init__.py +0 -0
  13. {misleep-0.2.2 → misleep-0.2.3}/misleep/analysis/auto_stage_model/EEG_F_lightgbm_20241221.pkl +0 -0
  14. {misleep-0.2.2 → misleep-0.2.3}/misleep/analysis/auto_stage_model/EEG_P_lightgbm_20241221.pkl +0 -0
  15. {misleep-0.2.2 → misleep-0.2.3}/misleep/analysis/classification.py +0 -0
  16. {misleep-0.2.2 → misleep-0.2.3}/misleep/analysis/detection.py +0 -0
  17. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/__init__.py +0 -0
  18. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/about.py +0 -0
  19. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/resources/__init__.py +0 -0
  20. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/resources/entire_logo.png +0 -0
  21. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/resources/logo.png +0 -0
  22. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/resources/misleep.py +0 -0
  23. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/resources/misleep.qrc +0 -0
  24. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/show.py +0 -0
  25. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/spec_window.py +0 -0
  26. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/thread.py +0 -0
  27. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/uis/SWA_detect_dialog_ui.py +0 -0
  28. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/uis/__init__.py +0 -0
  29. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/uis/about_ui.py +0 -0
  30. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/uis/auto_stage_dialog_ui.py +0 -0
  31. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/uis/horizontal_line_dialog_ui.py +0 -0
  32. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/uis/label_dialog_ui.py +0 -0
  33. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/uis/main_window_ui.py +0 -0
  34. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/uis/save_data_dialog_ui.py +0 -0
  35. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/uis/spec_window_ui.py +0 -0
  36. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/uis/spindle_detect_dialog_ui.py +0 -0
  37. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/uis/state_spectral_dialog_ui.py +0 -0
  38. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/uis/transfer_result_dialog_ui.py +0 -0
  39. {misleep-0.2.2 → misleep-0.2.3}/misleep/gui/utils.py +0 -0
  40. {misleep-0.2.2 → misleep-0.2.3}/misleep/io/__init__.py +0 -0
  41. {misleep-0.2.2 → misleep-0.2.3}/misleep/io/annotation_io.py +0 -0
  42. {misleep-0.2.2 → misleep-0.2.3}/misleep/io/base.py +0 -0
  43. {misleep-0.2.2 → misleep-0.2.3}/misleep/io/signal_io.py +0 -0
  44. {misleep-0.2.2 → misleep-0.2.3}/misleep/preprocessing/__init__.py +0 -0
  45. {misleep-0.2.2 → misleep-0.2.3}/misleep/preprocessing/channel.py +0 -0
  46. {misleep-0.2.2 → misleep-0.2.3}/misleep/preprocessing/signals.py +0 -0
  47. {misleep-0.2.2 → misleep-0.2.3}/misleep/preprocessing/spectral.py +0 -0
  48. {misleep-0.2.2 → misleep-0.2.3}/misleep/utils/__init__.py +0 -0
  49. {misleep-0.2.2 → misleep-0.2.3}/misleep/utils/annotation.py +0 -0
  50. {misleep-0.2.2 → misleep-0.2.3}/misleep/utils/logger_handler.py +0 -0
  51. {misleep-0.2.2 → misleep-0.2.3}/misleep/utils/signals.py +0 -0
  52. {misleep-0.2.2 → misleep-0.2.3}/misleep/viz/__init__.py +0 -0
  53. {misleep-0.2.2 → misleep-0.2.3}/misleep/viz/hypnogram.py +0 -0
  54. {misleep-0.2.2 → misleep-0.2.3}/misleep/viz/signals.py +0 -0
  55. {misleep-0.2.2 → misleep-0.2.3}/misleep/viz/spectral.py +0 -0
  56. {misleep-0.2.2 → misleep-0.2.3}/misleep.egg-info/SOURCES.txt +0 -0
  57. {misleep-0.2.2 → misleep-0.2.3}/misleep.egg-info/dependency_links.txt +0 -0
  58. {misleep-0.2.2 → misleep-0.2.3}/misleep.egg-info/requires.txt +0 -0
  59. {misleep-0.2.2 → misleep-0.2.3}/misleep.egg-info/top_level.txt +0 -0
  60. {misleep-0.2.2 → misleep-0.2.3}/setup.cfg +0 -0
  61. {misleep-0.2.2 → misleep-0.2.3}/test/test_annotation_io.py +0 -0
  62. {misleep-0.2.2 → misleep-0.2.3}/test/test_loadmat73.py +0 -0
  63. {misleep-0.2.2 → misleep-0.2.3}/test/test_midata.py +0 -0
  64. {misleep-0.2.2 → misleep-0.2.3}/test/test_show.py +0 -0
  65. {misleep-0.2.2 → misleep-0.2.3}/test/test_signal_io.py +0 -0
  66. {misleep-0.2.2 → misleep-0.2.3}/test/test_signals_viz.py +0 -0
  67. {misleep-0.2.2 → misleep-0.2.3}/test/test_spectral_viz.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: misleep
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: MiSleep: Mice Sleep EEG/EMG visualization, scoring and analysis.
5
5
  Home-page: https://github.com/BryanWang0702/MiSleep/
6
6
  Download-URL: https://github.com/BryanWang0702/MiSleep/
@@ -82,7 +82,7 @@ There is a config.ini in the root directory of MiSleep source package, multiple
82
82
 
83
83
  4. Auto stage
84
84
 
85
- Finally, now we have the auto stage function! Check it in the tool.
85
+ Finally, now we have the auto stage function! Check it in the tool. The overall test accuracy of NREM and Wake is higher than 90%, and for REM, the accuracy is higher than 80%. Currently the model's result is rather fragmented in the state transition segments, we will add some constraints to fix this.
86
86
 
87
87
  **Future**: Open for suggestions :).
88
88
 
@@ -48,7 +48,7 @@ There is a config.ini in the root directory of MiSleep source package, multiple
48
48
 
49
49
  4. Auto stage
50
50
 
51
- Finally, now we have the auto stage function! Check it in the tool.
51
+ Finally, now we have the auto stage function! Check it in the tool. The overall test accuracy of NREM and Wake is higher than 90%, and for REM, the accuracy is higher than 80%. Currently the model's result is rather fragmented in the state transition segments, we will add some constraints to fix this.
52
52
 
53
53
  **Future**: Open for suggestions :).
54
54
 
@@ -5,6 +5,7 @@ import pandas as pd
5
5
  from scipy import stats
6
6
  import antropy
7
7
  import joblib
8
+ import copy
8
9
 
9
10
 
10
11
  def filter_power_line_noise(data, sf, noise_band='50-100-150'):
@@ -36,8 +37,10 @@ def split_window_data(data, sf, state, window_length=20, stride_length=5):
36
37
  return []
37
38
 
38
39
  window_data = []
39
- for i in range(0, len(data) - int(window_length*sf) + 1, int(stride_length*sf)):
40
- window = data[i:i + int(window_length*sf)]
40
+ # Make sure we have enough data point of the final segment
41
+ data_sec_length = floor(data.shape[0] / sf)
42
+ for i in range(0, data_sec_length-stride_length, stride_length):
43
+ window = data[int(i*sf):int((i+window_length)*sf)]
41
44
  window_data.append([window, state])
42
45
 
43
46
  return window_data
@@ -99,6 +102,24 @@ def get_data_features(data, sf, data_format='EEG'):
99
102
 
100
103
  return window_feature_df
101
104
 
105
+ def result_constraints(pred_label):
106
+ """
107
+ Once finished the prediction, add some constraints to make the result more smooth
108
+ 1. No REM after Wake, set to NREM
109
+ 2. All one epoch between two same state will be set to the around state
110
+ """
111
+
112
+ pred_label = copy.deepcopy(pred_label)
113
+ for idx in range(1, len(pred_label)-1):
114
+ label_ = pred_label[idx]
115
+ if label_ == 3 and pred_label[idx+1] == 2: # REM after Wake
116
+ pred_label[idx+1] = 1
117
+ if pred_label[idx-1] ==pred_label[idx+1]: # Same state previous and after
118
+ pred_label[idx] = pred_label[idx-1]
119
+
120
+ return pred_label
121
+
122
+
102
123
  def auto_stage_gbm(EEG, EMG, sf, EEG_channel='F'):
103
124
  """
104
125
  Auto stage with lightgbm method
@@ -132,5 +153,6 @@ def auto_stage_gbm(EEG, EMG, sf, EEG_channel='F'):
132
153
  gbm_model = joblib.load(r'./misleep/analysis/auto_stage_model/EEG_P_lightgbm_20241221.pkl')
133
154
 
134
155
  pred_label = gbm_model.predict(window_feature_df, num_iteration=gbm_model.best_iteration_)
156
+ pred_label = result_constraints(pred_label)
135
157
  pred_label = [item for each in pred_label for item in [each]*5]
136
158
  return pred_label
@@ -1,5 +1,5 @@
1
1
  [gui]
2
- version = v0.2.2
2
+ version = v0.2.3
3
3
  updatetime = 2024/12/23
4
4
  marker = ['long REM', 'first REM', 'WindEEG', 'W-R ', 'maker']
5
5
  startend = ['burst-supression', 'REM', 'Wake', 'Spindle', 'SWA', 'start end label', 'start end label']
@@ -916,6 +916,7 @@ class AutoStageDialog(QDialog, Ui_AutoStageDialog):
916
916
 
917
917
  return pred_label
918
918
 
919
+
919
920
  def okEvent(self):
920
921
  self.closed = False
921
922
  self.hide()
@@ -1626,8 +1626,8 @@ class main_window(QMainWindow, Ui_MiSleep):
1626
1626
  return
1627
1627
  auto_stage_lst = self.auto_stage_dialog.auto_stage(self.midata)
1628
1628
 
1629
- # start_end = self.mianno.start_end +
1630
- self.mianno._sleep_state[:len(auto_stage_lst)] = auto_stage_lst
1629
+ # Not sure which one is shorter, so get the minimum one
1630
+ self.mianno._sleep_state[:min(len(self.mianno._sleep_state),len(auto_stage_lst))] = auto_stage_lst[:min(len(self.mianno._sleep_state),len(auto_stage_lst))]
1631
1631
 
1632
1632
  self.is_saved = False
1633
1633
  self.AnnotationPathLabel.setText('*Annotation path:')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: misleep
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: MiSleep: Mice Sleep EEG/EMG visualization, scoring and analysis.
5
5
  Home-page: https://github.com/BryanWang0702/MiSleep/
6
6
  Download-URL: https://github.com/BryanWang0702/MiSleep/
@@ -82,7 +82,7 @@ There is a config.ini in the root directory of MiSleep source package, multiple
82
82
 
83
83
  4. Auto stage
84
84
 
85
- Finally, now we have the auto stage function! Check it in the tool.
85
+ Finally, now we have the auto stage function! Check it in the tool. The overall test accuracy of NREM and Wake is higher than 90%, and for REM, the accuracy is higher than 80%. Currently the model's result is rather fragmented in the state transition segments, we will add some constraints to fix this.
86
86
 
87
87
  **Future**: Open for suggestions :).
88
88
 
@@ -11,7 +11,7 @@ MAINTAINER_EMAIL = "swang@gmail.com"
11
11
  URL = "https://github.com/BryanWang0702/MiSleep/"
12
12
  LICENSE = "BSD (3-clause)"
13
13
  DOWNLOAD_URL = "https://github.com/BryanWang0702/MiSleep/"
14
- VERSION = "0.2.2"
14
+ VERSION = "0.2.3"
15
15
 
16
16
  INSTALL_REQUIRES = [
17
17
  "numpy>=1.18.1",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes