Structure
This commit is contained in:
parent
1480bf60ca
commit
5fcf60921c
24 changed files with 38 additions and 23 deletions
|
@ -5,8 +5,8 @@ Created on Tue Nov 23 11:11:41 2021
|
||||||
|
|
||||||
@author: adamr
|
@author: adamr
|
||||||
"""
|
"""
|
||||||
import NeurOne
|
from connection import NeurOne, RDA
|
||||||
import RDA
|
# import RDA
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import matplotlib
|
import matplotlib
|
||||||
|
@ -21,16 +21,16 @@ import matplotlib.cm as cm
|
||||||
import PyQt5.uic as uic
|
import PyQt5.uic as uic
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import json
|
import json
|
||||||
#import scipy.stats as st
|
import scipy.stats as st
|
||||||
import csv
|
import csv
|
||||||
import datetime
|
import datetime
|
||||||
import ctypes
|
import ctypes
|
||||||
import scipy
|
import scipy
|
||||||
import pywt
|
import pywt
|
||||||
import queue
|
# import queue
|
||||||
|
|
||||||
from cycler import cycler
|
from cycler import cycler
|
||||||
from matplotlib.backend_bases import MouseButton
|
# from matplotlib.backend_bases import MouseButton
|
||||||
from PyQt5.QtCore import QTimer, Qt
|
from PyQt5.QtCore import QTimer, Qt
|
||||||
from PyQt5.QtGui import QImage, QPixmap, QIcon, QFont
|
from PyQt5.QtGui import QImage, QPixmap, QIcon, QFont
|
||||||
from PyQt5.QtWidgets import (QMainWindow, QFileDialog, QMessageBox, QCheckBox, QLineEdit, QWidget, QPushButton,
|
from PyQt5.QtWidgets import (QMainWindow, QFileDialog, QMessageBox, QCheckBox, QLineEdit, QWidget, QPushButton,
|
||||||
|
@ -46,9 +46,9 @@ if sys.platform=='darwin':
|
||||||
#from multiprocessing import Queue as QueueOld #Queue doesn't work on MacOS
|
#from multiprocessing import Queue as QueueOld #Queue doesn't work on MacOS
|
||||||
else:
|
else:
|
||||||
from multiprocessing import Process, Queue, Value
|
from multiprocessing import Process, Queue, Value
|
||||||
from Waiting import Waiting_window
|
from utils.Waiting import Waiting_window
|
||||||
from FirstWindow import First_window
|
from utils.FirstWindow import First_window
|
||||||
from Functions import (apply_montage, eye_reg, most_frequent, connect_sig, set_to_gray, update_stem,
|
from utils.Functions import (apply_montage, eye_reg, most_frequent, connect_sig, set_to_gray, update_stem,
|
||||||
adjust_hist, min_zero, pentropy, entropy, check_integrity, doubleMADsfromMedian)
|
adjust_hist, min_zero, pentropy, entropy, check_integrity, doubleMADsfromMedian)
|
||||||
|
|
||||||
if sys.platform=='darwin':
|
if sys.platform=='darwin':
|
||||||
|
@ -215,7 +215,7 @@ def acquire_data(q, size, run, speed, downsample, sleep_time, ip = '192.168.200.
|
||||||
run: Value class from multiprocessing library. That value can be changed in main process
|
run: Value class from multiprocessing library. That value can be changed in main process
|
||||||
downsample: boolean value. Says if data will be downsampled to 1000 Hz
|
downsample: boolean value. Says if data will be downsampled to 1000 Hz
|
||||||
sleep_time: int, set how often function should refresh. Usually it takes a bit more that that"""
|
sleep_time: int, set how often function should refresh. Usually it takes a bit more that that"""
|
||||||
# offline = 'offline'
|
offline = 'offline'
|
||||||
#import NeurOne_v3
|
#import NeurOne_v3
|
||||||
if offline=="offline":
|
if offline=="offline":
|
||||||
NO = NeurOneOffline()
|
NO = NeurOneOffline()
|
||||||
|
@ -385,7 +385,7 @@ class AppForm(QMainWindow):
|
||||||
|
|
||||||
#montage matrix is a matrix that is multiplied with the signal
|
#montage matrix is a matrix that is multiplied with the signal
|
||||||
#identity matrix multiply all channels by 1, so we have the same signal as an output
|
#identity matrix multiply all channels by 1, so we have the same signal as an output
|
||||||
settings_file = pd.read_csv('TMS_protocol.txt',sep=':', header=None) #read file with settings
|
settings_file = pd.read_csv('settings/TMS_protocol.txt',sep=':', header=None) #read file with settings
|
||||||
print(restarted)
|
print(restarted)
|
||||||
#open the file to save values during the experiment
|
#open the file to save values during the experiment
|
||||||
self.log_file = open('logs//TMS_log_'+str(f"{datetime.datetime.now():%Y-%m-%d-%H-%M}"+restarted+'.csv'), 'w')
|
self.log_file = open('logs//TMS_log_'+str(f"{datetime.datetime.now():%Y-%m-%d-%H-%M}"+restarted+'.csv'), 'w')
|
||||||
|
@ -396,7 +396,7 @@ class AppForm(QMainWindow):
|
||||||
self.size_of_up = 2*self.Fs #5000 how much data we get from NeurOne function
|
self.size_of_up = 2*self.Fs #5000 how much data we get from NeurOne function
|
||||||
|
|
||||||
#file with settings and assigning variables to them
|
#file with settings and assigning variables to them
|
||||||
settings_file = pd.read_csv('TMS_protocol.txt',sep=':', header=None)
|
# settings_file = pd.read_csv('settings/TMS_protocol.txt',sep=':', header=None)
|
||||||
|
|
||||||
#params can be set in GUI, so then no need for using ones from the file
|
#params can be set in GUI, so then no need for using ones from the file
|
||||||
if passed_params is not None:
|
if passed_params is not None:
|
||||||
|
@ -470,7 +470,7 @@ class AppForm(QMainWindow):
|
||||||
print(self.included_ch)
|
print(self.included_ch)
|
||||||
# self.montage_matrix = np.identity(self.num_of_ch)
|
# self.montage_matrix = np.identity(self.num_of_ch)
|
||||||
if self.montage_file_path in [None, '']:
|
if self.montage_file_path in [None, '']:
|
||||||
self.montage_file_path = 'montage_18ch.csv'
|
self.montage_file_path = 'settings/montage_18ch.csv'
|
||||||
self.montage_matrix = np.array(pd.read_csv(self.montage_file_path, header=None))
|
self.montage_matrix = np.array(pd.read_csv(self.montage_file_path, header=None))
|
||||||
|
|
||||||
|
|
||||||
|
@ -743,7 +743,7 @@ class AppForm(QMainWindow):
|
||||||
self.timer.setInterval(int(self.speed_general*1.03))
|
self.timer.setInterval(int(self.speed_general*1.03))
|
||||||
|
|
||||||
times = time.time()
|
times = time.time()
|
||||||
# self.offline='offline' #remove this!
|
self.offline='offline' #remove this!
|
||||||
if self.offline=="offline":
|
if self.offline=="offline":
|
||||||
incl = [0,2,6,7,8,10,13,16,18,22,25,28,31,34,41,43,-3,-2,-1] # For offline only
|
incl = [0,2,6,7,8,10,13,16,18,22,25,28,31,34,41,43,-3,-2,-1] # For offline only
|
||||||
loaded_temp = self.q.get()[incl]/10 # Load data
|
loaded_temp = self.q.get()[incl]/10 # Load data
|
||||||
|
@ -1359,7 +1359,7 @@ class Ui(QMainWindow):
|
||||||
def __init__(self, main_file):
|
def __init__(self, main_file):
|
||||||
self.main_file = main_file
|
self.main_file = main_file
|
||||||
super(Ui, self).__init__()
|
super(Ui, self).__init__()
|
||||||
uic.loadUi('soft2.ui', self)
|
uic.loadUi('settings/soft2.ui', self)
|
||||||
self.show()
|
self.show()
|
||||||
self.load_button = self.findChild(QPushButton, 'pushButton')
|
self.load_button = self.findChild(QPushButton, 'pushButton')
|
||||||
self.load_button.clicked.connect(self.get_file)
|
self.load_button.clicked.connect(self.get_file)
|
|
@ -1,2 +0,0 @@
|
||||||
full_cap_file_path: /home/adamr/Documents/PYTHON/TMS TV/EStiMo/easycap-M10_63_NO.txt
|
|
||||||
cap_file_path: /home/adamr/Documents/PYTHON/TMS TV/EStiMo/easycap-M10_16_NO.txt
|
|
0
connection/__init__.py
Normal file
0
connection/__init__.py
Normal file
BIN
connection/__pycache__/NeurOne.cpython-38.pyc
Normal file
BIN
connection/__pycache__/NeurOne.cpython-38.pyc
Normal file
Binary file not shown.
BIN
connection/__pycache__/RDA.cpython-38.pyc
Normal file
BIN
connection/__pycache__/RDA.cpython-38.pyc
Normal file
Binary file not shown.
BIN
connection/__pycache__/__init__.cpython-38.pyc
Normal file
BIN
connection/__pycache__/__init__.cpython-38.pyc
Normal file
Binary file not shown.
12
requirements.txt
Normal file
12
requirements.txt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
matplotlib==3.6.2
|
||||||
|
mne==1.3.1
|
||||||
|
numpy==1.23.5
|
||||||
|
scipy==1.7.3
|
||||||
|
pandas==2.0.0
|
||||||
|
json==2.0.9
|
||||||
|
csv
|
||||||
|
datetime
|
||||||
|
ctypes==1.1.0
|
||||||
|
pywt==1.4.1
|
||||||
|
cycler==0.10.0
|
||||||
|
PyQt5
|
2
settings/Electrode_selection.txt
Normal file
2
settings/Electrode_selection.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
full_cap_file_path: /home/adamr/Documents/PYTHON/TMS TV/EStiMo/settings/easycap-M10_63_NO.txt
|
||||||
|
cap_file_path: /home/adamr/Documents/PYTHON/TMS TV/EStiMo/settings/easycap-M10_16_NO.txt
|
|
@ -6,6 +6,7 @@ Created on Mon Jan 24 11:26:23 2022
|
||||||
"""
|
"""
|
||||||
import mne
|
import mne
|
||||||
import os, sys, traceback, time
|
import os, sys, traceback, time
|
||||||
|
|
||||||
from PyQt5.QtWidgets import (QMainWindow, QFileDialog, QMessageBox, QCheckBox, QLineEdit, QWidget, QPushButton,
|
from PyQt5.QtWidgets import (QMainWindow, QFileDialog, QMessageBox, QCheckBox, QLineEdit, QWidget, QPushButton,
|
||||||
QLabel, QHBoxLayout, QGridLayout, QAction, QApplication, QDialog, QDialogButtonBox,
|
QLabel, QHBoxLayout, QGridLayout, QAction, QApplication, QDialog, QDialogButtonBox,
|
||||||
QVBoxLayout, QFrame, QTabWidget, QComboBox, QScrollArea, QFormLayout)
|
QVBoxLayout, QFrame, QTabWidget, QComboBox, QScrollArea, QFormLayout)
|
||||||
|
@ -21,14 +22,13 @@ if sys.platform=='darwin':
|
||||||
#from multiprocessing import Queue as StupidNotWorkingQueue
|
#from multiprocessing import Queue as StupidNotWorkingQueue
|
||||||
else:
|
else:
|
||||||
from multiprocessing import Process, Queue, Value
|
from multiprocessing import Process, Queue, Value
|
||||||
import NeurOne
|
from connection import NeurOne, RDA
|
||||||
import RDA
|
|
||||||
import ctypes
|
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from mne.channels.layout import _find_topomap_coords as get_pos
|
from mne.channels.layout import _find_topomap_coords as get_pos
|
||||||
import json
|
import json
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import ctypes
|
||||||
|
|
||||||
if sys.platform=='darwin':
|
if sys.platform=='darwin':
|
||||||
from multiprocessing.queues import Queue as QueueOld
|
from multiprocessing.queues import Queue as QueueOld
|
||||||
|
@ -225,15 +225,15 @@ class First_window(QMainWindow):
|
||||||
self.setWindowTitle('EStiMo Configuration')
|
self.setWindowTitle('EStiMo Configuration')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cap_loc_file = pd.read_csv('Electrode_selection.txt', sep=':', header=None)
|
cap_loc_file = pd.read_csv('settings/Electrode_selection.txt', sep=':', header=None)
|
||||||
self.cap_file_path = cap_loc_file[cap_loc_file[0]=='cap_file_path'].values[0][1].strip()
|
self.cap_file_path = cap_loc_file[cap_loc_file[0]=='cap_file_path'].values[0][1].strip()
|
||||||
self.full_cap_file_path = cap_loc_file[cap_loc_file[0]=='full_cap_file_path'].values[0][1].strip() #'easycap-M10_63_NO.txt'
|
self.full_cap_file_path = cap_loc_file[cap_loc_file[0]=='full_cap_file_path'].values[0][1].strip() #'easycap-M10_63_NO.txt'
|
||||||
except:
|
except:
|
||||||
print("CAP FILE EXCEPTION")
|
print("CAP FILE EXCEPTION")
|
||||||
self.cap_file_path = 'easycap-M10_16_NO.txt'
|
self.cap_file_path = 'settings/easycap-M10_16_NO.txt'
|
||||||
self.full_cap_file_path = 'easycap-M10_63_NO.txt'
|
self.full_cap_file_path = 'settings/easycap-M10_63_NO.txt'
|
||||||
|
|
||||||
self.conf_path = 'TMS_protocol.txt'
|
self.conf_path = 'settings/TMS_protocol.txt'
|
||||||
montage = mne.channels.read_custom_montage(self.cap_file_path)
|
montage = mne.channels.read_custom_montage(self.cap_file_path)
|
||||||
montage_file = pd.read_csv(self.cap_file_path, sep='\t')
|
montage_file = pd.read_csv(self.cap_file_path, sep='\t')
|
||||||
|
|
3
utils/__init__.py
Normal file
3
utils/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import sys, os
|
||||||
|
# sys.path.append("..")
|
||||||
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
BIN
utils/__pycache__/FirstWindow.cpython-38.pyc
Normal file
BIN
utils/__pycache__/FirstWindow.cpython-38.pyc
Normal file
Binary file not shown.
BIN
utils/__pycache__/Functions.cpython-38.pyc
Normal file
BIN
utils/__pycache__/Functions.cpython-38.pyc
Normal file
Binary file not shown.
BIN
utils/__pycache__/Waiting.cpython-38.pyc
Normal file
BIN
utils/__pycache__/Waiting.cpython-38.pyc
Normal file
Binary file not shown.
BIN
utils/__pycache__/__init__.cpython-38.pyc
Normal file
BIN
utils/__pycache__/__init__.cpython-38.pyc
Normal file
Binary file not shown.
Loading…
Reference in a new issue