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.
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/PKG-INFO +1 -1
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/config.yaml +1 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/BuildDataset.py +9 -2
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/EvalPlotExamples.py +2 -1
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/EvalReport.py +2 -1
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/Predict.py +10 -16
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/Setup.py +2 -2
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases.egg-info/PKG-INFO +1 -1
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/setup.py +1 -1
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/LICENSE +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/README.md +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/DataManipulation.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/EventScorer.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/FeatureExtraction.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/MultiScorer.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/Plot.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/Plugin.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/PreManipulation.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/RecordFeatureExtraction.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/Reporter.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/SignalPreprocessing.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/SleePyPhases.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/SleepMetaData.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/__init__.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/DataAnalysis.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/DataReport.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/Eval.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/ExportMetadataToMeticalDB.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/Extract.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/ExtractEvents.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/ExtractFeatures.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/ExtractRecordFeatures.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/GatherMetadata.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/LogCleanup.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/LogOverview.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/TestRun.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/ThresholdOptimisation.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/Training.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/Validation.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/VisualizeConfig.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases/phases/__init__.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases.egg-info/SOURCES.txt +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases.egg-info/dependency_links.txt +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases.egg-info/requires.txt +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/SleePyPhases.egg-info/top_level.txt +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/pyproject.toml +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/setup.cfg +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/__init__.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/conftest.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/__init__.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_BuildDataset.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_BuildDatasetFolded.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_BuildDatasetMetadataSync.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_BuildDatasetSegments.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_DataManipulation.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_Eval.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_EventScorer.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_Extract.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_PreManipulation.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_RecordFeatureExtraction.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_RecordProcessor.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_Setup.py +0 -0
- {sleepyphases-0.8.2 → sleepyphases-0.8.4}/tests/unit/test_SignalPreprocessing.py +0 -0
|
@@ -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
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
139
|
+
dm.validateDatasetVersion(raiseException=self.getConfig("validateDataset", True))
|
|
140
140
|
|
|
141
141
|
return dm
|
|
142
142
|
|
|
@@ -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.
|
|
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
|
|
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
|
|
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
|
|
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
|