preparation for 1.5.1
This commit is contained in:
@@ -239,6 +239,55 @@ class FullClickComboBox(QComboBox):
|
||||
return super().eventFilter(obj, event)
|
||||
|
||||
|
||||
|
||||
from PySide6.QtWidgets import QWidget, QHBoxLayout, QLineEdit, QPushButton, QFileDialog
|
||||
from PySide6.QtCore import Signal
|
||||
|
||||
class FilePickerWidget(QWidget):
|
||||
# This custom signal lets our container mimic a standard QLineEdit
|
||||
textChanged = Signal(str)
|
||||
|
||||
def __init__(self, default_val="", file_filter="JSON Files (*.json);;All Files (*)", parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
# Inline layout to hold line edit and button side-by-side
|
||||
layout = QHBoxLayout(self)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.setSpacing(5)
|
||||
|
||||
self.line_edit = QLineEdit()
|
||||
self.line_edit.setText(str(default_val))
|
||||
self.line_edit.setPlaceholderText("Select file path...")
|
||||
# Forward internal text updates out through our custom component signal
|
||||
self.line_edit.textChanged.connect(self.textChanged.emit)
|
||||
|
||||
self.browse_btn = QPushButton("Browse...")
|
||||
self.browse_btn.clicked.connect(self.open_file_dialog)
|
||||
|
||||
layout.addWidget(self.line_edit)
|
||||
layout.addWidget(self.browse_btn)
|
||||
|
||||
self.file_filter = file_filter
|
||||
|
||||
def open_file_dialog(self):
|
||||
# Open PySide6 native file browser
|
||||
file_path, _ = QFileDialog.getOpenFileName(
|
||||
self,
|
||||
"Select Configuration File",
|
||||
self.line_edit.text(),
|
||||
self.file_filter
|
||||
)
|
||||
if file_path:
|
||||
self.line_edit.setText(file_path)
|
||||
|
||||
# Mimic standard text getter/setter behaviors so parent systems remain unbothered
|
||||
def text(self):
|
||||
return self.line_edit.text()
|
||||
|
||||
def setText(self, text):
|
||||
self.line_edit.setText(text)
|
||||
|
||||
|
||||
class ParamSection(QWidget):
|
||||
"""
|
||||
A widget section that dynamically creates labeled input fields from parameter metadata.
|
||||
@@ -339,9 +388,15 @@ class ParamSection(QWidget):
|
||||
else:
|
||||
widget.setValue(15) # Default fallback
|
||||
widget.valueChanged.connect(lambda val, p=param["name"]: self.check_if_changed(p, val))
|
||||
elif param["type"] == "json_file":
|
||||
# Create our custom dual-element compound layout widget
|
||||
widget = FilePickerWidget(default_val=default_val, file_filter="JSON Files (*.json)")
|
||||
# Your existing tracking signals connect seamlessly!
|
||||
widget.textChanged.connect(lambda val, p=param["name"]: self.check_if_changed(p, val))
|
||||
else:
|
||||
widget = QLineEdit()
|
||||
widget.setText(str(default_val))
|
||||
widget.textChanged.connect(lambda val, p=param["name"]: self.check_if_changed(p, val))
|
||||
|
||||
if "depends_on" in param:
|
||||
self.dependencies.append({
|
||||
@@ -567,6 +622,8 @@ class ParamSection(QWidget):
|
||||
values[name] = range(widget.value())
|
||||
else:
|
||||
values[name] = range(15) # Fallback
|
||||
elif expected_type == "json_file":
|
||||
values[name] = widget.text()
|
||||
else:
|
||||
raw_text = widget.text()
|
||||
try:
|
||||
@@ -1236,7 +1293,7 @@ class CrossGroupUIMixin:
|
||||
|
||||
return file_paths
|
||||
|
||||
def get_common_request_data(self, parameterized_indexes):
|
||||
def get_common_request_data(self, parameterized_indexes, json_location=None, contrast_dfs=None):
|
||||
selected_event = self.event_dropdown.currentText()
|
||||
if selected_event == "<None Selected>":
|
||||
selected_event = None
|
||||
@@ -1274,6 +1331,65 @@ class CrossGroupUIMixin:
|
||||
if idx in parameterized_indexes
|
||||
}
|
||||
|
||||
dynamic_rois = []
|
||||
|
||||
# 1. Check for the JSON file and parse ROI names
|
||||
if os.path.exists(json_location):
|
||||
try:
|
||||
with open(json_location, 'r', encoding='utf-8') as f:
|
||||
regions_data = json.load(f)
|
||||
|
||||
# Extract "name" from each region under "regions_of_interest"
|
||||
regions_list = regions_data.get("regions_of_interest", [])
|
||||
dynamic_rois = [region["name"] for region in regions_list if "name" in region]
|
||||
|
||||
except Exception as e:
|
||||
# Safe log if JSON is corrupted or unreadable
|
||||
print(f"Error reading ROI configurations from {json_location}: {e}")
|
||||
|
||||
# Fallback to prevent UI crashes if JSON file doesn't exist or is empty
|
||||
if not dynamic_rois:
|
||||
dynamic_rois = ["Option 1", "Option 2"]
|
||||
|
||||
dynamic_contrasts = []
|
||||
if contrast_dfs:
|
||||
contrast_set = set()
|
||||
for fp in all_selected_paths:
|
||||
# Get the contrasts dictionary associated with this file path
|
||||
file_contrasts = contrast_dfs.get(fp, {})
|
||||
for contrast_name in file_contrasts.keys():
|
||||
# If no event is selected, display all contrasts.
|
||||
# If an event is selected, only keep contrasts containing the event name as a substring.
|
||||
if selected_event is None or selected_event in contrast_name:
|
||||
contrast_set.add(contrast_name)
|
||||
|
||||
# Sort them cleanly for the UI
|
||||
dynamic_contrasts = sorted(list(contrast_set))
|
||||
|
||||
# 2. Loop through the active parameters needing input and intercept 'roi_a' and 'roi_b'
|
||||
for idx, params_list in indexes_needing_params.items():
|
||||
for param_info in params_list:
|
||||
if param_info["key"] == "roi_a":
|
||||
# Inject options list dynamically
|
||||
param_info["options"] = dynamic_rois
|
||||
# Default to the very first item
|
||||
param_info["default"] = dynamic_rois[0] if dynamic_rois else ""
|
||||
|
||||
elif param_info["key"] == "roi_b":
|
||||
# Inject the same options list
|
||||
param_info["options"] = dynamic_rois
|
||||
# Default to the first item not taken (index 1), with safety fallbacks
|
||||
if len(dynamic_rois) > 1:
|
||||
param_info["default"] = dynamic_rois[1]
|
||||
elif len(dynamic_rois) == 1:
|
||||
param_info["default"] = dynamic_rois[0]
|
||||
else:
|
||||
param_info["default"] = ""
|
||||
|
||||
elif param_info["key"] == "contrast_name":
|
||||
param_info["options"] = dynamic_contrasts
|
||||
param_info["default"] = dynamic_contrasts[0] if dynamic_contrasts else ""
|
||||
|
||||
param_values = {}
|
||||
if indexes_needing_params:
|
||||
dialog = ParameterInputDialog(indexes_needing_params, parent=self)
|
||||
|
||||
@@ -43,9 +43,9 @@ PIPELINE_STAGES = [
|
||||
"Design Matrix",
|
||||
"General Linear Model",
|
||||
"Generate GLM Results",
|
||||
"Generate Channel Significance",
|
||||
"Generate Channel, Region of Interest, and Contrast Results",
|
||||
"Compute Contrast Results",
|
||||
"Generate Channel Results",
|
||||
"Generate Region of Interest Results",
|
||||
"Generate Contrast Results",
|
||||
"Finishing Up"
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user