Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .idea/Loop System.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions loop_system/Baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,26 @@

warnings.filterwarnings("ignore")


def select_file(title, filetypes):
root = tk.Tk()
root.withdraw() # hide the main Tkinter window

file_path = filedialog.askopenfilename(title=title, filetypes=filetypes)
file_path = filedialog.askopenfilename(
title=title,
filetypes=filetypes
)

if not file_path:
print("No file selected. Exiting...")
sys.exit(1)

return file_path


def main():
start_time = time.time()

# Prompt user to select the XDF file
file_path = select_file("Select the Baseline data file", [("XDF files", "*.xdf")])
file_path = select_file("Select the Baseline data file",[("XDF files", "*.xdf")])

# Extract folder and condition name from the file path
folder = os.path.dirname(file_path)
Expand Down Expand Up @@ -70,6 +71,5 @@ def main():
except Exception as e:
print(f"An error occurred saving the Baseline Dataframe: {e}")


if __name__ == "__main__":
main()
20 changes: 8 additions & 12 deletions loop_system/Manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ def run(self):
modelTrainer = ModelTrainer()

"""Load and Select Baseline Data file"""
baseline_file = select_file(
"Select the Baseline data file.", [("CSV files", "*.csv")]
)
baseline_file = select_file("Select the Baseline data file.", [("CSV files", "*.csv")])

if not baseline_file:
print("No baseline file selected. Exiting...")
Expand All @@ -78,9 +76,7 @@ def run(self):

"""Load and Select Training Data file"""

training_data = select_file(
"Select the training data file.", [("CSV files", "*.csv")]
)
training_data = select_file("Select the training data file.", [("CSV files", "*.csv")])

if not training_data:
print("No training data file selected. Exiting...")
Expand Down Expand Up @@ -118,9 +114,7 @@ def run(self):
os.makedirs(log_folder, exist_ok=True) # Ensure directory exists
log_file_path = os.path.join(log_folder, "output.txt")

print(
"Logging output to {log_file_path}...".format(log_file_path=log_file_path)
)
print("Logging output to {log_file_path}...".format(log_file_path=log_file_path))

log_file = open(log_file_path, "w")
sys.stdout = TeeLogger(log_file)
Expand Down Expand Up @@ -245,8 +239,11 @@ def run(self):
pass
finally:
try:
model_path = os.path.join(base_dir, f"model_v{self.model_version}.pkl")
joblib.dump(self.model, model_path)
model_path = os.path.join(base_dir, f"model_v{self.model_version}.pkl" )
joblib.dump(
self.model,
model_path
)
print(f"Model saved successfully to {model_path}")
except Exception as e:
print(f"Error saving the model: {e}")
Expand All @@ -265,7 +262,6 @@ def run(self):
data_sender.join()
print("Closed all processes.")


if __name__ == "__main__":
multiprocessing.freeze_support()
manager = Manager()
Expand Down
8 changes: 3 additions & 5 deletions loop_system/Training_Model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

warnings.filterwarnings("ignore")


def main():

start_time = time.time()
Expand All @@ -20,9 +19,7 @@ def main():

"""Load Baseline Data file"""

baseline_file = select_file(
"Select the Baseline data file", [("CSV files", "*.csv")]
)
baseline_file = select_file("Select the Baseline data file", [("CSV files", "*.csv")])

"""Baseline Dataframe"""
try:
Expand Down Expand Up @@ -61,6 +58,7 @@ def main():
print(f"An error occurred loading the N-Back data: {e}")
sys.exit(1)


"""Signals Processing"""
signals = getSignals(
data, "OpenSignals", "PsychoPy Markers", "PsychoPy Ratings", sensors=sensors
Expand Down Expand Up @@ -106,6 +104,7 @@ def main():
print("Performing GridSearchCV to find the best models...")
best_models = gridSearchCV(X, Y)


print("GridSearch completed.")
# Sort the models by their best score in descending order
sorted_models = sorted(
Expand Down Expand Up @@ -138,6 +137,5 @@ def main():

print(f"Elapsed time = {(time.time()-start_time)/60:.2f} minutes")


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion physiological_data/Epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def getMarkers(marker, timestamps):
category, onset, offset = list(), list(), list()

for timestamp, markers in zip(timestamps, marker):
if markers[1] == "1":
if markers[1] == '1':
offset.append(timestamp)
elif markers[0] == "end":
offset.append(timestamp)
Expand Down
8 changes: 2 additions & 6 deletions physiological_data/Load.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ def Load_Ratings(data, stream_name: str):
else:
arousal.append("High")

ratings = {
"Valence": valence,
"Arousal": arousal,
"Valence Timestamps": valence_timestamps,
"Arousal Timestamps": arousal_timestamps,
}
ratings = {"Valence": valence, "Arousal": arousal, "Valence Timestamps": valence_timestamps,
"Arousal Timestamps": arousal_timestamps}

return ratings

Expand Down
Loading
Loading