latest version of the software added
Esse commit está contido em:
@@ -4,10 +4,6 @@ from pyqtgraph.Qt import QtCore, QtGui
|
||||
import numpy as np
|
||||
|
||||
class CustomWidget(pg.GraphicsWindow):
|
||||
|
||||
"""
|
||||
The custom widget to plot the EEG in real-time
|
||||
"""
|
||||
pg.setConfigOption('background', 'w')
|
||||
pg.setConfigOption('foreground', 'k')
|
||||
ptr1 = 0
|
||||
@@ -26,13 +22,6 @@ class CustomWidget(pg.GraphicsWindow):
|
||||
timer.start(2000) # number of seconds (every 1000) for next update
|
||||
|
||||
def update(self):
|
||||
|
||||
"""
|
||||
Update the EEG plot.
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
|
||||
"""
|
||||
self.data1[:-1] = self.data1[1:] # shift data in the array one sample left
|
||||
# (see also: np.roll)
|
||||
self.data1[-1] = np.random.normal()
|
||||
|
||||
+4
-35
@@ -1,42 +1,11 @@
|
||||
# ZmaxCoDo
|
||||
# ZmaxDonders
|
||||
|
||||
## Overview
|
||||
|
||||
Zmax Controller Donders (ZmaxCoDo) is Python package to record, monitor, analyze, and modulate sleep in **real-time**. The developers have done their best to build it in a modular and open-source fashion, such that other researchers can add their own features to it and extend it further.
|
||||
ZmaxDonders is a software that is written in Python to control Hypnodyne Zmax headbands while monitoring/analyzing its EEG data. The software allows researchers to load their own or pre-trained deep learning models to classify different phases of sleep via single-channel EEG data. The developers have done their best to build it in a modular and open-source fashion, such that other researchers can add their own features to it and extend it further.
|
||||
|
||||
## Real-time features:
|
||||
1. Open source!
|
||||
2. Data navigation and monitoring: Real-time representation of the EEG channels with adjustable time axis and amplitude scales
|
||||
3. Analysis: Real-time spectrogram and peridogoram analysis
|
||||
4. Autoscoring: Real-time sleep staging, open to any algorithm (is not ideal yet, still under development)
|
||||
5. Modulation: sleep modulation by visual, auditory, and tactile stimulation
|
||||
6. annotations: The experimenter can set various annotations throughout the experiment.
|
||||
Another remarkable feature of it is plotting spectrogram and periodogram of the EEG data in real-time. These plots contain a reach amount of information that can contribute to the inference of the experimenters.
|
||||
|
||||
## How to install?
|
||||
Create all the required packages on a virtual environment:
|
||||
```
|
||||
conda env create --name zmax --file zmax.yml
|
||||
```
|
||||
|
||||
## How to use?
|
||||
Simply activate the environment you made in the previous step and run the latest version of the app:
|
||||
```
|
||||
conda activate zmax
|
||||
python mainwindow.py
|
||||
```
|
||||
## How to Install
|
||||
|
||||
## Demo:
|
||||
### Main user interface (UI)
|
||||
<img width="617" alt="Untitled" src="https://user-images.githubusercontent.com/48684369/174683169-44503f1e-2064-40a1-aa48-31ba9882fee4.png">
|
||||
|
||||
### FAQ:
|
||||
*1. What sources of informaion we can collect?*
|
||||
Basically whatever that the Zmax Hypnodyne can collect in addition to other information regarding stimulation, annotations assignment, and autoscoring, e.g., stimulation properties (color of light, intensity, etc), exact time (accurate up to the number of sample), autoscoring (real-time scored data output)
|
||||
|
||||
*2. How to post-process the data*
|
||||
For post-processing of the data collected by ZmaxCoDo, one should use: https://github.com/ZmaxDonders/ZmaxCoDoAnalyzer
|
||||
|
||||
**CITATION:**
|
||||
hello world!
|
||||
|
||||
**CopyRight (2021 - 22): Amir Hossein Daraie, Mahdad Jafarzadeh Esfahani**
|
||||
|
||||
+164
-167
@@ -1,175 +1,172 @@
|
||||
# =============================================================================
|
||||
# import realTimeAutoScoring
|
||||
# import numpy as np
|
||||
# import scipy.signal as ssignal
|
||||
#
|
||||
# from model import TinySleepNet
|
||||
# from minibatching import (iterate_minibatches,
|
||||
# iterate_batch_seq_minibatches,
|
||||
# iterate_batch_multiple_seq_minibatches)
|
||||
#
|
||||
# sleepScoringModel = realTimeAutoScoring.importModel("./out_QS/train/21")
|
||||
#
|
||||
# recording = np.loadtxt(".\\2021-08-19 Pilot 8 Saba\\recording-date-2021-08-19-time-07-26-40-complete.txt", delimiter=',')
|
||||
# recordingValid = recording[recording[:,4]!=1]
|
||||
# fs = 256
|
||||
# T = 30
|
||||
# lenEpoch = fs*T
|
||||
# recordingValidtruncated = recordingValid[0:int(recordingValid.shape[0] - recordingValid.shape[0]%(fs*T)), :]
|
||||
#
|
||||
# EEGR = recordingValidtruncated[:,0]
|
||||
# EEGL = recordingValidtruncated[:,1]
|
||||
#
|
||||
# sigReq = EEGL
|
||||
# sigRef = EEGR
|
||||
#
|
||||
import realTimeAutoScoring
|
||||
import numpy as np
|
||||
import scipy.signal as ssignal
|
||||
|
||||
from model import TinySleepNet
|
||||
from minibatching import (iterate_minibatches,
|
||||
iterate_batch_seq_minibatches,
|
||||
iterate_batch_multiple_seq_minibatches)
|
||||
|
||||
sleepScoringModel = realTimeAutoScoring.importModel("./out_QS/train/21")
|
||||
|
||||
recording = np.loadtxt(".\\2021-08-19 Pilot 8 Saba\\recording-date-2021-08-19-time-07-26-40-complete.txt", delimiter=',')
|
||||
recordingValid = recording[recording[:,4]!=1]
|
||||
fs = 256
|
||||
T = 30
|
||||
lenEpoch = fs*T
|
||||
recordingValidtruncated = recordingValid[0:int(recordingValid.shape[0] - recordingValid.shape[0]%(fs*T)), :]
|
||||
|
||||
EEGR = recordingValidtruncated[:,0]
|
||||
EEGL = recordingValidtruncated[:,1]
|
||||
|
||||
sigReq = EEGL
|
||||
sigRef = EEGR
|
||||
|
||||
lowcut = 0.3
|
||||
highcut = 30
|
||||
nyquist_freq = fs / 2.
|
||||
low = lowcut / nyquist_freq
|
||||
high = highcut / nyquist_freq
|
||||
# Req channel
|
||||
b, a = ssignal.butter(3, [low, high], btype='band')
|
||||
signal_req = ssignal.filtfilt(b, a, sigReq)
|
||||
# Ref channel
|
||||
signal_ref = ssignal.filtfilt(b, a, sigRef)
|
||||
|
||||
sigReq2 = sigReq.reshape((1, sigReq.shape[0]))
|
||||
sigRef2 = sigRef.reshape((1, sigRef.shape[0]))
|
||||
|
||||
n_epochs = int(sigRef2.shape[1] / lenEpoch)
|
||||
|
||||
sigReq_epoched = np.reshape (sigReq2,
|
||||
(n_epochs, lenEpoch ), order='F')
|
||||
|
||||
sigRef_epoched = np.reshape (sigRef2,
|
||||
(n_epochs, lenEpoch ), order='F')
|
||||
|
||||
signals = sigReq_epoched - sigRef_epoched
|
||||
|
||||
signals *= 10**(-6)
|
||||
|
||||
x = signals.astype(np.float32)
|
||||
labels = np.ones((1, n_epochs)) # Create fake labels
|
||||
y = labels.astype(np.int32)
|
||||
|
||||
Name = "Subject X"
|
||||
|
||||
# Init
|
||||
test_x = []
|
||||
|
||||
# Reshape the data to match the input of the model - conv2d
|
||||
x = np.squeeze(x)
|
||||
x = x[:, :, np.newaxis, np.newaxis]
|
||||
|
||||
# Casting
|
||||
x = x.astype(np.float32)
|
||||
y = y.astype(np.int32)
|
||||
|
||||
test_x.append(x)
|
||||
test_y = y
|
||||
|
||||
config = realTimeAutoScoring.config
|
||||
|
||||
preds = []
|
||||
|
||||
if config["model"] == "model-origin":
|
||||
for night_idx, night_data in enumerate(zip(test_x, test_y)):
|
||||
# Create minibatches for testing
|
||||
night_x, night_y = night_data
|
||||
test_minibatch_fn = iterate_batch_seq_minibatches(
|
||||
night_x,
|
||||
night_y,
|
||||
batch_size=config["batch_size"],
|
||||
seq_length=config["seq_length"],
|
||||
)
|
||||
# Evaluate
|
||||
test_outs = sleepScoringModel.evaluate(test_minibatch_fn)
|
||||
preds.extend(test_outs["test/preds"])
|
||||
else:
|
||||
for night_idx, night_data in enumerate(zip(test_x, test_y)):
|
||||
# Create minibatches for testing
|
||||
night_x, night_y = night_data
|
||||
test_minibatch_fn = iterate_batch_multiple_seq_minibatches(
|
||||
[night_x],
|
||||
[night_y],
|
||||
batch_size=config["batch_size"],
|
||||
seq_length=config["seq_length"],
|
||||
shuffle_idx=None,
|
||||
augment_seq=False,
|
||||
)
|
||||
if (config.get('augment_signal') is not None) and config['augment_signal']:
|
||||
# Evaluate
|
||||
test_outs = sleepScoringModel.evaluate_aug(test_minibatch_fn)
|
||||
else:
|
||||
# Evaluate
|
||||
test_outs = sleepScoringModel.evaluate(test_minibatch_fn)
|
||||
preds.extend(test_outs["test/preds"])
|
||||
|
||||
# Save labels and predictions (each night of each subject)
|
||||
save_dict = {
|
||||
"y_true": test_outs["test/trues"],
|
||||
"y_pred": test_outs["test/preds"],
|
||||
}
|
||||
|
||||
# Object.plot_comparative_hyp(hyp_true = s_trues, hyp_pred = test_outs["test/preds"] , sub_name = Name, s_preds = test_outs["test/preds"],\
|
||||
# s_acc = 'N/A' , s_kappa = 'N/A' , s_f1_score = 'N/A' ,\
|
||||
# mark_REM = 'active', write_metrics = False,
|
||||
# Title = 'True Hyp_'+ Name , save_fig = False,\
|
||||
# directory = "./")
|
||||
# directory = "P:/3022033.01/FilesForMathijs/daily_zmax_autoscoring/daily_zmax_hypnograms/
|
||||
|
||||
# sampling_rate = 256
|
||||
# lowcut = 0.3
|
||||
# highcut = 30
|
||||
# nyquist_freq = fs / 2.
|
||||
# nyquist_freq = sampling_rate / 2.
|
||||
# low = lowcut / nyquist_freq
|
||||
# high = highcut / nyquist_freq
|
||||
# # Req channel
|
||||
# b, a = ssignal.butter(3, [low, high], btype='band')
|
||||
# signal_req = ssignal.filtfilt(b, a, sigReq)
|
||||
# # Ref channel
|
||||
# signal_ref = ssignal.filtfilt(b, a, sigRef)
|
||||
#
|
||||
# sigReq2 = sigReq.reshape((1, sigReq.shape[0]))
|
||||
# sigRef2 = sigRef.reshape((1, sigRef.shape[0]))
|
||||
#
|
||||
# n_epochs = int(sigRef2.shape[1] / lenEpoch)
|
||||
#
|
||||
# sigReq_epoched = np.reshape (sigReq2,
|
||||
# (n_epochs, lenEpoch ), order='F')
|
||||
#
|
||||
# sigRef_epoched = np.reshape (sigRef2,
|
||||
# (n_epochs, lenEpoch ), order='F')
|
||||
#
|
||||
# signals = sigReq_epoched - sigRef_epoched
|
||||
#
|
||||
# signals *= 10**(-6)
|
||||
#
|
||||
# x = signals.astype(np.float32)
|
||||
# labels = np.ones((1, n_epochs)) # Create fake labels
|
||||
# y = labels.astype(np.int32)
|
||||
#
|
||||
# Name = "Subject X"
|
||||
#
|
||||
# sigReq = ssignal.filtfilt(b, a, sigReq)
|
||||
# sigRef = ssignal.filtfilt(b, a, sigRef)
|
||||
|
||||
|
||||
|
||||
# signals = sigReq - sigRef
|
||||
#
|
||||
# signals = signals.reshape((1, signals.shape[0]))
|
||||
#
|
||||
# x = signals.astype(np.float32)
|
||||
#
|
||||
# data_epoched = np.reshape (signals,
|
||||
# (int(signals.shape[1] / lenEpoch), lenEpoch, 1, 1 ), order='F')
|
||||
#
|
||||
# # Init
|
||||
# test_x = []
|
||||
#
|
||||
# # Reshape the data to match the input of the model - conv2d
|
||||
# x = np.squeeze(x)
|
||||
# x = x[:, :, np.newaxis, np.newaxis]
|
||||
#
|
||||
# # Casting
|
||||
# x = x.astype(np.float32)
|
||||
# y = y.astype(np.int32)
|
||||
#
|
||||
# test_x.append(x)
|
||||
# test_y = y
|
||||
#
|
||||
# config = realTimeAutoScoring.config
|
||||
#
|
||||
# preds = []
|
||||
#
|
||||
# if config["model"] == "model-origin":
|
||||
# for night_idx, night_data in enumerate(zip(test_x, test_y)):
|
||||
# # Create minibatches for testing
|
||||
# night_x, night_y = night_data
|
||||
# test_minibatch_fn = iterate_batch_seq_minibatches(
|
||||
# night_x,
|
||||
# night_y,
|
||||
# batch_size=config["batch_size"],
|
||||
# seq_length=config["seq_length"],
|
||||
# )
|
||||
# # Evaluate
|
||||
# test_outs = sleepScoringModel.evaluate(test_minibatch_fn)
|
||||
# preds.extend(test_outs["test/preds"])
|
||||
# else:
|
||||
# for night_idx, night_data in enumerate(zip(test_x, test_y)):
|
||||
# # Create minibatches for testing
|
||||
# night_x, night_y = night_data
|
||||
# test_minibatch_fn = iterate_batch_multiple_seq_minibatches(
|
||||
# [night_x],
|
||||
# [night_y],
|
||||
# batch_size=config["batch_size"],
|
||||
# seq_length=config["seq_length"],
|
||||
# shuffle_idx=None,
|
||||
# augment_seq=False,
|
||||
# )
|
||||
# if (config.get('augment_signal') is not None) and config['augment_signal']:
|
||||
# # Evaluate
|
||||
# test_outs = sleepScoringModel.evaluate_aug(test_minibatch_fn)
|
||||
# else:
|
||||
# # Evaluate
|
||||
# test_outs = sleepScoringModel.evaluate(test_minibatch_fn)
|
||||
# preds.extend(test_outs["test/preds"])
|
||||
#
|
||||
# # Save labels and predictions (each night of each subject)
|
||||
# save_dict = {
|
||||
# "y_true": test_outs["test/trues"],
|
||||
# "y_pred": test_outs["test/preds"],
|
||||
# }
|
||||
#
|
||||
# # Object.plot_comparative_hyp(hyp_true = s_trues, hyp_pred = test_outs["test/preds"] , sub_name = Name, s_preds = test_outs["test/preds"],\
|
||||
# # s_acc = 'N/A' , s_kappa = 'N/A' , s_f1_score = 'N/A' ,\
|
||||
# # mark_REM = 'active', write_metrics = False,
|
||||
# # Title = 'True Hyp_'+ Name , save_fig = False,\
|
||||
# # directory = "./")
|
||||
# # directory = "P:/3022033.01/FilesForMathijs/daily_zmax_autoscoring/daily_zmax_hypnograms/
|
||||
#
|
||||
# # sampling_rate = 256
|
||||
# # lowcut = 0.3
|
||||
# # highcut = 30
|
||||
# # nyquist_freq = sampling_rate / 2.
|
||||
# # low = lowcut / nyquist_freq
|
||||
# # high = highcut / nyquist_freq
|
||||
# # # Req channel
|
||||
# # b, a = ssignal.butter(3, [low, high], btype='band')
|
||||
# # sigReq = ssignal.filtfilt(b, a, sigReq)
|
||||
# # sigRef = ssignal.filtfilt(b, a, sigRef)
|
||||
#
|
||||
#
|
||||
#
|
||||
# # signals = sigReq - sigRef
|
||||
# #
|
||||
# # signals = signals.reshape((1, signals.shape[0]))
|
||||
# #
|
||||
# # x = signals.astype(np.float32)
|
||||
# #
|
||||
# # data_epoched = np.reshape (signals,
|
||||
# # (int(signals.shape[1] / lenEpoch), lenEpoch, 1, 1 ), order='F')
|
||||
# #
|
||||
# # # Init
|
||||
# # test_x = []
|
||||
#
|
||||
#
|
||||
# # dataSamplesToAnalyzeBeginIndex = 0
|
||||
# # dataSampleCounter = 0
|
||||
# #
|
||||
# # predictions = []
|
||||
# #
|
||||
# # for row in recording:
|
||||
# # dataSampleCounter += 1
|
||||
# # if row[4] > 1:
|
||||
# # if dataSamplesToAnalyzeBeginIndex == 0:
|
||||
# # dataSamplesToAnalyzeBeginIndex = dataSampleCounter
|
||||
# #
|
||||
# # if dataSampleCounter == dataSamplesToAnalyzeBeginIndex+30*256:
|
||||
# # sig = recording[dataSamplesToAnalyzeBeginIndex:dataSamplesToAnalyzeBeginIndex+30*256]
|
||||
# # dataSamplesToAnalyzeBeginIndex = 0
|
||||
# # print(f"shape of sig: {len(sig)}")
|
||||
# # sigRef = [col[0] for col in sig]
|
||||
# # sigReq = [col[1] for col in sig]
|
||||
# # sigRef = np.asarray(sigRef)
|
||||
# # sigReq = np.asarray(sigReq)
|
||||
# # sigRef = sigRef.reshape((1, sigRef.shape[0]))
|
||||
# # sigReq = sigReq.reshape((1, sigReq.shape[0]))
|
||||
# # print(sigRef.shape, sigReq.shape)
|
||||
# # modelPrediction = realTimeAutoScoring.Predict_array(output_dir="./DataiBand/output/Fp1-Fp2_filtered",
|
||||
# # args_log_file="info_ch_extract.log", filtering_status=True,
|
||||
# # lowcut=0.3, highcut=30, fs=256, signal_req=sigReq, signal_ref=sigRef, model=sleepScoringModel)
|
||||
# # predictions.append(modelPrediction[0])
|
||||
#
|
||||
# =============================================================================
|
||||
|
||||
|
||||
# dataSamplesToAnalyzeBeginIndex = 0
|
||||
# dataSampleCounter = 0
|
||||
#
|
||||
# predictions = []
|
||||
#
|
||||
# for row in recording:
|
||||
# dataSampleCounter += 1
|
||||
# if row[4] > 1:
|
||||
# if dataSamplesToAnalyzeBeginIndex == 0:
|
||||
# dataSamplesToAnalyzeBeginIndex = dataSampleCounter
|
||||
#
|
||||
# if dataSampleCounter == dataSamplesToAnalyzeBeginIndex+30*256:
|
||||
# sig = recording[dataSamplesToAnalyzeBeginIndex:dataSamplesToAnalyzeBeginIndex+30*256]
|
||||
# dataSamplesToAnalyzeBeginIndex = 0
|
||||
# print(f"shape of sig: {len(sig)}")
|
||||
# sigRef = [col[0] for col in sig]
|
||||
# sigReq = [col[1] for col in sig]
|
||||
# sigRef = np.asarray(sigRef)
|
||||
# sigReq = np.asarray(sigReq)
|
||||
# sigRef = sigRef.reshape((1, sigRef.shape[0]))
|
||||
# sigReq = sigReq.reshape((1, sigReq.shape[0]))
|
||||
# print(sigRef.shape, sigReq.shape)
|
||||
# modelPrediction = realTimeAutoScoring.Predict_array(output_dir="./DataiBand/output/Fp1-Fp2_filtered",
|
||||
# args_log_file="info_ch_extract.log", filtering_status=True,
|
||||
# lowcut=0.3, highcut=30, fs=256, signal_req=sigReq, signal_ref=sigRef, model=sleepScoringModel)
|
||||
# predictions.append(modelPrediction[0])
|
||||
|
||||
@@ -1,36 +1,33 @@
|
||||
# =============================================================================
|
||||
# import realTimeAutoScoring
|
||||
# import numpy as np
|
||||
#
|
||||
# sleepScoringModel = realTimeAutoScoring.importModel("./out_QS/train/4")
|
||||
#
|
||||
# recording = np.loadtxt(Sample_data, delimiter=',')
|
||||
#
|
||||
# dataSamplesToAnalyzeBeginIndex = 0
|
||||
# dataSampleCounter = 0
|
||||
#
|
||||
# predictions = []
|
||||
#
|
||||
# for row in recording:
|
||||
# dataSampleCounter += 1
|
||||
# if row[4] > 1:
|
||||
# if dataSamplesToAnalyzeBeginIndex == 0:
|
||||
# dataSamplesToAnalyzeBeginIndex = dataSampleCounter
|
||||
#
|
||||
# if dataSampleCounter == dataSamplesToAnalyzeBeginIndex+30*256:
|
||||
# sig = recording[dataSamplesToAnalyzeBeginIndex:dataSamplesToAnalyzeBeginIndex+30*256]
|
||||
# dataSamplesToAnalyzeBeginIndex = 0
|
||||
# print(f"shape of sig: {len(sig)}")
|
||||
# sigRef = [col[0] for col in sig]
|
||||
# sigReq = [col[1] for col in sig]
|
||||
# sigRef = np.asarray(sigRef)
|
||||
# sigReq = np.asarray(sigReq)
|
||||
# sigRef = sigRef.reshape((1, sigRef.shape[0]))
|
||||
# sigReq = sigReq.reshape((1, sigReq.shape[0]))
|
||||
# print(sigRef.shape, sigReq.shape)
|
||||
# modelPrediction = realTimeAutoScoring.Predict_array(output_dir="./DataiBand/output/Fp1-Fp2_filtered",
|
||||
# args_log_file="info_ch_extract.log", filtering_status=True,
|
||||
# lowcut=0.3, highcut=30, fs=256, signal_req=sigReq, signal_ref=sigRef, model=sleepScoringModel)
|
||||
# predictions.append(modelPrediction[0])
|
||||
#
|
||||
# =============================================================================
|
||||
import realTimeAutoScoring
|
||||
import numpy as np
|
||||
|
||||
sleepScoringModel = realTimeAutoScoring.importModel("./out_QS/train/21")
|
||||
|
||||
recording = np.loadtxt(".\\2021-08-19 Pilot 8 Saba\\recording-date-2021-08-19-time-07-26-40-complete.txt", delimiter=',')
|
||||
|
||||
dataSamplesToAnalyzeBeginIndex = 0
|
||||
dataSampleCounter = 0
|
||||
|
||||
predictions = []
|
||||
|
||||
for row in recording:
|
||||
dataSampleCounter += 1
|
||||
if row[4] > 1:
|
||||
if dataSamplesToAnalyzeBeginIndex == 0:
|
||||
dataSamplesToAnalyzeBeginIndex = dataSampleCounter
|
||||
|
||||
if dataSampleCounter == dataSamplesToAnalyzeBeginIndex+30*256:
|
||||
sig = recording[dataSamplesToAnalyzeBeginIndex:dataSamplesToAnalyzeBeginIndex+30*256]
|
||||
dataSamplesToAnalyzeBeginIndex = 0
|
||||
print(f"shape of sig: {len(sig)}")
|
||||
sigRef = [col[0] for col in sig]
|
||||
sigReq = [col[1] for col in sig]
|
||||
sigRef = np.asarray(sigRef)
|
||||
sigReq = np.asarray(sigReq)
|
||||
sigRef = sigRef.reshape((1, sigRef.shape[0]))
|
||||
sigReq = sigReq.reshape((1, sigReq.shape[0]))
|
||||
print(sigRef.shape, sigReq.shape)
|
||||
modelPrediction = realTimeAutoScoring.Predict_array(output_dir="./DataiBand/output/Fp1-Fp2_filtered",
|
||||
args_log_file="info_ch_extract.log", filtering_status=True,
|
||||
lowcut=0.3, highcut=30, fs=256, signal_req=sigReq, signal_ref=sigRef, model=sleepScoringModel)
|
||||
predictions.append(modelPrediction[0])
|
||||
|
||||
+4
-158
@@ -5,73 +5,17 @@ import enum
|
||||
|
||||
|
||||
class ZmaxDataID(enum.Enum):
|
||||
"""
|
||||
Enumerating each data signal with a specific number.
|
||||
"""
|
||||
eegr = 0
|
||||
|
||||
"""
|
||||
The assigned number to EEG R channel
|
||||
"""
|
||||
eegl = 1
|
||||
|
||||
"""
|
||||
The assigned number to EEG L channel
|
||||
"""
|
||||
|
||||
dx = 2
|
||||
|
||||
"""
|
||||
The assigned number to acceleration in x direction of the IMU.
|
||||
"""
|
||||
|
||||
dy = 3
|
||||
|
||||
"""
|
||||
The assigned number to acceleration in y direction of the IMU.
|
||||
"""
|
||||
|
||||
dz = 4
|
||||
|
||||
"""
|
||||
The assigned number to acceleration in z direction of the IMU.
|
||||
"""
|
||||
|
||||
bodytemp = 5
|
||||
|
||||
"""
|
||||
The assigned number to body temperature data.
|
||||
"""
|
||||
|
||||
bat = 6
|
||||
|
||||
"""
|
||||
The assigned number to battery levels.
|
||||
"""
|
||||
|
||||
noise = 7
|
||||
|
||||
"""
|
||||
The assigned number to noise/microphone data.
|
||||
"""
|
||||
|
||||
light = 8
|
||||
|
||||
"""
|
||||
The assigned number to ambient light data.
|
||||
"""
|
||||
|
||||
nasal_l = 9
|
||||
|
||||
"""
|
||||
The assigned number to the left nasal channel.
|
||||
"""
|
||||
|
||||
nasal_r = 10
|
||||
|
||||
"""
|
||||
The assigned number to the right nasal channel.
|
||||
"""
|
||||
oxy_ir_ac = 11
|
||||
oxy_r_ac = 12
|
||||
oxy_dark_ac = 13
|
||||
@@ -81,13 +25,6 @@ class ZmaxDataID(enum.Enum):
|
||||
|
||||
|
||||
def connect():
|
||||
"""
|
||||
Initiate the connection by calling a ZmaxSocket object.
|
||||
|
||||
:param None: no input
|
||||
|
||||
:returns: socket
|
||||
"""
|
||||
socket = ZmaxSocket()
|
||||
socket.connect()
|
||||
print(socket.serverConnected)
|
||||
@@ -112,16 +49,9 @@ class ZmaxHeadband():
|
||||
|
||||
def read(self, reqIDs=[0, 1]):
|
||||
"""
|
||||
Reading the signal from ZmaxDataID class.
|
||||
|
||||
output refers to a list of the desired outputs of the function for example [0,1,3] returns [eegl, eegr, dy]
|
||||
[0=eegr, 1=eegl, 2=dx, 3=dy, 4=dz, 5=bodytemp, 6=bat, 7=noise, 8=light, 9=nasal_l, 10=nasal_r, 11=oxy_ir_ac,
|
||||
12=oxy_r_ac, 13=oxy_dark_ac, 14=oxy_ir_dc, 15=oxy_r_dc, 16=oxy_dark_dc]
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param reqIDs: The ID of the data to record.
|
||||
|
||||
:returns: reqVals
|
||||
"""
|
||||
reqVals = []
|
||||
buf = self.socket.receive_oneLineBuffer()
|
||||
@@ -172,45 +102,17 @@ class ZmaxHeadband():
|
||||
|
||||
def getbyteat(self, buf, idx=0):
|
||||
"""
|
||||
Receiving the bytes of data.
|
||||
|
||||
for example getbyteat("08-80-56-7F-EA",0) -> hex2dec(08)
|
||||
getbyteat("08-80-56-7F-EA",2) -> hex2dec(56)
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param buf: the data buffer.
|
||||
:param idx: the index of the data (indicating the data type).
|
||||
|
||||
:returns: self.hex2dec(s)
|
||||
|
||||
"""
|
||||
s = buf[idx * 3:idx * 3 + 2]
|
||||
return self.hex2dec(s)
|
||||
|
||||
def getwordat(self, buf, idx=0):
|
||||
|
||||
"""
|
||||
Get the word
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param buf: the data buffer.
|
||||
:param idx: the index of the data (indicating the data type).
|
||||
|
||||
:returns: w
|
||||
"""
|
||||
w = self.getbyteat(buf, idx) * 256 + self.getbyteat(buf, idx + 1)
|
||||
return w
|
||||
|
||||
def ScaleEEG(self, e): # word value to uV
|
||||
|
||||
"""
|
||||
Scale the EEG data by receiving the word and converting it to uV.
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param e: word to convert
|
||||
|
||||
:returns: d
|
||||
"""
|
||||
uvRange = 3952;
|
||||
d = e - 32768;
|
||||
d = d * uvRange;
|
||||
@@ -218,67 +120,24 @@ class ZmaxHeadband():
|
||||
return d
|
||||
|
||||
def ScaleAccel(self, dx): # word value to 'g'
|
||||
|
||||
"""
|
||||
Scale the acceleration value with respecto to the gravity (g).
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param dx: word value to be converted to 'g' scale
|
||||
"""
|
||||
d = dx * 4 / 4096 - 2
|
||||
return d
|
||||
|
||||
def BatteryVoltage(self, vbat): # word value to Volts
|
||||
|
||||
"""
|
||||
The battery voltage data
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param vbat: The word to be converted to battery voltage (v)
|
||||
|
||||
:returns: t (temperature)
|
||||
"""
|
||||
|
||||
v = vbat / 1024 * 6.60;
|
||||
return v
|
||||
|
||||
def BodyTemp(self, bodytemp): # word value to degrees C
|
||||
|
||||
"""
|
||||
The body temperature data.
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param bodytemp: The temperature in words (to be converted to degrees)
|
||||
|
||||
:returns: t (temperature)
|
||||
"""
|
||||
v = bodytemp / 1024 * 3.3
|
||||
t = 15 + ((v - 1.0446) / 0.0565537333333333)
|
||||
return t
|
||||
|
||||
def hex2dec(self, s):
|
||||
"""
|
||||
Return the integer value of a hexadecimal string 's'.
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param s: string value
|
||||
|
||||
:returns: int(s, 16)
|
||||
|
||||
"""
|
||||
"""return the integer value of a hexadecimal string s"""
|
||||
return int(s, 16)
|
||||
|
||||
def dec2hex(self, n, pad=0):
|
||||
"""
|
||||
return the hexadecimal string representation of integer 'n'
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param n: string value
|
||||
:param pad: padding
|
||||
|
||||
:returns: s.rjust(pad, '0')
|
||||
|
||||
"""
|
||||
"""return the hexadecimal string representation of integer n"""
|
||||
s = "%X" % n
|
||||
if pad == 0:
|
||||
return s
|
||||
@@ -288,9 +147,6 @@ class ZmaxHeadband():
|
||||
|
||||
def stimulate(self, rgb1=(0, 0, 2), rgb2=(0, 0, 2), pwm1=254, pwm2=0, t1=1, t2=3, reps=5, vib=1, alt=0):
|
||||
"""
|
||||
|
||||
Stimulation trigger.
|
||||
|
||||
example:
|
||||
LIVEMODE_SENDBYTES 15 6 111 04-00-00-02-00-00-02-FE-00-01-03-05-01-00\r\n
|
||||
command = "LIVEMODE_SENDBYTES"
|
||||
@@ -311,17 +167,6 @@ class ZmaxHeadband():
|
||||
reps = 05
|
||||
vib = 01
|
||||
alt = 00 # althernate eyes
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param rgb1: rgb value 1
|
||||
:param rgb2: rgb value 2
|
||||
:param pwm1: ON intensity
|
||||
:param pwm2: OFF intensity
|
||||
:param t1: time ON
|
||||
:param t2: time OFF
|
||||
:param reps: number of blinks/ repititions
|
||||
:param vib: Vibration triggering
|
||||
:param alt: Alternating the LEDs
|
||||
"""
|
||||
command = "LIVEMODE_SENDBYTES"
|
||||
retries = 15
|
||||
@@ -343,7 +188,8 @@ class ZmaxHeadband():
|
||||
i13 = self.dec2hex(vib, pad=2)
|
||||
i14 = self.dec2hex(alt, pad=2)
|
||||
|
||||
s = f"""{command} {retries} {self.msgn} {retry_ms} {i1}-{i2}-{i3}-{i4}-{i5}-{i6}-{i7}-{i8}-{i9}-{i10}-{i11}-{i12}-{i13}-{i14}\r\n"""
|
||||
s = f"""{command} {retries} {self.msgn} {retry_ms} {i1}-{i2}-{i3}-{i4}\
|
||||
-{i5}-{i6}-{i7}-{i8}-{i9}-{i10}-{i11}-{i12}-{i13}-{i14}\r\n"""
|
||||
# print(s)
|
||||
self.socket.sendString(s)
|
||||
self.msgn += 1
|
||||
@@ -2,11 +2,6 @@ import socket
|
||||
import sys
|
||||
|
||||
class ZmaxSocket:
|
||||
|
||||
"""
|
||||
Defining the ZmaxSocket, the relavant port and IP for connecting the ZmaxCoDo
|
||||
to the server
|
||||
"""
|
||||
def __init__(self, sock=None):
|
||||
self.MSGLEN = 4500 # InputBufferSize?
|
||||
self.serverConnected = False
|
||||
@@ -18,14 +13,6 @@ class ZmaxSocket:
|
||||
self.sock = sock
|
||||
|
||||
def connect(self, host='127.0.0.1', port=8000):
|
||||
|
||||
"""
|
||||
Connect the socket.
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param host: host address.
|
||||
:param port: port number
|
||||
"""
|
||||
try:
|
||||
self.sock.connect((host, port))
|
||||
self.serverConnected = True
|
||||
@@ -35,15 +22,6 @@ class ZmaxSocket:
|
||||
self.serverConnected = False
|
||||
|
||||
def send(self, msg):
|
||||
|
||||
"""
|
||||
Send message to the server.
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param msg: the message to be sent to the server.
|
||||
|
||||
|
||||
"""
|
||||
totalsent = 0
|
||||
while totalsent < self.MSGLEN:
|
||||
sent = self.sock.send(msg[totalsent:])
|
||||
@@ -53,14 +31,6 @@ class ZmaxSocket:
|
||||
totalsent = totalsent + sent
|
||||
|
||||
def receive_completeBuffer(self):
|
||||
|
||||
"""
|
||||
Receiving the complete data buffer from the server.
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
|
||||
:returns: message to carry
|
||||
"""
|
||||
chunks = []
|
||||
bytes_recd = 0
|
||||
while bytes_recd < self.MSGLEN:
|
||||
@@ -80,15 +50,6 @@ class ZmaxSocket:
|
||||
return msg.decode("utf-8")
|
||||
|
||||
def receive_oneLineBuffer(self, type=1):
|
||||
|
||||
"""
|
||||
Receiving the online buffer from the server.
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param type: data type (0: binary, 1: string)
|
||||
|
||||
:returns: message
|
||||
"""
|
||||
chunks = []
|
||||
bytes_recd = 0
|
||||
while bytes_recd < self.MSGLEN:
|
||||
@@ -115,26 +76,11 @@ class ZmaxSocket:
|
||||
return msg.decode("utf-8")
|
||||
|
||||
def sendString(self, msg):
|
||||
|
||||
"""
|
||||
Send string to the server
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param msg: message to be sent
|
||||
|
||||
"""
|
||||
# msg = ("%s\n" % "HELLO").encode('utf-8')
|
||||
msg = msg.encode('utf-8')
|
||||
self.sock.send(msg)
|
||||
|
||||
def live_recieve(self):
|
||||
|
||||
"""
|
||||
receive data chunk online.
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:returns: chunks
|
||||
"""
|
||||
chunks = []
|
||||
while True:
|
||||
chunk = self.sock.recv(2048) # 1024?
|
||||
|
||||
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
@@ -1,3 +1,3 @@
|
||||
Create an environment from YAML file
|
||||
******** Create an environment from YAML file *************
|
||||
|
||||
conda env create --name dreamento --file dreamento.yml
|
||||
conda env create --name dreamento --file dreamento.yml
|
||||
+240
-100
@@ -26978,143 +26978,283 @@
|
||||
2022-06-16 12:02:16 [INFO ] Initializing the model ...
|
||||
2022-06-16 12:02:17 [INFO ] Shape:
|
||||
2022-06-16 12:02:17 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:07:22 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:07:22 [INFO ]
|
||||
2022-07-05 10:05:48 [INFO ] Loading new array for prediciton...
|
||||
2022-07-05 10:05:48 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:07:22 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:07:22 [INFO ] Shape:
|
||||
2022-07-01 18:07:22 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:07:52 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:07:52 [INFO ]
|
||||
2022-07-05 10:05:48 [INFO ] Initializing the model ...
|
||||
2022-07-05 10:05:48 [INFO ] Shape:
|
||||
2022-07-05 10:05:48 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:26:16 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:26:16 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:07:52 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:07:52 [INFO ] Shape:
|
||||
2022-07-01 18:07:52 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:08:22 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:08:22 [INFO ]
|
||||
2022-07-06 11:26:16 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:26:16 [INFO ] Shape:
|
||||
2022-07-06 11:26:16 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:26:46 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:26:46 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:08:22 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:08:22 [INFO ] Shape:
|
||||
2022-07-01 18:08:22 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:08:53 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:08:53 [INFO ]
|
||||
2022-07-06 11:26:46 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:26:46 [INFO ] Shape:
|
||||
2022-07-06 11:26:46 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:27:16 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:27:16 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:08:53 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:08:53 [INFO ] Shape:
|
||||
2022-07-01 18:08:53 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:09:23 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:09:23 [INFO ]
|
||||
2022-07-06 11:27:16 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:27:16 [INFO ] Shape:
|
||||
2022-07-06 11:27:16 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:27:47 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:27:47 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:09:23 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:09:23 [INFO ] Shape:
|
||||
2022-07-01 18:09:23 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:09:53 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:09:53 [INFO ]
|
||||
2022-07-06 11:27:47 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:27:47 [INFO ] Shape:
|
||||
2022-07-06 11:27:47 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:28:17 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:28:17 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:09:53 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:09:53 [INFO ] Shape:
|
||||
2022-07-01 18:09:53 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:10:24 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:10:24 [INFO ]
|
||||
2022-07-06 11:28:17 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:28:17 [INFO ] Shape:
|
||||
2022-07-06 11:28:17 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:28:47 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:28:47 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:10:24 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:10:24 [INFO ] Shape:
|
||||
2022-07-01 18:10:24 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:10:54 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:10:54 [INFO ]
|
||||
2022-07-06 11:28:47 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:28:47 [INFO ] Shape:
|
||||
2022-07-06 11:28:47 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:29:15 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:29:15 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:10:54 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:10:54 [INFO ] Shape:
|
||||
2022-07-01 18:10:54 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:11:24 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:11:24 [INFO ]
|
||||
2022-07-06 11:29:15 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:29:15 [INFO ] Shape:
|
||||
2022-07-06 11:29:15 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:32:55 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:32:55 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:11:24 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:11:24 [INFO ] Shape:
|
||||
2022-07-01 18:11:24 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:11:54 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:11:54 [INFO ]
|
||||
2022-07-06 11:32:55 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:32:55 [INFO ] Shape:
|
||||
2022-07-06 11:32:55 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:33:24 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:33:24 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:11:54 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:11:54 [INFO ] Shape:
|
||||
2022-07-01 18:11:54 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:12:25 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:12:25 [INFO ]
|
||||
2022-07-06 11:33:25 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:33:25 [INFO ] Shape:
|
||||
2022-07-06 11:33:25 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:33:55 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:33:55 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:12:25 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:12:25 [INFO ] Shape:
|
||||
2022-07-01 18:12:25 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:12:55 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:12:55 [INFO ]
|
||||
2022-07-06 11:33:55 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:33:55 [INFO ] Shape:
|
||||
2022-07-06 11:33:55 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:34:25 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:34:25 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:12:55 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:12:55 [INFO ] Shape:
|
||||
2022-07-01 18:12:55 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:13:25 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:13:25 [INFO ]
|
||||
2022-07-06 11:34:25 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:34:25 [INFO ] Shape:
|
||||
2022-07-06 11:34:25 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:34:55 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:34:55 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:13:25 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:13:25 [INFO ] Shape:
|
||||
2022-07-01 18:13:25 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:13:56 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:13:56 [INFO ]
|
||||
2022-07-06 11:34:55 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:34:55 [INFO ] Shape:
|
||||
2022-07-06 11:34:55 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:35:26 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:35:26 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:13:56 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:13:56 [INFO ] Shape:
|
||||
2022-07-01 18:13:56 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:14:26 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:14:26 [INFO ]
|
||||
2022-07-06 11:35:26 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:35:26 [INFO ] Shape:
|
||||
2022-07-06 11:35:26 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:35:56 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:35:56 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:14:26 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:14:26 [INFO ] Shape:
|
||||
2022-07-01 18:14:26 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:14:56 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:14:56 [INFO ]
|
||||
2022-07-06 11:35:56 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:35:56 [INFO ] Shape:
|
||||
2022-07-06 11:35:56 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:36:26 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:36:26 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:14:56 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:14:56 [INFO ] Shape:
|
||||
2022-07-01 18:14:56 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:15:26 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:15:26 [INFO ]
|
||||
2022-07-06 11:36:26 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:36:26 [INFO ] Shape:
|
||||
2022-07-06 11:36:26 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:36:56 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:36:56 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:15:26 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:15:26 [INFO ] Shape:
|
||||
2022-07-01 18:15:26 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:15:57 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:15:57 [INFO ]
|
||||
2022-07-06 11:36:56 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:36:56 [INFO ] Shape:
|
||||
2022-07-06 11:36:56 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:37:27 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:37:27 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:15:57 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:15:57 [INFO ] Shape:
|
||||
2022-07-01 18:15:57 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:16:27 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:16:27 [INFO ]
|
||||
2022-07-06 11:37:27 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:37:27 [INFO ] Shape:
|
||||
2022-07-06 11:37:27 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:37:57 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:37:57 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:16:27 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:16:27 [INFO ] Shape:
|
||||
2022-07-01 18:16:27 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-01 18:16:57 [INFO ] Loading new array for prediciton...
|
||||
2022-07-01 18:16:57 [INFO ]
|
||||
2022-07-06 11:37:57 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:37:57 [INFO ] Shape:
|
||||
2022-07-06 11:37:57 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:38:27 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:38:27 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-01 18:16:57 [INFO ] Initializing the model ...
|
||||
2022-07-01 18:16:57 [INFO ] Shape:
|
||||
2022-07-01 18:16:57 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:38:27 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:38:27 [INFO ] Shape:
|
||||
2022-07-06 11:38:27 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:38:57 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:38:57 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:38:57 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:38:57 [INFO ] Shape:
|
||||
2022-07-06 11:38:57 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:39:28 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:39:28 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:39:28 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:39:28 [INFO ] Shape:
|
||||
2022-07-06 11:39:28 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:39:58 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:39:58 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:39:58 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:39:58 [INFO ] Shape:
|
||||
2022-07-06 11:39:58 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:40:28 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:40:28 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:40:28 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:40:28 [INFO ] Shape:
|
||||
2022-07-06 11:40:28 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:40:59 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:40:59 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:40:59 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:40:59 [INFO ] Shape:
|
||||
2022-07-06 11:40:59 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:41:29 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:41:29 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:41:29 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:41:29 [INFO ] Shape:
|
||||
2022-07-06 11:41:29 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:41:59 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:41:59 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:41:59 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:41:59 [INFO ] Shape:
|
||||
2022-07-06 11:41:59 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:42:29 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:42:29 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:42:29 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:42:29 [INFO ] Shape:
|
||||
2022-07-06 11:42:29 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:43:00 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:43:00 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:43:00 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:43:00 [INFO ] Shape:
|
||||
2022-07-06 11:43:00 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:43:30 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:43:30 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:43:30 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:43:30 [INFO ] Shape:
|
||||
2022-07-06 11:43:30 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:44:00 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:44:00 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:44:00 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:44:00 [INFO ] Shape:
|
||||
2022-07-06 11:44:00 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:44:31 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:44:31 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:44:31 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:44:31 [INFO ] Shape:
|
||||
2022-07-06 11:44:31 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:45:01 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:45:01 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:45:01 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:45:01 [INFO ] Shape:
|
||||
2022-07-06 11:45:01 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:45:32 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:45:32 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:45:32 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:45:32 [INFO ] Shape:
|
||||
2022-07-06 11:45:32 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:46:02 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:46:02 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:46:02 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:46:02 [INFO ] Shape:
|
||||
2022-07-06 11:46:02 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:46:32 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:46:32 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:46:32 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:46:32 [INFO ] Shape:
|
||||
2022-07-06 11:46:32 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:48:17 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:48:17 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:48:17 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:48:17 [INFO ] Shape:
|
||||
2022-07-06 11:48:17 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:48:47 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:48:47 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:48:47 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:48:47 [INFO ] Shape:
|
||||
2022-07-06 11:48:47 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:52:32 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:52:32 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:52:32 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:52:32 [INFO ] Shape:
|
||||
2022-07-06 11:52:32 [INFO ] (1, 7680, 1, 1)
|
||||
2022-07-06 11:53:02 [INFO ] Loading new array for prediciton...
|
||||
2022-07-06 11:53:02 [INFO ]
|
||||
=======================================
|
||||
|
||||
2022-07-06 11:53:02 [INFO ] Initializing the model ...
|
||||
2022-07-06 11:53:02 [INFO ] Shape:
|
||||
2022-07-06 11:53:02 [INFO ] (1, 7680, 1, 1)
|
||||
|
||||
+2
-32
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
Arquivo binário não exibido.
+1
-107
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
+35
-345
@@ -19,20 +19,25 @@ import periodogram # for periodogram plotting
|
||||
import pyqtgraph as pg # for eeg plotting
|
||||
import scipy.signal as ssignal # for signal filtering 4 plotting EEG
|
||||
from matplotlib.backends.backend_qt5agg import (NavigationToolbar2QT as NavigationToolbar) # for spectrogram plotting
|
||||
def tic():
|
||||
#Homemade version of matlab tic and toc functions
|
||||
import time
|
||||
global startTime_for_tictoc
|
||||
startTime_for_tictoc = time.time()
|
||||
def toc(echo=True):
|
||||
import time
|
||||
if 'startTime_for_tictoc' in globals():
|
||||
if echo:
|
||||
print( "Elapsed time is " + str(time.time() - startTime_for_tictoc) + " seconds.")
|
||||
return (time.time() - startTime_for_tictoc)
|
||||
else:
|
||||
if echo:
|
||||
print("Toc: start time not set")
|
||||
return -1
|
||||
|
||||
|
||||
|
||||
class Window:
|
||||
"""
|
||||
This is one of the main programming classes of the ZmaxCoDo responsible for
|
||||
all the the creation of graphical user-interface (GUI), relavant parameters
|
||||
for the recording (e.g., which signals to record), stimulation
|
||||
(e.g., the properties of a sensory stimulation), data representation and its
|
||||
corresponding scales (e.g., amplitude scale), the buttons and the corresponding
|
||||
functions of the GUI's buttons can be defined.
|
||||
|
||||
|
||||
"""
|
||||
def __init__(self):
|
||||
self.hb = None
|
||||
self.dlg = uic.loadUi("mainWindows.ui")
|
||||
@@ -96,8 +101,8 @@ class Window:
|
||||
# {background-color: #e7e7e7; color: black;} /* Gray */
|
||||
# {background-color: #555555;} /* Black */
|
||||
self.dlg.graphWidget.setBackground('w')
|
||||
self.dlg.graphWidget.setLabel('left', "<span style=\"color:black;font-size:14px\">EEG (uV)</span>")
|
||||
self.dlg.graphWidget.setLabel('bottom', "<span style=\"color:black;font-size:14px\">Time (sec)</span>")
|
||||
self.dlg.graphWidget.setLabel('left', "<span style=\"color:red;font-size:14px\">EEG (uV)</span>")
|
||||
self.dlg.graphWidget.setLabel('bottom', "<span style=\"color:red;font-size:14px\">Time (sec)</span>")
|
||||
self.displayedXrangeCounter = 0 # for pyqtgraph eeg plot dynamic range
|
||||
self.desiredXrange = 5 # set default (0,5) - (5,10) - (10-15) - ...
|
||||
self.desiredYrange = 60 # set default (-60,60)
|
||||
@@ -142,47 +147,15 @@ class Window:
|
||||
self.dlg.show()
|
||||
|
||||
def rSliderChanged(self, value):
|
||||
"""
|
||||
Defines the slider for 'red' color of visual stimulation.
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param value: the value from 0 to 2
|
||||
|
||||
:returns: self.dlg.rValLabel.setText(str(value))
|
||||
"""
|
||||
self.dlg.rValLabel.setText(str(value))
|
||||
|
||||
def gSliderChanged(self, value):
|
||||
"""
|
||||
Defines the slider for 'green' color of visual stimulation.
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param value: the value from 0 to 2
|
||||
|
||||
:returns: self.dlg.gValLabel.setText(str(value))
|
||||
"""
|
||||
self.dlg.gValLabel.setText(str(value))
|
||||
|
||||
def bSliderChanged(self, value):
|
||||
"""
|
||||
Defines the slider for 'blue' color of visual stimulation.
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param value: the value from 0 to 2
|
||||
|
||||
:returns: self.dlg.bValLabel.setText(str(value))
|
||||
"""
|
||||
self.dlg.bValLabel.setText(str(value))
|
||||
|
||||
def pwmSliderChanged(self, value):
|
||||
""""
|
||||
Defines the intensity of the visual stimulation.
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param value: the value from 0 to 100
|
||||
|
||||
:returns: self.dlg.intensitySliderLabel.setText(s)
|
||||
"""
|
||||
val = value
|
||||
val = (val - 2) / 252 * 100
|
||||
s = f"{int(np.ceil(val))}%"
|
||||
@@ -190,15 +163,6 @@ class Window:
|
||||
self.dlg.intensitySliderLabel.setText(s)
|
||||
|
||||
def connectSoftwareButton(self):
|
||||
|
||||
"""
|
||||
Initiates the ZmaxHeadband() and check the socket method of it to check
|
||||
whether the server is running or is not yet connected.
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
|
||||
:returns: self.dlg.connectSoftwareButton.setStyleSheet() , self.dlg.connectSoftwareButton.setText(), self.dlg.triggerLightButton.setEnabled(True), self.dlg.recordButton.setEnabled(True)
|
||||
"""
|
||||
self.hb = ZmaxHeadband()
|
||||
if self.hb.socket is None: # HDServer is not running
|
||||
self.dlg.connectSoftwareButton.setStyleSheet("background-color: #f44336; color: white;") # /* Red */
|
||||
@@ -218,13 +182,6 @@ class Window:
|
||||
self.setupPredictionPanelInGUI(enabled=False)
|
||||
|
||||
def AudioBrowserClicked(self):
|
||||
"""
|
||||
The method to address the audio file for audio stimulation
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
|
||||
:returns: self.audio_file_path, self.audio_file_name, self.dlg.triggerSoundButton.setEnabled(True), self.dlg.audioNameLabel.setText(str(self.audio_file_name))
|
||||
"""
|
||||
default_path = ".\\"
|
||||
self.audio_file_path, _ = QtWidgets.QFileDialog.getOpenFileName(self.dlg, 'Open File', default_path, '*.wav', )
|
||||
self.audio_file_name = self.audio_file_path.split('/')[-1]
|
||||
@@ -232,17 +189,6 @@ class Window:
|
||||
self.dlg.triggerSoundButton.setEnabled(True)
|
||||
|
||||
def triggerLightClicked(self):
|
||||
|
||||
"""
|
||||
Receives the properties for the light/visual stimulation and then present the cue by activating self.hb.stimulate().
|
||||
If the software is already 'recording', then the stimulation properties will
|
||||
be stored using and the exact time of stimulation will be received from
|
||||
self.recordingThread.getCurrentSampleInformation()
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
|
||||
:returns: self.recordingThread.getCurrentSampleInformation()
|
||||
"""
|
||||
# print(self.dlg.offTimeSpinBox.value()*10)
|
||||
self.hb.stimulate((self.dlg.rSlider.value(), self.dlg.gSlider.value(), self.dlg.bSlider.value()),
|
||||
(self.dlg.rSlider.value(), self.dlg.gSlider.value(), self.dlg.bSlider.value()),
|
||||
@@ -251,7 +197,7 @@ class Window:
|
||||
vib=self.dlg.vibrationBox.isChecked(), alt=self.dlg.altEyesBox.isChecked())
|
||||
if self.isRecording:
|
||||
# for saving time (sec) and sample number (from 1 to 250:260) of triggered simulation
|
||||
stimulationSampleNum, stimulationSecondNum, stimulationTotalSampleNum = self.recordingThread.getCurrentSampleInformation()
|
||||
stimulationSampleNum, stimulationSecondNum = self.recordingThread.getCurrentSampleInformation()
|
||||
color = ""
|
||||
if (str(self.dlg.rSlider.value()) == "1" or str(self.dlg.rSlider.value()) == "2") and \
|
||||
self.dlg.gSlider.value() == 0 and self.dlg.bSlider.value() == 0:
|
||||
@@ -268,7 +214,7 @@ class Window:
|
||||
else:
|
||||
color = f"mixed color {self.dlg.rSlider.value()}, {self.dlg.gSlider.value()}, {self.dlg.bSlider.value()}"
|
||||
|
||||
self.stimulationDataBase[f"LIGHT sample {stimulationSampleNum}, second {stimulationSecondNum}, totalSample {stimulationTotalSampleNum}"] = \
|
||||
self.stimulationDataBase[f"LIGHT sample {stimulationSampleNum}, second {stimulationSecondNum}"] = \
|
||||
f"""{color}, \
|
||||
pwm: {self.dlg.pwmSlider.value()}, {0}, On: {int(self.dlg.onTimeSpinBox.value() * 10)}, \
|
||||
Off: {int(self.dlg.offTimeSpinBox.value() * 10)}, Reps: {self.dlg.repetitionsBox.value()}, \
|
||||
@@ -276,16 +222,6 @@ Vib: {self.dlg.vibrationBox.isChecked()}, Alt: {self.dlg.altEyesBox.isChecked()}
|
||||
print(self.stimulationDataBase)
|
||||
|
||||
def text2speech(self, txt):
|
||||
|
||||
"""
|
||||
Text-to-speech converter for communication with the participant.
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
|
||||
:param txt: the text to be converted to speech.
|
||||
|
||||
:returns: an audio file, ie., f"{file_path}\\{dt_string}.wav"
|
||||
"""
|
||||
file_path = ".\\voices\\text2speech"
|
||||
Path(f"{file_path}").mkdir(parents=True, exist_ok=True) # ensures directory exists
|
||||
myVoice = gTTS(text=txt, lang='en', slow=False) # text 2 speech
|
||||
@@ -297,55 +233,30 @@ Vib: {self.dlg.vibrationBox.isChecked()}, Alt: {self.dlg.altEyesBox.isChecked()}
|
||||
return f"{file_path}\\{dt_string}.wav" # returns output file name
|
||||
|
||||
def triggerSoundClicked(self):
|
||||
|
||||
"""
|
||||
Presents the audio file which is loaded using AudioBrowserClicked
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
|
||||
:returns: play the audio cue and store the properties and timing in self.stimulationDataBase
|
||||
"""
|
||||
if self.audio_file_name != "":
|
||||
QSound.play(self.audio_file_path) # plays .wav audio file
|
||||
|
||||
if self.isRecording:
|
||||
# for saving time (sec) and sample number (from 1 to 250:260) of triggered simulation
|
||||
stimulationSampleNum, stimulationSecondNum, stimulationTotalSampleNum = self.recordingThread.getCurrentSampleInformation()
|
||||
|
||||
self.stimulationDataBase[f"SOUND sample {stimulationSampleNum}, second {stimulationSecondNum}, totalSample {stimulationTotalSampleNum}"] = \
|
||||
stimulationSampleNum, stimulationSecondNum = self.recordingThread.getCurrentSampleInformation()
|
||||
self.stimulationDataBase[f"SOUND sample {stimulationSampleNum}, second {stimulationSecondNum}"] = \
|
||||
f"""{self.audio_file_path}"""
|
||||
print(self.stimulationDataBase)
|
||||
|
||||
def triggerText2SpeechClicked(self):
|
||||
"""
|
||||
Convert the text to speech, create a .wav file and play it.
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
|
||||
:returns: play the text-to-speech cue and store the properties and timing in self.stimulationDataBase
|
||||
"""
|
||||
if self.dlg.textToSpeechLineEdit.text() != "":
|
||||
try:
|
||||
voiceFile = self.text2speech(self.dlg.textToSpeechLineEdit.text()) # text2speech and save .wav
|
||||
QSound.play(voiceFile) # plays saved .wav file, which contain speeched-voice
|
||||
if self.isRecording: # if a recording is in progress...
|
||||
# for saving time (sec) and sample number (from 1 to 250:260) of triggered simulation
|
||||
stimulationSampleNum, stimulationSecondNum, stimulationTotalSampleNum = self.recordingThread.getCurrentSampleInformation()
|
||||
self.stimulationDataBase[f"TEXT2SPEECH sample {stimulationSampleNum}, second {stimulationSecondNum}, totalSample {stimulationTotalSampleNum}"] = \
|
||||
stimulationSampleNum, stimulationSecondNum = self.recordingThread.getCurrentSampleInformation()
|
||||
self.stimulationDataBase[f"TEXT2SPEECH sample {stimulationSampleNum}, second {stimulationSecondNum}"] = \
|
||||
f"""{self.dlg.textToSpeechLineEdit.text()}"""
|
||||
except:
|
||||
print("No internet connection for playing speech")
|
||||
|
||||
def textToSpeechLineEditChanged(self):
|
||||
|
||||
"""
|
||||
Activate the text2speech button when a text exists.
|
||||
|
||||
:param self:access the attributes and methods of the class
|
||||
|
||||
:returns: self.dlg.triggerText2SpeechButton.setEnabled(True/False)
|
||||
|
||||
"""
|
||||
if self.dlg.textToSpeechLineEdit.text() != "":
|
||||
self.dlg.triggerText2SpeechButton.setEnabled(True)
|
||||
|
||||
@@ -353,17 +264,6 @@ Vib: {self.dlg.vibrationBox.isChecked()}, Alt: {self.dlg.altEyesBox.isChecked()}
|
||||
self.dlg.triggerText2SpeechButton.setEnabled(False)
|
||||
|
||||
def recordClicked(self):
|
||||
|
||||
"""
|
||||
Start/stop recording, load relavant autoscoring algorithms, and
|
||||
communicate with the thread to transmit 30-seconds epochs for
|
||||
plotting and analysis.
|
||||
|
||||
:param self:access the attributes and methods of the class
|
||||
|
||||
:returns: self.recordingThread.finished.connect(self.onRecordingFinished), self.recordingThread.recordingFinishedSignal.connect(self.onRecordingFinishedWriteStimulationDB), self.recordingThread.epochPredictionResultSignal.connect(self.displayEpochPredictionResult) , self.recordingThread.sendEEGdata2MainWindow.connect(self.getEEG_from_thread)
|
||||
|
||||
"""
|
||||
if self.isRecording is False:
|
||||
self.recordingThread = RecordThread()
|
||||
if self.firstRecording:
|
||||
@@ -399,42 +299,17 @@ Vib: {self.dlg.vibrationBox.isChecked()}, Alt: {self.dlg.altEyesBox.isChecked()}
|
||||
# self.dlg.graphWidget.clear()
|
||||
|
||||
def updateRecordBtnText(self, timeInSeconds):
|
||||
"""
|
||||
change the shape of the record button before, during, and after recording.
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param timeInSeconds: The passed time.
|
||||
"""
|
||||
|
||||
m, s = divmod(timeInSeconds, 60)
|
||||
h, m = divmod(m, 60)
|
||||
self.dlg.recordButton.setText(f'{h:d}:{m:02d}:{s:02d}')
|
||||
|
||||
def displayEpochPredictionResult(self, predResult, epochNum):
|
||||
|
||||
"""
|
||||
Display of the autosciring results
|
||||
|
||||
:param self: access the attributes and methods of the class
|
||||
:param predResult: the predictions
|
||||
:param epochNum: Epoch number
|
||||
|
||||
:returns: self.dlg.appDisplay.appendHtml(f"<font style='color:{stagesListColor[predResult]};' size='4'>{epochNum:03}. {stagesList[predResult]}</font>")
|
||||
|
||||
"""
|
||||
stagesList = ['W', 'N1', 'N2', 'N3', 'REM', 'MOVE', 'UNK']
|
||||
stagesListColor = ['SlateBlue', 'MediumSeaGreen', 'DodgerBlue', 'Violet', 'Tomato', 'Gray', 'LightGray']
|
||||
self.dlg.appDisplay.appendHtml(f"<font style='color:{stagesListColor[predResult]};' size='4'>{epochNum:03}. {stagesList[predResult]}</font>")
|
||||
|
||||
def onRecordingFinished(self):
|
||||
"""
|
||||
When the recording is finished, this function is called to chnage the icon shape
|
||||
, change text, and the rest of initialization for the next recording.
|
||||
|
||||
:param self: access the attributes and methods of the class.
|
||||
|
||||
|
||||
"""
|
||||
# when the recording is finished, this function is called
|
||||
self.dlg.recordButton.setIcon(QIcon('.\\graphics\\record_gray.png'))
|
||||
self.isRecording = False
|
||||
lastRecording = self.dlg.recordButton.text() # get last recording duration from the button text :)
|
||||
@@ -442,20 +317,6 @@ Vib: {self.dlg.vibrationBox.isChecked()}, Alt: {self.dlg.altEyesBox.isChecked()}
|
||||
self.dlg.markerLineEdit.setPlaceholderText('A remarkable happening....')
|
||||
|
||||
def onRecordingFinishedWriteStimulationDB(self, fileName):
|
||||
|
||||
"""
|
||||
Writing the output of the recordings. This method generates two outputs,
|
||||
namely the stimulation marker/annotations file (*.json) and the
|
||||
predicitons of the real-time scoring (*.txt)
|
||||
|
||||
:param self: access the attributes and methods of the class.
|
||||
|
||||
:param fileName: filename, which is the date and time of the start of reording
|
||||
|
||||
:returns: *.json, *.txt
|
||||
|
||||
"""
|
||||
|
||||
# save triggered stimulation information on disk:
|
||||
with open(f'{fileName}-markers.json', 'w') as fp:
|
||||
json.dump(self.stimulationDataBase, fp, indent=4, separators=(',', ': '))
|
||||
@@ -467,67 +328,26 @@ Vib: {self.dlg.vibrationBox.isChecked()}, Alt: {self.dlg.altEyesBox.isChecked()}
|
||||
outfile.write("\n".join(str(item) for item in self.scoring_predictions))
|
||||
|
||||
def setMarkerButtonPressed(self):
|
||||
|
||||
"""
|
||||
Pressing 'set markers' button to store the relavant information regarding
|
||||
the description and the timing of an annotation.
|
||||
|
||||
:param self: access the attributes and methods of the class.
|
||||
|
||||
"""
|
||||
if self.isRecording: # if a recording is in progress...
|
||||
# for saving time (sec) and sample number (from 1 to 250:260) of triggered simulation
|
||||
stimulationSampleNum, stimulationSecondNum, stimulationTotalSampleNum = self.recordingThread.getCurrentSampleInformation()
|
||||
self.stimulationDataBase[f"MARKER sample {stimulationSampleNum}, second {stimulationSecondNum}, totalSample {stimulationTotalSampleNum}"] = \
|
||||
stimulationSampleNum, stimulationSecondNum = self.recordingThread.getCurrentSampleInformation()
|
||||
self.stimulationDataBase[f"MARKER sample {stimulationSampleNum}, second {stimulationSecondNum}"] = \
|
||||
f"""{self.dlg.markerLineEdit.text()}"""
|
||||
self.dlg.markerLineEdit.setPlaceholderText(f'{self.dlg.markerLineEdit.text()} - SAVED!')
|
||||
self.previousMarkerLineEditValue = self.dlg.markerLineEdit.text()
|
||||
self.dlg.markerLineEdit.setText("")
|
||||
|
||||
def markerLineEditChanged(self):
|
||||
|
||||
"""
|
||||
Retrieving the last marker by pushing '...'. This is useful for setting up
|
||||
the repititive markers withou wasting time on retyping them.
|
||||
|
||||
:param self: access the attributes and methods of the class.
|
||||
|
||||
:returns: self.dlg.markerLineEdit.setText(self.previousMarkerLineEditValue)
|
||||
"""
|
||||
if self.dlg.markerLineEdit.text() == "...":
|
||||
self.dlg.markerLineEdit.setText(self.previousMarkerLineEditValue)
|
||||
|
||||
def scoreSleepCheckBoxEnabled(self):
|
||||
|
||||
"""
|
||||
Enabling autoscoring checkbox in the GUI
|
||||
|
||||
:param self: access the attributes and methods of the class.
|
||||
|
||||
"""
|
||||
self.setupPredictionPanelInGUI(enabled=True)
|
||||
|
||||
def scoreSleepCheckBoxDisabled(self):
|
||||
|
||||
"""
|
||||
Disabling autoscoring checkbox in the GUI
|
||||
|
||||
:param self: access the attributes and methods of the class.
|
||||
|
||||
"""
|
||||
self.setupPredictionPanelInGUI(enabled=False)
|
||||
|
||||
def setupPredictionPanelInGUI(self, enabled=True):
|
||||
|
||||
"""
|
||||
Designing the autoscoring panel in the GUI
|
||||
|
||||
:param self: access the attributes and methods of the class.
|
||||
|
||||
:param enabled: enable/disable the prediction panel.
|
||||
|
||||
"""
|
||||
|
||||
if enabled:
|
||||
self.dlg.PredictionLabel.setStyleSheet("color:#000;")
|
||||
self.dlg.appDisplay.setDisabled(False) # enable
|
||||
@@ -539,14 +359,6 @@ Vib: {self.dlg.vibrationBox.isChecked()}, Alt: {self.dlg.altEyesBox.isChecked()}
|
||||
self.dlg.sleepScoringMethodComboBox.setEnabled(False) # disable
|
||||
|
||||
def resetEEGPlotButtonPressed(self):
|
||||
|
||||
"""
|
||||
The button to adjust the time-axis length of the online plotting of the
|
||||
EEG channels. Set up the desired time and then push this button.
|
||||
|
||||
:param self: access the attributes and methods of the class.
|
||||
|
||||
"""
|
||||
# pen = pg.mkPen(color=(255, 0, 0), width=1)
|
||||
# self.dlg.graphWidget.clear()
|
||||
# # self.dlg.graphWidget.setXRange(0, 30, padding=0)
|
||||
@@ -589,28 +401,8 @@ Vib: {self.dlg.vibrationBox.isChecked()}, Alt: {self.dlg.altEyesBox.isChecked()}
|
||||
plot_EEG=False, plot_periodogram=False,
|
||||
plot_spectrogram=False, sleep_scoring=True,
|
||||
epoch_counter=0):
|
||||
"""
|
||||
The main method to connect the thread to the main window (GUI).
|
||||
Getting the desired signals (EEG L and EEG R) from the thread and apply
|
||||
the relavant analysis such as scoring, TFR, and periodogram analysis.
|
||||
|
||||
:param self: access the attributes and methods of the class.
|
||||
:param eegSignal_r: the EEG R recording.
|
||||
:param eegSignal_l: the EEG L recording.
|
||||
:param plot_EEG: PLotting EEG in real-time.
|
||||
:param plot_periodogram: plotting/updating periodogram every epoch (30 s)
|
||||
:param plot_spectrogram: plotting/updating TFR every epoch (30 s)
|
||||
:param sleep_scoring: enable/disable sleep scoring
|
||||
:param epoch_counter: the counter for the epoch number
|
||||
|
||||
:returns: autoscoring (self.scoring_predictions.append()),
|
||||
spectrogram (self.spectrogramMplWidget.canvas.draw()),
|
||||
periodogram (self.periodogramMplWidget.canvas.draw())
|
||||
|
||||
"""
|
||||
self.epochCounter = epoch_counter
|
||||
|
||||
|
||||
if plot_EEG:
|
||||
# lowcut = 0.3
|
||||
# highcut = 40
|
||||
@@ -803,12 +595,6 @@ Vib: {self.dlg.vibrationBox.isChecked()}, Alt: {self.dlg.altEyesBox.isChecked()}
|
||||
# self.triggerLightClicked()
|
||||
|
||||
def scoreSleepCheckBoxChanged(self):
|
||||
"""
|
||||
Autoscoring checkbox
|
||||
|
||||
:param self: access the attributes and methods of the class.
|
||||
|
||||
"""
|
||||
if self.dlg.scoreSleepCheckBox.isChecked():
|
||||
self.dlg.scoreSleepCheckBox.setText("Real-time Autoscoring with:")
|
||||
|
||||
@@ -816,14 +602,6 @@ Vib: {self.dlg.vibrationBox.isChecked()}, Alt: {self.dlg.altEyesBox.isChecked()}
|
||||
self.dlg.scoreSleepCheckBox.setText("No Real-time Autoscoring")
|
||||
|
||||
def eegRangeY_SpinBox_valueChanged(self, val):
|
||||
|
||||
"""
|
||||
Chanigng the amplitude scale of the real-time EEG representation.
|
||||
|
||||
:param self: access the attributes and methods of the class.
|
||||
:param val: zero-to-peak amplitude
|
||||
|
||||
"""
|
||||
# to change range automatically with change of spin box
|
||||
print(int(val))
|
||||
if int(val)%5 == 0:
|
||||
@@ -832,19 +610,10 @@ Vib: {self.dlg.vibrationBox.isChecked()}, Alt: {self.dlg.altEyesBox.isChecked()}
|
||||
self.dlg.graphWidget.setYRange(-Y_rng, Y_rng, padding=0)
|
||||
|
||||
def eegRangeX_SpinBox_valueChanged(self, val):
|
||||
|
||||
"""
|
||||
Chanigng the time scale of the real-time EEG representation. To apply this,
|
||||
after setting the scale, the button should be clicked.
|
||||
|
||||
:param self: access the attributes and methods of the class.
|
||||
:param val: zero-to-peak amplitude
|
||||
|
||||
"""
|
||||
# to change range automatically with change of spin box
|
||||
if int(val) % 5 == 0:
|
||||
sec = int(np.floor(self.displayedXrangeCounter / 256))
|
||||
k = int(np.floor(sec / val))
|
||||
k = int(np.floor(sec / self.desiredXrange))
|
||||
xMin = val * k
|
||||
xMax = val * (k + 1)
|
||||
a_X = self.dlg.graphWidget.getAxis('bottom')
|
||||
@@ -852,38 +621,11 @@ Vib: {self.dlg.vibrationBox.isChecked()}, Alt: {self.dlg.altEyesBox.isChecked()}
|
||||
a_X.setTicks([[(v, str(v)) for v in ticks]])
|
||||
self.dlg.graphWidget.setXRange(xMin, xMax, padding=0)
|
||||
|
||||
|
||||
class RecordThread(QThread):
|
||||
|
||||
"""
|
||||
The thread class of the program which is basically meant for establishing a connection
|
||||
with the mainwindow GUI.
|
||||
"""
|
||||
recordingProgessSignal = pyqtSignal(int) # a sending signal to mainWindow - sends time info of ongoing recording to mainWindow
|
||||
"""
|
||||
pyqtSignal: send recording signal and time info to mainWindow
|
||||
|
||||
|
||||
"""
|
||||
recordingFinishedSignal = pyqtSignal(str)
|
||||
|
||||
"""
|
||||
pyqtSignal: a sending signal to mainWindow - sends name of stored file to mainWindow
|
||||
|
||||
|
||||
"""
|
||||
recordingFinishedSignal = pyqtSignal(str) # a sending signal to mainWindow - sends name of stored file to mainWindow
|
||||
epochPredictionResultSignal = pyqtSignal(int, int)
|
||||
|
||||
"""
|
||||
pyqtSignal:Sleep scoring prediction signal
|
||||
|
||||
|
||||
"""
|
||||
sendEEGdata2MainWindow = pyqtSignal(object, object, bool, bool, bool, bool, int)
|
||||
|
||||
"""
|
||||
pyqtSignal: Sending the relavant data from the thread to the main window.
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(RecordThread, self).__init__(parent)
|
||||
@@ -893,20 +635,10 @@ class RecordThread(QThread):
|
||||
self.stimulationType = ""
|
||||
self.secondCounter = 0
|
||||
self.dataSampleCounter = 0
|
||||
self.totalDataSampleCounter = 0
|
||||
self.epochCounter = 0
|
||||
self.samples_db = []
|
||||
|
||||
def getSignalTypeFromUI(self, sig_type):
|
||||
|
||||
"""
|
||||
To know which signals to record, based on the comboBox in the GUI
|
||||
|
||||
:param self: access the attributes and methods of the class.
|
||||
|
||||
:returns: self.signalType
|
||||
|
||||
"""
|
||||
# to know which signals to record, based on user interface's choice in comboBox
|
||||
if sig_type == "EEGR":
|
||||
self.signalType = [ZmaxDataID.eegr.value]
|
||||
@@ -925,51 +657,16 @@ class RecordThread(QThread):
|
||||
ZmaxDataID.dx.value,ZmaxDataID.dy.value,ZmaxDataID.dz.value]
|
||||
|
||||
def getCurrentSampleInformation(self):
|
||||
|
||||
"""
|
||||
Receive current information regarding the sample numbers
|
||||
|
||||
:param self: access the attributes and methods of the class.
|
||||
|
||||
:returns: self.dataSampleCounter, self.secondCounter, self.totalDataSampleCounter
|
||||
|
||||
"""
|
||||
return [self.dataSampleCounter, self.secondCounter, self.totalDataSampleCounter] # returns time info of stimulation, when called
|
||||
return [self.dataSampleCounter, self.secondCounter] # returns time info of stimulation, when called
|
||||
|
||||
def sendEEGdata2main(self,
|
||||
eegSigR=None, eegSigL=None,
|
||||
plot_EEG=False, plot_periodogram=False, plot_spectrogram=False,
|
||||
score_sleep=False):
|
||||
"""
|
||||
Data transmission from the thread to the mainwindow.
|
||||
|
||||
:param self: access the attributes and methods of the class.
|
||||
:param eegSigR: EEG R
|
||||
:param eegSigL: EEG L
|
||||
:param plot_EEG: enable/disable EEG plotting
|
||||
:param plot_periodogram: plotting/updating periodogram every epoch (30 s)
|
||||
:param plot_spectrogram: plotting/updating spectrogram every epoch (30 s)
|
||||
:param score_sleep: enable/disable sleep scoring
|
||||
|
||||
:returns: self.sendEEGdata2MainWindow.emit(eegSigR, eegSigL, plot_EEG, plot_periodogram, plot_spectrogram,
|
||||
score_sleep, self.epochCounter)
|
||||
|
||||
"""
|
||||
|
||||
self.sendEEGdata2MainWindow.emit(eegSigR, eegSigL, plot_EEG, plot_periodogram, plot_spectrogram,
|
||||
score_sleep, self.epochCounter)
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
"""
|
||||
start recording the signal. in each second, also calculates the sampling rate
|
||||
(# of samples received by program over stream)
|
||||
|
||||
:param self: access the attributes and methods of the class.
|
||||
|
||||
"""
|
||||
|
||||
# This part of the cord RECORDS signal.
|
||||
# In each second, also calculates the sampling rate (# of samples received by program over stream)
|
||||
recording = []
|
||||
@@ -998,10 +695,12 @@ class RecordThread(QThread):
|
||||
sigL_accumulative = []
|
||||
|
||||
while True:
|
||||
if self.epochCounter%60==0 and dataSamplesToAnalyzeCounter == 0:
|
||||
del hb
|
||||
hb = ZmaxHeadband()
|
||||
print("New HB created after 60 epochs")
|
||||
# =============================================================================
|
||||
# if int(self.epochCounter % 60) and dataSamplesToAnalyzeCounter == 0:
|
||||
# del hb
|
||||
# hb = ZmaxHeadband()
|
||||
# print("New HB created after 60 epochs")
|
||||
# =============================================================================
|
||||
|
||||
self.dataSampleCounter = 0 # count samples in each second
|
||||
self.secondCounter += 1
|
||||
@@ -1014,7 +713,6 @@ class RecordThread(QThread):
|
||||
x = hb.read(cols[:-2])
|
||||
if x != []:
|
||||
self.dataSampleCounter += 1
|
||||
self.totalDataSampleCounter += 1
|
||||
|
||||
x.extend([self.dataSampleCounter, self.secondCounter])
|
||||
recording.append(x)
|
||||
@@ -1085,17 +783,9 @@ class RecordThread(QThread):
|
||||
self.recordingFinishedSignal.emit(f"{file_path}\\{dt_string}") # send path of recorded file to mainWindow
|
||||
|
||||
def stop(self):
|
||||
|
||||
"""
|
||||
Stop the recording.
|
||||
|
||||
:param self: access the attributes and methods of the class.
|
||||
|
||||
"""
|
||||
self.threadactive = False
|
||||
self.wait()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QtWidgets.QApplication([])
|
||||
dialog = Window()
|
||||
|
||||
+18
-20
@@ -1,20 +1,18 @@
|
||||
# =============================================================================
|
||||
# import yasa
|
||||
# import sys
|
||||
# import numpy as np
|
||||
# import random
|
||||
# import matplotlib.pyplot as plt
|
||||
# from scipy import signal
|
||||
#
|
||||
#
|
||||
# dataset = np.loadtxt(sample_data, delimiter=',')
|
||||
#
|
||||
# data = dataset[10*256:(10+30)*256,0]
|
||||
# # data = signal.resample(data, int(len(data)/256*100))
|
||||
# # data = data.reshape((data.shape[0],1))
|
||||
#
|
||||
# sls = yasa.SleepStaging_From_NumpyArray(data)
|
||||
# y_pred = sls.predict(path_to_model=".\\clf_eeg_lgb_0.4.0.joblib")
|
||||
# out = sls.get_features()
|
||||
# # times, epochs = yasa.sliding_window(data, sf=100, window=30)
|
||||
# =============================================================================
|
||||
from yasa_imported import yasa
|
||||
import sys
|
||||
import numpy as np
|
||||
import random
|
||||
import matplotlib.pyplot as plt
|
||||
from scipy import signal
|
||||
|
||||
|
||||
dataset = np.loadtxt(".\\Teressa_rec.txt", delimiter=',')
|
||||
|
||||
data = dataset[10*256:(10+30)*256,0]
|
||||
# data = signal.resample(data, int(len(data)/256*100))
|
||||
# data = data.reshape((data.shape[0],1))
|
||||
|
||||
sls = yasa.SleepStaging_From_NumpyArray(data)
|
||||
y_pred = sls.predict(path_to_model=".\\clf_eeg_lgb_0.4.0.joblib")
|
||||
out = sls.get_features()
|
||||
# times, epochs = yasa.sliding_window(data, sf=100, window=30)
|
||||
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
@@ -1,2 +0,0 @@
|
||||
model_checkpoint_path: "best_model.ckpt-7136"
|
||||
all_model_checkpoint_paths: "best_model.ckpt-7136"
|
||||
@@ -1,2 +0,0 @@
|
||||
model_checkpoint_path: "model.ckpt-10310"
|
||||
all_model_checkpoint_paths: "model.ckpt-10310"
|
||||
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
|
Antes Largura: | Altura: | Tamanho: 1.1 MiB |
Arquivo binário não exibido.
@@ -0,0 +1,232 @@
|
||||
2021-07-19 18:40:14 [INFO ] Best model restored from ./out_QS/train/4\best_ckpt\best_model.ckpt-10896
|
||||
2021-07-19 18:40:14 [INFO ] Loading ...
|
||||
2021-07-19 18:40:14 [INFO ] Signal file: C:\Users\mahjaf\Downloads\
|
||||
2021-07-19 18:40:14 [INFO ] Start datetime: 2021-07-17 03:32:42
|
||||
2021-07-19 18:40:14 [INFO ] File duration: 22710 sec
|
||||
2021-07-19 18:40:14 [INFO ] Epoch duration: 30.0 sec (changed from 1 sec)
|
||||
2021-07-19 18:40:15 [INFO ] Selected channel: EEG L - EEG R
|
||||
2021-07-19 18:40:15 [INFO ] Select channel samples: 757 epochs
|
||||
2021-07-19 18:40:15 [INFO ] Sampling rate: 256.0 Hz
|
||||
2021-07-19 18:40:15 [INFO ]
|
||||
=======================================
|
||||
|
||||
2021-07-19 18:40:15 [INFO ] Autoscoring file: Left ...
|
||||
2021-07-19 18:40:15 [INFO ] Test set (n_night_sleeps=1)
|
||||
2021-07-19 18:40:15 [INFO ] (757, 7680, 1, 1)
|
||||
2021-07-19 18:45:08 [INFO ] Best model restored from ./out_QS/train/4\best_ckpt\best_model.ckpt-16140
|
||||
2021-07-19 18:45:08 [INFO ] Loading ...
|
||||
2021-07-19 18:45:08 [INFO ] Signal file: C:/Users/mahjaf/Downloads/
|
||||
2021-07-19 18:45:08 [INFO ] Start datetime: 2021-07-17 03:32:42
|
||||
2021-07-19 18:45:08 [INFO ] File duration: 22710 sec
|
||||
2021-07-19 18:45:08 [INFO ] Epoch duration: 30.0 sec (changed from 1 sec)
|
||||
2021-07-19 18:45:09 [INFO ] Selected channel: EEG L - EEG R
|
||||
2021-07-19 18:45:09 [INFO ] Select channel samples: 757 epochs
|
||||
2021-07-19 18:45:09 [INFO ] Sampling rate: 256.0 Hz
|
||||
2021-07-19 18:45:09 [INFO ]
|
||||
=======================================
|
||||
|
||||
2021-07-19 18:45:09 [INFO ] Autoscoring file: 1 ...
|
||||
2021-07-19 18:45:09 [INFO ] Test set (n_night_sleeps=1)
|
||||
2021-07-19 18:45:09 [INFO ] (757, 7680, 1, 1)
|
||||
2021-07-19 18:45:22 [INFO ] Loading ...
|
||||
2021-07-19 18:45:22 [INFO ] Signal file: C:/Users/mahjaf/Downloads/
|
||||
2021-07-19 18:47:55 [INFO ] Best model restored from ./out_QS/train/4\best_ckpt\best_model.ckpt-16140
|
||||
2021-07-19 18:47:55 [INFO ] Loading ...
|
||||
2021-07-19 18:47:55 [INFO ] Signal file: C:/Users/mahjaf/Downloads/
|
||||
2021-07-19 18:47:55 [INFO ] Start datetime: 2021-07-17 03:32:42
|
||||
2021-07-19 18:47:55 [INFO ] File duration: 22710 sec
|
||||
2021-07-19 18:47:55 [INFO ] Epoch duration: 30.0 sec (changed from 1 sec)
|
||||
2021-07-19 18:47:56 [INFO ] Selected channel: EEG L - EEG R
|
||||
2021-07-19 18:47:56 [INFO ] Select channel samples: 757 epochs
|
||||
2021-07-19 18:47:56 [INFO ] Sampling rate: 256.0 Hz
|
||||
2021-07-19 18:47:56 [INFO ]
|
||||
=======================================
|
||||
|
||||
2021-07-19 18:47:56 [INFO ] Autoscoring file: 1 ...
|
||||
2021-07-19 18:47:56 [INFO ] Test set (n_night_sleeps=1)
|
||||
2021-07-19 18:47:56 [INFO ] (757, 7680, 1, 1)
|
||||
2021-07-29 18:22:16 [INFO ] Best model restored from ./out_QS/train/4\best_ckpt\best_model.ckpt-16140
|
||||
2021-07-29 18:22:16 [INFO ] Loading ...
|
||||
2021-07-29 18:22:16 [INFO ] Signal file: C:/Users/mahjaf/Downloads/
|
||||
2021-07-29 18:22:16 [INFO ] Start datetime: 2021-07-29 14:14:33
|
||||
2021-07-29 18:22:16 [INFO ] File duration: 5530 sec
|
||||
2021-07-29 18:22:16 [INFO ] Epoch duration: 30.0 sec (changed from 1 sec)
|
||||
2021-07-29 18:22:16 [INFO ] Selected channel: EEG L - EEG R
|
||||
2021-07-29 18:22:16 [INFO ] Select channel samples: 184 epochs
|
||||
2021-07-29 18:22:16 [INFO ] Sampling rate: 256.0 Hz
|
||||
2021-07-29 18:22:16 [INFO ]
|
||||
=======================================
|
||||
|
||||
2021-07-29 18:22:16 [INFO ] Autoscoring file: 1 ...
|
||||
2021-07-29 18:22:16 [INFO ] Test set (n_night_sleeps=1)
|
||||
2021-07-29 18:22:16 [INFO ] (184, 7680, 1, 1)
|
||||
2021-08-05 12:37:38 [INFO ] Best model restored from ./out_QS/train/4\best_ckpt\best_model.ckpt-16140
|
||||
2021-08-05 12:37:38 [INFO ] Loading ...
|
||||
2021-08-05 12:37:38 [INFO ] Signal file: C:/Users/mahjaf/Downloads/
|
||||
2021-08-05 12:38:38 [INFO ] Best model restored from ./out_QS/train/4\best_ckpt\best_model.ckpt-16140
|
||||
2021-08-05 12:38:38 [INFO ] Loading ...
|
||||
2021-08-05 12:38:38 [INFO ] Signal file: C:/Users/mahjaf/Downloads/
|
||||
2021-08-05 12:38:38 [INFO ] Start datetime: 2021-08-05 10:43:50
|
||||
2021-08-05 12:38:38 [INFO ] File duration: 6320 sec
|
||||
2021-08-05 12:38:38 [INFO ] Epoch duration: 30.0 sec (changed from 1 sec)
|
||||
2021-08-05 12:38:39 [INFO ] Selected channel: EEG L - EEG R
|
||||
2021-08-05 12:38:39 [INFO ] Select channel samples: 210 epochs
|
||||
2021-08-05 12:38:39 [INFO ] Sampling rate: 256.0 Hz
|
||||
2021-08-05 12:38:39 [INFO ]
|
||||
=======================================
|
||||
|
||||
2021-08-05 12:38:39 [INFO ] Autoscoring file: 1 ...
|
||||
2021-08-05 12:38:39 [INFO ] Test set (n_night_sleeps=1)
|
||||
2021-08-05 12:38:39 [INFO ] (210, 7680, 1, 1)
|
||||
2021-08-05 12:40:48 [INFO ] Best model restored from ./out_QS/train/10\best_ckpt\best_model.ckpt-6601
|
||||
2021-08-05 12:40:48 [INFO ] Loading ...
|
||||
2021-08-05 12:40:48 [INFO ] Signal file: C:/Users/mahjaf/Downloads/
|
||||
2021-08-05 12:40:48 [INFO ] Start datetime: 2021-08-05 10:43:50
|
||||
2021-08-05 12:40:48 [INFO ] File duration: 6320 sec
|
||||
2021-08-05 12:40:48 [INFO ] Epoch duration: 30.0 sec (changed from 1 sec)
|
||||
2021-08-05 12:40:48 [INFO ] Selected channel: EEG L - EEG R
|
||||
2021-08-05 12:40:48 [INFO ] Select channel samples: 210 epochs
|
||||
2021-08-05 12:40:48 [INFO ] Sampling rate: 256.0 Hz
|
||||
2021-08-05 12:40:48 [INFO ]
|
||||
=======================================
|
||||
|
||||
2021-08-05 12:40:48 [INFO ] Autoscoring file: 1 ...
|
||||
2021-08-05 12:40:48 [INFO ] Test set (n_night_sleeps=1)
|
||||
2021-08-05 12:40:48 [INFO ] (210, 7680, 1, 1)
|
||||
2021-08-09 13:15:34 [INFO ] Best model restored from ./out_QS/train/4\best_ckpt\best_model.ckpt-16140
|
||||
2021-08-09 13:15:34 [INFO ] Loading ...
|
||||
2021-08-09 13:15:34 [INFO ] Signal file: C:\Users\asus\Desktop\dr. dresler\zmax\code\ZmaxDonders\Testing\recording-date-2021-08-05-time-10-43-53 Pilot 2\
|
||||
2021-08-09 13:15:34 [INFO ] Start datetime: 2021-08-05 10:43:50
|
||||
2021-08-09 13:15:34 [INFO ] File duration: 6320 sec
|
||||
2021-08-09 13:15:34 [INFO ] Epoch duration: 30.0 sec (changed from 1 sec)
|
||||
2021-08-09 13:15:34 [INFO ] Selected channel: EEG L - EEG R
|
||||
2021-08-09 13:15:34 [INFO ] Select channel samples: 210 epochs
|
||||
2021-08-09 13:15:34 [INFO ] Sampling rate: 256 Hz
|
||||
2021-08-09 13:15:34 [INFO ]
|
||||
=======================================
|
||||
|
||||
2021-08-09 13:15:34 [INFO ] Autoscoring file: 1 ...
|
||||
2021-08-09 13:15:34 [INFO ] Test set (n_night_sleeps=1)
|
||||
2021-08-09 13:15:34 [INFO ] (210, 7680, 1, 1)
|
||||
2021-08-09 13:29:20 [INFO ] Best model restored from ./out_QS/train/4\best_ckpt\best_model.ckpt-16140
|
||||
2021-08-09 13:29:20 [INFO ] Loading ...
|
||||
2021-08-09 13:29:20 [INFO ] Signal file: C:\Users\asus\Desktop\dr. dresler\zmax\code\ZmaxDonders\Testing\recording-date-2021-08-05-time-10-43-53 Pilot 2\
|
||||
2021-08-09 13:29:20 [INFO ] Start datetime: 2021-08-05 10:43:50
|
||||
2021-08-09 13:29:20 [INFO ] File duration: 6320 sec
|
||||
2021-08-09 13:29:20 [INFO ] Epoch duration: 30.0 sec (changed from 1 sec)
|
||||
2021-08-09 13:29:20 [INFO ] Selected channel: EEG L - EEG R
|
||||
2021-08-09 13:29:20 [INFO ] Select channel samples: 210 epochs
|
||||
2021-08-09 13:29:20 [INFO ] Sampling rate: 256 Hz
|
||||
2021-08-09 13:29:20 [INFO ]
|
||||
=======================================
|
||||
|
||||
2021-08-09 13:29:20 [INFO ] Autoscoring file: 1 ...
|
||||
2021-08-09 13:29:20 [INFO ] Test set (n_night_sleeps=1)
|
||||
2021-08-09 13:29:20 [INFO ] (210, 7680, 1, 1)
|
||||
2021-08-09 13:30:45 [INFO ] Best model restored from ./out_QS/train/4\best_ckpt\best_model.ckpt-16140
|
||||
2021-08-09 13:30:45 [INFO ] Loading ...
|
||||
2021-08-09 13:30:45 [INFO ] Signal file: C:\Users\asus\Desktop\dr. dresler\zmax\code\ZmaxDonders\Testing\recording-date-2021-08-05-time-10-43-53 Pilot 2\
|
||||
2021-08-09 13:30:45 [INFO ] Start datetime: 2021-08-05 10:43:50
|
||||
2021-08-09 13:30:45 [INFO ] File duration: 6320 sec
|
||||
2021-08-09 13:30:45 [INFO ] Epoch duration: 30.0 sec (changed from 1 sec)
|
||||
2021-08-09 13:30:45 [INFO ] Selected channel: EEG L - EEG R
|
||||
2021-08-09 13:30:45 [INFO ] Select channel samples: 210 epochs
|
||||
2021-08-09 13:30:45 [INFO ] Sampling rate: 256 Hz
|
||||
2021-08-09 13:30:45 [INFO ]
|
||||
=======================================
|
||||
|
||||
2021-08-09 13:30:45 [INFO ] Autoscoring file: 1 ...
|
||||
2021-08-09 13:30:45 [INFO ] Test set (n_night_sleeps=1)
|
||||
2021-08-09 13:30:45 [INFO ] (210, 7680, 1, 1)
|
||||
2021-08-09 13:32:30 [INFO ] Best model restored from ./out_QS/train/4\best_ckpt\best_model.ckpt-16140
|
||||
2021-08-09 13:32:30 [INFO ] Loading ...
|
||||
2021-08-09 13:32:30 [INFO ] Signal file: C:\Users\asus\Desktop\dr. dresler\zmax\code\ZmaxDonders\Testing\recording-date-2021-08-05-time-10-43-53 Pilot 2\
|
||||
2021-08-09 13:32:30 [INFO ] Start datetime: 2021-08-05 10:43:50
|
||||
2021-08-09 13:32:30 [INFO ] File duration: 6320 sec
|
||||
2021-08-09 13:32:30 [INFO ] Epoch duration: 30.0 sec (changed from 1 sec)
|
||||
2021-08-09 13:32:30 [INFO ] Selected channel: EEG L - EEG R
|
||||
2021-08-09 13:32:30 [INFO ] Select channel samples: 210 epochs
|
||||
2021-08-09 13:32:30 [INFO ] Sampling rate: 256 Hz
|
||||
2021-08-09 13:32:30 [INFO ]
|
||||
=======================================
|
||||
|
||||
2021-08-09 13:32:30 [INFO ] Autoscoring file: 1 ...
|
||||
2021-08-09 13:32:30 [INFO ] Test set (n_night_sleeps=1)
|
||||
2021-08-09 13:32:30 [INFO ] (210, 7680, 1, 1)
|
||||
2021-08-09 13:53:26 [INFO ] Best model restored from ./out_QS/train/4\best_ckpt\best_model.ckpt-16140
|
||||
2021-08-09 13:53:26 [INFO ] Loading ...
|
||||
2021-08-09 13:53:26 [INFO ] Signal file: C:\Users\asus\Desktop\dr. dresler\zmax\code\ZmaxDonders\Testing\recording-date-2021-08-05-time-10-43-53 Pilot 2\
|
||||
2021-08-09 13:53:26 [INFO ] Start datetime: 2021-08-05 10:43:50
|
||||
2021-08-09 13:53:26 [INFO ] File duration: 6320 sec
|
||||
2021-08-09 13:53:26 [INFO ] Epoch duration: 30.0 sec (changed from 1 sec)
|
||||
2021-08-09 13:53:26 [INFO ] Selected channel: EEG L - EEG R
|
||||
2021-08-09 13:53:26 [INFO ] Select channel samples: 210 epochs
|
||||
2021-08-09 13:53:26 [INFO ] Sampling rate: 256 Hz
|
||||
2021-08-09 13:53:26 [INFO ]
|
||||
=======================================
|
||||
|
||||
2021-08-09 13:53:26 [INFO ] Autoscoring file: 1 ...
|
||||
2021-08-09 13:53:26 [INFO ] Test set (n_night_sleeps=1)
|
||||
2021-08-09 13:53:26 [INFO ] (210, 7680, 1, 1)
|
||||
2021-08-09 13:55:07 [INFO ] Best model restored from ./out_QS/train/4\best_ckpt\best_model.ckpt-16140
|
||||
2021-08-09 13:55:07 [INFO ] Loading ...
|
||||
2021-08-09 13:55:07 [INFO ] Signal file: C:\Users\asus\Desktop\dr. dresler\zmax\code\ZmaxDonders\Testing\recording-date-2021-08-05-time-10-43-53 Pilot 2\
|
||||
2021-08-09 13:55:07 [INFO ] Start datetime: 2021-08-05 10:43:50
|
||||
2021-08-09 13:55:07 [INFO ] File duration: 6320 sec
|
||||
2021-08-09 13:55:07 [INFO ] Epoch duration: 30.0 sec (changed from 1 sec)
|
||||
2021-08-09 13:55:07 [INFO ] Selected channel: EEG L - EEG R
|
||||
2021-08-09 13:55:07 [INFO ] Select channel samples: 210 epochs
|
||||
2021-08-09 13:55:07 [INFO ] Sampling rate: 256 Hz
|
||||
2021-08-09 13:55:07 [INFO ]
|
||||
=======================================
|
||||
|
||||
2021-08-09 13:55:07 [INFO ] Autoscoring file: 1 ...
|
||||
2021-08-09 13:55:07 [INFO ] Test set (n_night_sleeps=1)
|
||||
2021-08-09 13:55:07 [INFO ] (210, 7680, 1, 1)
|
||||
2021-08-09 14:02:37 [INFO ] Loading new array for prediciton...
|
||||
2021-08-09 14:02:37 [INFO ]
|
||||
=======================================
|
||||
|
||||
2021-08-09 14:02:37 [INFO ] Initializing the model ...
|
||||
2021-08-09 14:02:45 [INFO ] Loading new array for prediciton...
|
||||
2021-08-09 14:02:45 [INFO ]
|
||||
=======================================
|
||||
|
||||
2021-08-09 14:02:45 [INFO ] Initializing the model ...
|
||||
2021-08-11 11:11:32 [INFO ] Best model restored from ./out_QS/train/4\best_ckpt\best_model.ckpt-16140
|
||||
2021-08-11 11:11:58 [INFO ] Loading ...
|
||||
2021-08-11 11:11:58 [INFO ] Signal file: C:\Users\asus\Desktop\dr. dresler\zmax\code\ZmaxDonders\Testing\recording-date-2021-08-05-time-10-43-53 Pilot 2\
|
||||
2021-08-11 11:11:58 [INFO ] Start datetime: 2021-08-05 10:43:50
|
||||
2021-08-11 11:11:58 [INFO ] File duration: 6320 sec
|
||||
2021-08-11 11:11:58 [INFO ] Epoch duration: 30.0 sec (changed from 1 sec)
|
||||
2021-08-11 12:45:06 [INFO ] Best model restored from ./out_QS/train/4\best_ckpt\best_model.ckpt-16140
|
||||
2021-08-11 12:45:44 [INFO ] Best model restored from ./out_QS/train/4\best_ckpt\best_model.ckpt-16140
|
||||
2021-08-11 12:45:44 [INFO ] Loading ...
|
||||
2021-08-11 12:45:44 [INFO ] Signal file: C:\Users\asus\Desktop\dr. dresler\zmax\code\ZmaxDonders\Testing\recording-date-2021-08-05-time-10-43-53 Pilot 2\
|
||||
2021-08-11 12:45:44 [INFO ] Start datetime: 2021-08-05 10:43:50
|
||||
2021-08-11 12:45:44 [INFO ] File duration: 6320 sec
|
||||
2021-08-11 12:45:44 [INFO ] Epoch duration: 30.0 sec (changed from 1 sec)
|
||||
2021-08-11 12:45:44 [INFO ] Selected channel: EEG L - EEG R
|
||||
2021-08-11 12:45:44 [INFO ] Select channel samples: 210 epochs
|
||||
2021-08-11 12:45:44 [INFO ] Sampling rate: 256 Hz
|
||||
2021-08-11 12:45:44 [INFO ]
|
||||
=======================================
|
||||
|
||||
2021-08-11 12:45:44 [INFO ] Autoscoring file: 1 ...
|
||||
2021-08-11 12:45:44 [INFO ] Test set (n_night_sleeps=1)
|
||||
2021-08-11 12:45:44 [INFO ] (210, 7680, 1, 1)
|
||||
2021-08-11 12:47:18 [INFO ] Best model restored from ./out_QS/train/4\best_ckpt\best_model.ckpt-16140
|
||||
2021-08-11 12:47:18 [INFO ] Loading ...
|
||||
2021-08-11 12:47:18 [INFO ] Signal file: C:\Users\asus\Desktop\dr. dresler\zmax\code\ZmaxDonders\Testing\recording-date-2021-08-05-time-10-43-53 Pilot 2\
|
||||
2021-08-11 12:47:18 [INFO ] Start datetime: 2021-08-05 10:43:50
|
||||
2021-08-11 12:47:18 [INFO ] File duration: 6320 sec
|
||||
2021-08-11 12:47:18 [INFO ] Epoch duration: 30.0 sec (changed from 1 sec)
|
||||
2021-08-11 12:47:18 [INFO ] Selected channel: EEG L - EEG R
|
||||
2021-08-11 12:47:18 [INFO ] Select channel samples: 210 epochs
|
||||
2021-08-11 12:47:18 [INFO ] Sampling rate: 256 Hz
|
||||
2021-08-11 12:47:18 [INFO ]
|
||||
=======================================
|
||||
|
||||
2021-08-11 12:47:18 [INFO ] Autoscoring file: 1 ...
|
||||
2021-08-11 12:47:18 [INFO ] Test set (n_night_sleeps=1)
|
||||
2021-08-11 12:47:18 [INFO ] (210, 7680, 1, 1)
|
||||
|
Antes Largura: | Altura: | Tamanho: 1.1 MiB Depois Largura: | Altura: | Tamanho: 1.1 MiB |
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
@@ -1,2 +0,0 @@
|
||||
model_checkpoint_path: "best_model.ckpt-16140"
|
||||
all_model_checkpoint_paths: "best_model.ckpt-16140"
|
||||
@@ -1,2 +0,0 @@
|
||||
model_checkpoint_path: "model.ckpt-17450"
|
||||
all_model_checkpoint_paths: "model.ckpt-17450"
|
||||
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
|
Antes Largura: | Altura: | Tamanho: 1.1 MiB |
Arquivo binário não exibido.
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+6
-29
@@ -7,18 +7,6 @@ from yasa.spectral import bandpower as yas_bandpower # for periodogram label
|
||||
|
||||
# %% Plot Power spectral density
|
||||
def calculatePowerSpectralDensity(sig, fs, noverlap, NFFT=2 ** 11, scale_by_freq=True):
|
||||
"""
|
||||
Calculate power spectral density
|
||||
|
||||
:param sig: Signal
|
||||
:param fs: Sampling frequency
|
||||
:param noverlap: Overlap
|
||||
:param NFFT: Number of FFT points
|
||||
:param scale_by_freq: Scale by frequency
|
||||
|
||||
:returns: psd_sig, f_psd_sig, Pow_Delta_ratio, Pow_Theta_ratio, Pow_Alpha_ratio, Pow_Beta_ratio, Pow_Sigma_ratio
|
||||
|
||||
"""
|
||||
|
||||
# Compute power spectrums
|
||||
try:
|
||||
@@ -72,18 +60,6 @@ def plotPowerSpectralDensity(figure=None, axis=None, sig=None,
|
||||
lowcut=.3,
|
||||
highcut=30,
|
||||
):
|
||||
"""
|
||||
Plot power spectral density
|
||||
|
||||
:param fig: figure
|
||||
:param axis: axis
|
||||
:param sig: Signal
|
||||
:param filtering_status: Apply filtering?
|
||||
:param lowcut: highcut of filtering
|
||||
:param highcut: lowcut frequency of filtering
|
||||
|
||||
|
||||
"""
|
||||
log_power = False
|
||||
ylimit = 'auto' # [-50, 10]
|
||||
label = 'psd'
|
||||
@@ -102,6 +78,7 @@ def plotPowerSpectralDensity(figure=None, axis=None, sig=None,
|
||||
low = lowcut / nyquist_freq
|
||||
high = highcut / nyquist_freq
|
||||
# Req channel
|
||||
print("filtering for periodogram")
|
||||
b, a = ssignal.butter(3, [low, high], btype='band')
|
||||
sig = ssignal.filtfilt(b, a, sig)
|
||||
psd_sig, f_psd_sig, Pow_Delta_ratio, Pow_Theta_ratio, Pow_Alpha_ratio, Pow_Beta_ratio, Pow_Sigma_ratio = \
|
||||
@@ -137,11 +114,11 @@ def plotPowerSpectralDensity(figure=None, axis=None, sig=None,
|
||||
ylabel='Power spectral density (dB/ Hz)')
|
||||
|
||||
# Legend
|
||||
legend = axis.legend([f"Delta: {round(Pow_Delta_ratio * 100, 2)}% \n\
|
||||
Theta: {round(Pow_Theta_ratio * 100, 2)}% \n\
|
||||
Alpha: {round(Pow_Alpha_ratio * 100, 2)}% \n\
|
||||
Beta: {round(Pow_Beta_ratio * 100, 2)}%"], prop={'size': 10}, frameon=False)
|
||||
legend.set_draggable(state=True)
|
||||
# legend = axis.legend([f"Delta: {round(Pow_Delta_ratio * 100, 2)}% \n\
|
||||
# Theta: {round(Pow_Theta_ratio * 100, 2)}% \n\
|
||||
# Alpha: {round(Pow_Alpha_ratio * 100, 2)}% \n\
|
||||
# Beta: {round(Pow_Beta_ratio * 100, 2)}%"], prop={'size': 10}, frameon=False)
|
||||
# legend.set_draggable(state=True)
|
||||
|
||||
# new decision: calculate powers from YASA and show them on the legend
|
||||
ret = yas_bandpower(sig, sf=fs)
|
||||
|
||||
+11
-33
@@ -1,4 +1,5 @@
|
||||
""" - Main model is based on TinySleepNet (Supratak & Guo, 2020)
|
||||
""" - Main model is based on tinysleepnet - revised by Mahdad Jafarzadeh -Feb & Mar 2021
|
||||
|
||||
- This function should be used to directly predict from an Array (useful for, e.g. real-time scoring)
|
||||
|
||||
- Usage:
|
||||
@@ -34,6 +35,7 @@ from minibatching import (iterate_minibatches,
|
||||
iterate_batch_seq_minibatches,
|
||||
iterate_batch_multiple_seq_minibatches)
|
||||
from logger import get_logger
|
||||
# from ssccoorriinngg import ssccoorriinngg # TODO: add plotting if needed
|
||||
|
||||
config = {
|
||||
# Train
|
||||
@@ -73,13 +75,6 @@ config = {
|
||||
}
|
||||
|
||||
def importModel(best_model_dir="./out_QS/train/4"):
|
||||
|
||||
"""
|
||||
Import the trained model to classify the data.
|
||||
|
||||
:param best_model_dir: directory of the best model for classification.
|
||||
|
||||
"""
|
||||
global config
|
||||
# Add dummy class weights
|
||||
config["class_weights"] = np.ones(config["n_classes"], dtype=np.float32)
|
||||
@@ -105,23 +100,6 @@ def Predict_array(output_dir="./DataiBand/output/Fp1-Fp2_filtered",
|
||||
model=None,
|
||||
single_epoch = True
|
||||
):
|
||||
|
||||
"""
|
||||
Predict a data array and classify it to a sleep stage.
|
||||
|
||||
:param output_dir: the output directory
|
||||
:param args_log_file: directory to the log file
|
||||
:param filtering_status: enable/disable filtering
|
||||
:param lowcut: filter lowcut
|
||||
:param highcut: filter highcut
|
||||
:param fs: sampling frequency
|
||||
:param signal_req: Signal 1 (requested channel)
|
||||
:param signal_ref: Signal 2 (reference channel)
|
||||
:param model: model
|
||||
:param single_epoch: number of epochs to classify
|
||||
|
||||
:returns: outcome
|
||||
"""
|
||||
# %% Initializing paths
|
||||
output_dir = output_dir
|
||||
|
||||
@@ -144,9 +122,9 @@ def Predict_array(output_dir="./DataiBand/output/Fp1-Fp2_filtered",
|
||||
os.makedirs(output_dir)
|
||||
|
||||
# %% Create logger
|
||||
# logger = get_logger(args_log_file, level="info")
|
||||
#
|
||||
# logger.info("Loading new array for prediciton...")
|
||||
logger = get_logger(args_log_file, level="info")
|
||||
|
||||
logger.info("Loading new array for prediciton...")
|
||||
|
||||
# Filter properties
|
||||
if filtering_status:
|
||||
@@ -172,12 +150,12 @@ def Predict_array(output_dir="./DataiBand/output/Fp1-Fp2_filtered",
|
||||
# Casting
|
||||
x = x.astype(np.float32)
|
||||
|
||||
# logger.info("\n=======================================\n")
|
||||
logger.info("\n=======================================\n")
|
||||
|
||||
# %% Prediction section
|
||||
|
||||
# Initializing the model
|
||||
# logger.info("Initializing the model ...")
|
||||
logger.info("Initializing the model ...")
|
||||
|
||||
# Init preds and trues per subject
|
||||
s_preds = []
|
||||
@@ -191,8 +169,8 @@ def Predict_array(output_dir="./DataiBand/output/Fp1-Fp2_filtered",
|
||||
test_y.append(y)
|
||||
|
||||
# Print test set
|
||||
# logger.info("Shape: ")
|
||||
# for _x in test_x: logger.info(_x.shape)
|
||||
logger.info("Shape: ")
|
||||
for _x in test_x: logger.info(_x.shape)
|
||||
|
||||
if config["model"] == "model-origin":
|
||||
|
||||
@@ -223,7 +201,7 @@ def Predict_array(output_dir="./DataiBand/output/Fp1-Fp2_filtered",
|
||||
"pred_{}.npz".format(fname)
|
||||
)
|
||||
np.savez(save_path, **save_dict)
|
||||
# logger.info("Saved outputs to {}".format(save_path))
|
||||
logger.info("Saved outputs to {}".format(save_path))
|
||||
else:
|
||||
for night_idx, night_data in enumerate(zip(test_x, test_y)):
|
||||
# Create minibatches for testing
|
||||
|
||||
Arquivo binário não exibido.
Referência em uma Nova Issue
Bloquear um usuário