SleePyPhases 0.8.2__tar.gz → 0.8.4__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 (63) hide show
  1. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/PKG-INFO +1 -1
  2. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/config.yaml +1 -0
  3. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/BuildDataset.py +9 -2
  4. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/EvalPlotExamples.py +2 -1
  5. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/EvalReport.py +2 -1
  6. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/Predict.py +10 -16
  7. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/Setup.py +2 -2
  8. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases.egg-info/PKG-INFO +1 -1
  9. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/setup.py +1 -1
  10. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/LICENSE +0 -0
  11. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/README.md +0 -0
  12. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/DataManipulation.py +0 -0
  13. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/EventScorer.py +0 -0
  14. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/FeatureExtraction.py +0 -0
  15. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/MultiScorer.py +0 -0
  16. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/Plot.py +0 -0
  17. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/Plugin.py +0 -0
  18. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/PreManipulation.py +0 -0
  19. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/RecordFeatureExtraction.py +0 -0
  20. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/Reporter.py +0 -0
  21. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/SignalPreprocessing.py +0 -0
  22. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/SleePyPhases.py +0 -0
  23. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/SleepMetaData.py +0 -0
  24. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/__init__.py +0 -0
  25. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/DataAnalysis.py +0 -0
  26. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/DataReport.py +0 -0
  27. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/Eval.py +0 -0
  28. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/ExportMetadataToMeticalDB.py +0 -0
  29. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/Extract.py +0 -0
  30. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/ExtractEvents.py +0 -0
  31. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/ExtractFeatures.py +0 -0
  32. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/ExtractRecordFeatures.py +0 -0
  33. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/GatherMetadata.py +0 -0
  34. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/LogCleanup.py +0 -0
  35. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/LogOverview.py +0 -0
  36. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/TestRun.py +0 -0
  37. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/ThresholdOptimisation.py +0 -0
  38. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/Training.py +0 -0
  39. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/Validation.py +0 -0
  40. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/VisualizeConfig.py +0 -0
  41. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/__init__.py +0 -0
  42. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases.egg-info/SOURCES.txt +0 -0
  43. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases.egg-info/dependency_links.txt +0 -0
  44. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases.egg-info/requires.txt +0 -0
  45. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases.egg-info/top_level.txt +0 -0
  46. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/pyproject.toml +0 -0
  47. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/setup.cfg +0 -0
  48. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/__init__.py +0 -0
  49. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/conftest.py +0 -0
  50. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/__init__.py +0 -0
  51. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_BuildDataset.py +0 -0
  52. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_BuildDatasetFolded.py +0 -0
  53. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_BuildDatasetMetadataSync.py +0 -0
  54. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_BuildDatasetSegments.py +0 -0
  55. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_DataManipulation.py +0 -0
  56. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_Eval.py +0 -0
  57. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_EventScorer.py +0 -0
  58. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_Extract.py +0 -0
  59. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_PreManipulation.py +0 -0
  60. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_RecordFeatureExtraction.py +0 -0
  61. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_RecordProcessor.py +0 -0
  62. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_Setup.py +0 -0
  63. {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_SignalPreprocessing.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SleePyPhases
3
- Version: 0.8.2
3
+ Version: 0.8.4
4
4
  Summary: A framwork for creating deep learning pipelines for sleep data
5
5
  Home-page: https://gitlab.com/sleep-is-all-you-need/sleepyphases
6
6
  Author: Franz Ehrlich
@@ -163,5 +163,6 @@ predict:
163
163
  inputFile: null
164
164
  channelMapping: {}
165
165
  weights: null
166
+ pretraining: {}
166
167
 
167
168
  inputShape: null
@@ -42,12 +42,19 @@ class BuildDataset(Phase):
42
42
 
43
43
  dm = self.getData("dataversionmanager", DataversionManager)
44
44
  metadata = self.project.getData("metadata", pd.DataFrame)
45
+ channelMetaData = self.project.getData("metadata-channels", pd.DataFrame)
45
46
  metadataMap = {r["recordId"]: r for r in metadata.iloc}
46
47
  allRecordIds = [r for subgroup in dm.unShuffledgroupedRecords.values() for r in subgroup]
47
-
48
48
  recordIds = dm.getRecordsForSplit(splitName)
49
49
  recordIndexes = [allRecordIds.index(r) for r in recordIds]
50
- recordMetadata = [metadataMap[r] for r in allRecordIds] # unshuffled
50
+
51
+ if len(channelMetaData) > 0:
52
+ recordMetadata = [
53
+ {**metadataMap[r].to_dict(), "channels": channelMetaData[channelMetaData["recordId"] == r]}
54
+ for r in allRecordIds
55
+ ]
56
+ else:
57
+ recordMetadata = [metadataMap[r] for r in allRecordIds]
51
58
 
52
59
  # handle segment wise data
53
60
  recordLengthsInSegments = None
@@ -3,7 +3,6 @@ import numpy as np
3
3
  from pyPhases import Phase
4
4
  from pyPhasesRecordloader import RecordSignal, Signal
5
5
 
6
- from SleePyPhases.Plot import Plot
7
6
  from SleePyPhases.DataManipulation import DataManipulation
8
7
  from datetime import timedelta
9
8
 
@@ -37,6 +36,8 @@ class EvalPlotExamples(Phase):
37
36
  self, recordSignal: RecordSignal, fileName, sliceValues=None, highlights=None, offset=0, title="Example"
38
37
  ):
39
38
  from matplotlib import pyplot as plt
39
+ from SleePyPhases.Plot import Plot
40
+
40
41
  samplingrate = recordSignal.targetFrequency
41
42
  paddingInS = self.examplePaddingInS
42
43
  padding = paddingInS * samplingrate
@@ -8,7 +8,6 @@ import yaml
8
8
  from pyPhases import Phase
9
9
  from pyPhasesRecordloader import RecordSignal, Signal
10
10
 
11
- from SleePyPhases import Plot
12
11
  from SleePyPhases.DataManipulation import DataManipulation
13
12
 
14
13
 
@@ -51,6 +50,7 @@ class EvalReport(Phase):
51
50
  def plotRecordSignal(
52
51
  self, label, classExamples, recordSignal: RecordSignal, fileName, sliceValues=None, highlights=None, offset=0, classNames=None, threshold=None, labelName=""
53
52
  ):
53
+ from SleePyPhases import Plot
54
54
 
55
55
  classificationNames = {}
56
56
  for i, name1 in enumerate(classNames):
@@ -217,6 +217,7 @@ class EvalReport(Phase):
217
217
 
218
218
 
219
219
  metrics = self.getConfig("trainingParameter.validationMetrics")
220
+ metrics = [metrics] if isinstance(metrics[0], str) else metrics
220
221
  evalMetrics = self.getConfig("eval.metrics", metrics)
221
222
  labelNames = self.getConfig("classification.labelNames")
222
223
 
@@ -28,21 +28,6 @@ class Predict(Phase):
28
28
 
29
29
  CHANNEL_MAPPING_FILE = "lastchannelmapping.json"
30
30
 
31
- def getModel(self, weightsPath: Optional[str] = None) -> Model:
32
- """Load the model with optional custom weights."""
33
- if weightsPath:
34
- # Load custom weights from specified path
35
- model = ModelManager.getModel(True)
36
- model.build()
37
- model.load(weightsPath)
38
- else:
39
- # Use default trained model state
40
- modelState = self.project.getData("modelState", Model, generate=False)
41
- model = ModelManager.getModel(True)
42
- model.build()
43
- model.loadState(modelState)
44
- return model
45
-
46
31
  def loadChannelMapping(self) -> Dict[str, str]:
47
32
  """Load the last used channel mapping from file."""
48
33
  mappingPath = self.getConfig("predict.lastChannelMappingPath", self.CHANNEL_MAPPING_FILE)
@@ -169,6 +154,12 @@ class Predict(Phase):
169
154
  return self.predictRecordSignal(recordSignal)
170
155
 
171
156
  def predictRecordSignal(self, recordSignal, metadata=None, dummyY=None):
157
+ channelMapping = self.getConfig("predict.channelMapping", None)
158
+
159
+ for src, dst in (channelMapping or {}).items():
160
+ if src in recordSignal.signalNames:
161
+ recordSignal.renameSignal(src, dst)
162
+
172
163
  processedSignal = self.preprocessSignal(recordSignal)
173
164
 
174
165
  with self.project:
@@ -185,7 +176,10 @@ class Predict(Phase):
185
176
 
186
177
  # Load model with optional custom weights
187
178
  weightsPath = self.getConfig("predict.weights", False)
188
- model = self.getModel(weightsPath)
179
+ if weightsPath:
180
+ self.setConfig("pretraining.pretrainedModel", weightsPath)
181
+
182
+ model = self.project.generateData("trainedModel")
189
183
 
190
184
  # Run prediction
191
185
  prediction = model.predict(processedSignal, returnNumpy=False)
@@ -95,7 +95,7 @@ class Setup(Phase):
95
95
  for splitName in ["training", "validation", "test"]:
96
96
  if splitName in foldConfig:
97
97
  dm.addSplitBySlices(splitName, foldConfig[splitName])
98
- dm.validatDatasetVersion(raiseException=self.getConfig("validatDataset", True))
98
+ dm.validateDatasetVersion(raiseException=self.getConfig("validateDataset", True))
99
99
  return dm
100
100
 
101
101
  # add manual addes splits
@@ -136,7 +136,7 @@ class Setup(Phase):
136
136
  if "training" not in dm.splits:
137
137
  dm.addSplitByRemaining("training", 1)
138
138
 
139
- dm.validatDatasetVersion(raiseException=self.getConfig("validatDataset", True))
139
+ dm.validateDatasetVersion(raiseException=self.getConfig("validateDataset", True))
140
140
 
141
141
  return dm
142
142
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SleePyPhases
3
- Version: 0.8.2
3
+ Version: 0.8.4
4
4
  Summary: A framwork for creating deep learning pipelines for sleep data
5
5
  Home-page: https://gitlab.com/sleep-is-all-you-need/sleepyphases
6
6
  Author: Franz Ehrlich
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="SleePyPhases",
8
- version="v0.8.2"[1:],
8
+ version="v0.8.4"[1:],
9
9
  author="Franz Ehrlich",
10
10
  author_email="fehrlichd@gmail.com",
11
11
  description="A framwork for creating deep learning pipelines for sleep data",
File without changes
File without changes
File without changes