updates for next version

This commit is contained in:
2025-08-19 13:57:14 -07:00
parent 6b50e7f9f5
commit 65e33c8619
3 changed files with 173 additions and 26 deletions

122
main.py
View File

@@ -27,7 +27,7 @@ import psutil
import requests
from PySide6.QtWidgets import (
QApplication, QWidget, QMessageBox, QVBoxLayout, QHBoxLayout, QTextEdit, QScrollArea, QComboBox, QGridLayout,
QPushButton, QMainWindow, QFileDialog, QLabel, QLineEdit, QFrame, QSizePolicy
QPushButton, QMainWindow, QFileDialog, QLabel, QLineEdit, QFrame, QSizePolicy, QGroupBox
)
from PySide6.QtCore import QThread, Signal, Qt, QTimer
from PySide6.QtGui import QAction, QKeySequence, QIcon, QIntValidator, QDoubleValidator
@@ -114,7 +114,7 @@ SECTIONS = [
{
"title": "Haemoglobin Concentration",
"params": [
{"name": "PPF", "default": 0.1, "type": float, "help": "Partial Pathlength Factor."},
# Intentionally empty (TODO)
]
},
{
@@ -128,7 +128,7 @@ SECTIONS = [
{
"title": "General Linear Model",
"params": [
{"name": "N_JOBS", "default": 1, "type": int, "help": "Number of jobs for processing."},
{"name": "N_JOBS", "default": 1, "type": int, "help": "Number of jobs for GLM processing."},
]
},
{
@@ -137,6 +137,12 @@ SECTIONS = [
# Intentionally empty (TODO)
]
},
{
"title": "Other",
"params": [
{"name": "MAX_WORKERS", "default": 4, "type": int, "help": "Number of files to process at once."},
]
},
]
@@ -403,7 +409,7 @@ class ProgressBubble(QWidget):
self.setLayout(self.layout)
# Store the file path
self.file_path = file_path
self.file_path = os.path.normpath(file_path)
self.current_step = 0
# Make the bubble clickable
@@ -619,6 +625,10 @@ class MainApplication(QMainWindow):
self.platform_suffix = "-" + PLATFORM_NAME
self.pending_update_version = None
self.pending_update_path = None
self.file_metadata = {}
self.current_file = None
# Start local pending update check thread
self.local_check_thread = LocalPendingUpdateCheckThread(CURRENT_VERSION, self.platform_suffix)
@@ -642,11 +652,51 @@ class MainApplication(QMainWindow):
left_container.setLayout(left_layout)
left_container.setMinimumWidth(300)
# Top left widget (for demo, use QTextEdit)
top_left_container = QGroupBox() # Optional: add a title inside parentheses
top_left_container.setTitle("File information") # Optional visible title
top_left_container.setStyleSheet("QGroupBox { font-weight: bold; }") # Style if needed
top_left_container.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
top_left_layout = QHBoxLayout()
top_left_container.setLayout(top_left_layout)
# QTextEdit with fixed height, but only 80% width
self.top_left_widget = QTextEdit()
self.top_left_widget.setReadOnly(True)
self.top_left_widget.setReadOnly(True)
self.top_left_widget.setPlaceholderText("Click a file below to get started! No files below? Open one using File > Open!")
self.top_left_widget.setFixedHeight(250)
# Add QTextEdit to the layout with a stretch factor
top_left_layout.addWidget(self.top_left_widget, stretch=4) # 80%
# Create a vertical box layout for the right 20%
self.right_column_widget = QWidget()
right_column_layout = QVBoxLayout()
self.right_column_widget.setLayout(right_column_layout)
self.meta_fields = {
"Age": QLineEdit(),
"Gender": QLineEdit(),
}
# Inside your top-left container's right column layout:
for key, field in self.meta_fields.items():
label = QLabel(key.capitalize())
field.setPlaceholderText(f"Enter {key}")
right_column_layout.addWidget(label)
right_column_layout.addWidget(field)
right_column_layout.addStretch() # Push fields to top
self.right_column_widget.hide()
# Add right column widget to the top-left layout (takes 20% width)
top_left_layout.addWidget(self.right_column_widget, stretch=1)
# Add top_left_container to the main left_layout
left_layout.addWidget(top_left_container)
# Bottom left: the bubbles inside a scroll area
self.bubble_container = QWidget()
@@ -660,7 +710,6 @@ class MainApplication(QMainWindow):
self.scroll_area.setMinimumHeight(300)
# Add top left and bottom left to left layout
left_layout.addWidget(self.top_left_widget)
left_layout.addWidget(self.scroll_area)
self.progress_update_signal.connect(self.update_file_progress)
@@ -713,6 +762,7 @@ class MainApplication(QMainWindow):
self.button2.setMinimumSize(100, 40)
self.button3.setMinimumSize(100, 40)
self.button1.setVisible(False)
self.button3.setVisible(False)
self.button1.clicked.connect(self.on_run_task)
@@ -828,6 +878,8 @@ class MainApplication(QMainWindow):
def clear_all(self):
self.right_column_widget.hide()
# Clear the bubble layout
while self.bubble_layout.count():
item = self.bubble_layout.takeAt(0)
@@ -846,6 +898,7 @@ class MainApplication(QMainWindow):
self.all_figures = None
# Reset any visible UI elements
self.button1.setVisible(False)
self.button3.setVisible(False)
self.top_left_widget.clear()
@@ -889,6 +942,8 @@ class MainApplication(QMainWindow):
if file_path:
self.selected_path = file_path # store the file path
self.show_files_as_bubbles(file_path)
self.button1.setVisible(True)
def open_folder_dialog(self):
folder_path = QFileDialog.getExistingDirectory(
@@ -897,6 +952,8 @@ class MainApplication(QMainWindow):
if folder_path:
self.selected_path = folder_path # store the folder path
self.show_files_as_bubbles(folder_path)
self.button1.setVisible(True)
def open_multiple_folders_dialog(self):
@@ -921,6 +978,8 @@ class MainApplication(QMainWindow):
)
if more == QMessageBox.StandardButton.No:
break
self.button1.setVisible(True)
def save_project(self):
@@ -990,7 +1049,8 @@ class MainApplication(QMainWindow):
self.show_files_as_bubbles_from_list(data["file_list"], data.get("progress_states", {}), filename)
# Re-enable the "Viewer" button
# Re-enable the buttons
self.button1.setVisible(True)
self.button3.setVisible(True)
QMessageBox.information(self, "Loaded", f"Project loaded from:\n{filename}")
@@ -1089,6 +1149,10 @@ class MainApplication(QMainWindow):
def on_bubble_clicked(self, bubble):
# show age / gender
self.right_column_widget.show()
file_path = bubble.file_path
if not os.path.exists(file_path):
self.top_left_widget.setText("File not found.")
@@ -1121,15 +1185,51 @@ class MainApplication(QMainWindow):
# info += f" {k}: {v}\n"
self.top_left_widget.setText(info)
clicked_bubble = self.sender()
file_path = clicked_bubble.file_path
# Save current file's metadata
if self.current_file:
self.save_metadata(self.current_file)
# Update current file
self.current_file = file_path
# Load new file's metadata into the fields
metadata = self.file_metadata.get(file_path, {})
for key, field in self.meta_fields.items():
field.blockSignals(True)
field.setText(metadata.get(key, ""))
field.blockSignals(False)
def placeholder(self):
QMessageBox.information(self, "Placeholder", "This feature is not implemented yet.")
def save_metadata(self, file_path):
if not file_path:
return
self.file_metadata[file_path] = {
key: field.text()
for key, field in self.meta_fields.items()
}
def get_all_metadata(self):
# First, make sure current file's edits are saved
if self.current_file:
self.save_metadata(self.current_file)
return self.file_metadata
'''MODULE FILE'''
def on_run_task(self):
all_metadata = self.get_all_metadata()
for file_path, data in all_metadata.items():
print(f"{file_path}: {data}")
collected_data = {}
@@ -1164,7 +1264,6 @@ class MainApplication(QMainWindow):
collected_data["SNIRF_SUBFOLDERS"] = [Path(p).name for p in self.selected_paths]
collected_data["STIM_DURATION"] = [0 for _ in self.selected_paths]
elif hasattr(self, "selected_path") and self.selected_path:
# Handle single folder
selected_path = Path(self.selected_path)
@@ -1176,10 +1275,9 @@ class MainApplication(QMainWindow):
# No folder selected - handle gracefully or raise error
raise ValueError("No folder(s) selected")
collected_data["METADATA"] = all_metadata
collected_data["HRF_MODEL"] = 'fir'
collected_data["MAX_WORKERS"] = 12
collected_data["FORCE_DROP_CHANNELS"] = []
collected_data["TARGET_ACTIVITY"] = "Reach"