mainly whitespace, but also some generic qol improvements
This commit is contained in:
1 parent
2a5e3f5606
commit
3a8ffbdf70
26 files changed
+1871
-1224
No files matched your search
+32
-32
@@ -102,7 +102,7 @@ def _align_boris_and_write_snirf_worker(
|
||||
for raw_event in boris_events:
|
||||
if not isinstance(raw_event, (list, tuple)):
|
||||
continue
|
||||
|
||||
|
||||
event = cast(Sequence[Any], raw_event)
|
||||
|
||||
if len(event) < 3:
|
||||
@@ -179,7 +179,7 @@ def align_boris_and_write_snirf_isolated(
|
||||
time_shift
|
||||
)
|
||||
return future.result()
|
||||
|
||||
|
||||
|
||||
class EventUpdateMode(Enum):
|
||||
WRITE_SNIRF = auto() # destructive
|
||||
@@ -217,7 +217,7 @@ class UpdateEventsWindow(QWidget):
|
||||
self.label_events = QLabel("Events in selected observation:")
|
||||
self.combo_events = QComboBox()
|
||||
self.combo_events.setEnabled(False)
|
||||
|
||||
|
||||
self.label_snirf_events = QLabel("Events in SNIRF file:")
|
||||
self.combo_snirf_events = QComboBox()
|
||||
self.combo_snirf_events.setEnabled(False)
|
||||
@@ -227,13 +227,13 @@ class UpdateEventsWindow(QWidget):
|
||||
self.btn_clear.clicked.connect(self.clear_files)
|
||||
self.btn_go.clicked.connect(self.go_action)
|
||||
|
||||
# ---
|
||||
# ---
|
||||
layout = QVBoxLayout()
|
||||
self.description = QLabel()
|
||||
self.description.setTextFormat(Qt.TextFormat.RichText)
|
||||
self.description.setTextInteractionFlags(Qt.TextInteractionFlag.TextBrowserInteraction)
|
||||
self.description.setOpenExternalLinks(True)
|
||||
|
||||
|
||||
self.description.setText("The events that are present in a snirf file may not be the events that are to be studied and examined.<br>"
|
||||
"Utilizing different software and video recordings, it is easy enough to see when an action actually occured in a file.<br>"
|
||||
"The software <a href='https://www.boris.unito.it/'>BORIS</a> is used to add these events to video files, and these events can be applied to the snirf file <br>"
|
||||
@@ -317,7 +317,7 @@ class UpdateEventsWindow(QWidget):
|
||||
help_btn_suffix.setToolTip(help_text_suffix)
|
||||
help_btn_suffix.clicked.connect(lambda: self.show_help_popup(help_text_suffix))
|
||||
suffix2_layout.addWidget(help_btn_suffix)
|
||||
|
||||
|
||||
suffix2_container = QWidget()
|
||||
suffix2_container_layout = QHBoxLayout()
|
||||
suffix2_container_layout.setContentsMargins(0, 0, 0, 0)
|
||||
@@ -328,7 +328,7 @@ class UpdateEventsWindow(QWidget):
|
||||
|
||||
suffix2_layout.addWidget(suffix2_container)
|
||||
layout.addLayout(suffix2_layout)
|
||||
|
||||
|
||||
snirf_events_layout = QHBoxLayout()
|
||||
|
||||
help_text_snirf_events = "The event markers extracted from the SNIRF file."
|
||||
@@ -370,7 +370,7 @@ class UpdateEventsWindow(QWidget):
|
||||
try:
|
||||
# Memory leak safe: Extracted in a separate process that terminates immediately
|
||||
annotations: Annotations = load_snirf_annotations_isolated(file_path)
|
||||
|
||||
|
||||
print(f"Loaded {len(annotations)} annotations from {file_path}")
|
||||
|
||||
# Build individual event entries
|
||||
@@ -398,7 +398,7 @@ class UpdateEventsWindow(QWidget):
|
||||
file_path, _ = QFileDialog.getOpenFileName(self, "Select BORIS File", "", "BORIS project Files (*.boris)")
|
||||
if file_path:
|
||||
self.line_edit_file_b.setText(file_path)
|
||||
|
||||
|
||||
try:
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
@@ -411,7 +411,7 @@ class UpdateEventsWindow(QWidget):
|
||||
except (json.JSONDecodeError, FileNotFoundError, KeyError) as e:
|
||||
QMessageBox.warning(self, "Error", f"Failed to parse BORIS file:\n{e}")
|
||||
|
||||
|
||||
|
||||
def extract_boris_observation_keys(self, data: dict[str, Any]) -> List[str]:
|
||||
if "observations" not in data:
|
||||
raise KeyError("Missing 'observations' key in BORIS file.")
|
||||
@@ -419,7 +419,7 @@ class UpdateEventsWindow(QWidget):
|
||||
observations = cast(dict[str, Any], data["observations"])
|
||||
return list(observations.keys())
|
||||
|
||||
|
||||
|
||||
def on_observation_selected(self):
|
||||
selected_obs = self.combo_suffix.currentText()
|
||||
if not selected_obs or not hasattr(self, 'boris_data'):
|
||||
@@ -454,12 +454,12 @@ class UpdateEventsWindow(QWidget):
|
||||
def clear_files(self) -> None:
|
||||
self.line_edit_file_a.clear()
|
||||
self.line_edit_file_b.clear()
|
||||
|
||||
|
||||
def go_action(self) -> None:
|
||||
|
||||
|
||||
file_a = self.line_edit_file_a.text()
|
||||
suffix = "flare"
|
||||
|
||||
suffix = "flare"
|
||||
|
||||
if not hasattr(self, "boris_data") or self.combo_events.count() == 0 or self.combo_snirf_events.count() == 0:
|
||||
QMessageBox.warning(self, "Missing data", "Please make sure a BORIS and SNIRF event are selected.")
|
||||
return
|
||||
@@ -600,7 +600,7 @@ class UpdateEventsBlazesWindow(QWidget):
|
||||
self.label_events = QLabel("Events in selected blazes file:")
|
||||
self.combo_events = QComboBox()
|
||||
self.combo_events.setEnabled(False)
|
||||
|
||||
|
||||
self.label_snirf_events = QLabel("Events in SNIRF file:")
|
||||
self.combo_snirf_events = QComboBox()
|
||||
self.combo_snirf_events.setEnabled(False)
|
||||
@@ -610,13 +610,13 @@ class UpdateEventsBlazesWindow(QWidget):
|
||||
self.btn_clear.clicked.connect(self.clear_files)
|
||||
self.btn_go.clicked.connect(self.go_action)
|
||||
|
||||
# ---
|
||||
# ---
|
||||
layout = QVBoxLayout()
|
||||
self.description = QLabel()
|
||||
self.description.setTextFormat(Qt.TextFormat.RichText)
|
||||
self.description.setTextInteractionFlags(Qt.TextInteractionFlag.TextBrowserInteraction)
|
||||
self.description.setOpenExternalLinks(True)
|
||||
|
||||
|
||||
self.description.setText("The events that are present in a snirf file may not be the events that are to be studied and examined.<br>"
|
||||
"Utilizing different software and video recordings, it is easy enough to see when an action actually occured in a file.<br>"
|
||||
"The software <a href='https://git.research.dezeeuw.ca/tyler/blazes/'>BLAZES</a> is used to create these events in video files, and these events can be applied to the snirf file <br>"
|
||||
@@ -679,7 +679,7 @@ class UpdateEventsBlazesWindow(QWidget):
|
||||
help_btn_suffix.setToolTip(help_text_suffix)
|
||||
help_btn_suffix.clicked.connect(lambda: self.show_help_popup(help_text_suffix))
|
||||
suffix2_layout.addWidget(help_btn_suffix)
|
||||
|
||||
|
||||
suffix2_container = QWidget()
|
||||
suffix2_container_layout = QHBoxLayout()
|
||||
suffix2_container_layout.setContentsMargins(0, 0, 0, 0)
|
||||
@@ -690,7 +690,7 @@ class UpdateEventsBlazesWindow(QWidget):
|
||||
|
||||
suffix2_layout.addWidget(suffix2_container)
|
||||
layout.addLayout(suffix2_layout)
|
||||
|
||||
|
||||
snirf_events_layout = QHBoxLayout()
|
||||
|
||||
help_text_snirf_events = "The event markers extracted from the SNIRF file."
|
||||
@@ -733,7 +733,7 @@ class UpdateEventsBlazesWindow(QWidget):
|
||||
try:
|
||||
# Memory leak safe: Extracted in a separate process that terminates immediately
|
||||
annotations: Annotations = load_snirf_annotations_isolated(file_path)
|
||||
|
||||
|
||||
print(f"Loaded {len(annotations)} annotations from {file_path}")
|
||||
|
||||
# Build individual event entries
|
||||
@@ -761,7 +761,7 @@ class UpdateEventsBlazesWindow(QWidget):
|
||||
file_path, _ = QFileDialog.getOpenFileName(self, "Select JSON Timeline File", "", "JSON Files (*.json)")
|
||||
if file_path:
|
||||
self.line_edit_file_b.setText(file_path)
|
||||
|
||||
|
||||
try:
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
@@ -780,7 +780,7 @@ class UpdateEventsBlazesWindow(QWidget):
|
||||
QMessageBox.warning(self, "Error", f"Failed to parse JSON file:\n{e}")
|
||||
self.combo_events.clear()
|
||||
self.combo_events.setEnabled(False)
|
||||
|
||||
|
||||
|
||||
def extract_json_observation_strings(self, data: dict[str, Any]) -> List[str]:
|
||||
if "events" not in data:
|
||||
@@ -792,23 +792,23 @@ class UpdateEventsBlazesWindow(QWidget):
|
||||
for event in data["events"]:
|
||||
track_name = event.get("track_name", "Unknown")
|
||||
onset = event.get("start_sec", 0.0)
|
||||
|
||||
|
||||
display_str = f"{track_name} @ {onset:.3f}s"
|
||||
event_strings.append(display_str)
|
||||
|
||||
return event_strings
|
||||
|
||||
|
||||
|
||||
def clear_files(self) -> None:
|
||||
self.line_edit_file_a.clear()
|
||||
self.line_edit_file_b.clear()
|
||||
|
||||
|
||||
|
||||
|
||||
def go_action(self) -> None:
|
||||
file_a = self.line_edit_file_a.text()
|
||||
_ = self.line_edit_file_b.text()
|
||||
suffix = APP_NAME
|
||||
|
||||
|
||||
if not hasattr(self, "json_data") or self.combo_events.count() == 0 or self.combo_snirf_events.count() == 0:
|
||||
QMessageBox.warning(self, "Missing data", "Please make sure a JSON and SNIRF event are selected.")
|
||||
return
|
||||
@@ -835,14 +835,14 @@ class UpdateEventsBlazesWindow(QWidget):
|
||||
durations: list[float] = []
|
||||
descriptions: list[str] = []
|
||||
skipped_count = 0
|
||||
|
||||
|
||||
try:
|
||||
events_list = self.json_data.get("events", [])
|
||||
|
||||
|
||||
for event in events_list:
|
||||
track_name = event.get("track_name", "Unknown")
|
||||
clean_name = track_name.replace("AI: ", "").strip()
|
||||
|
||||
|
||||
original_start = event.get("start_sec", 0.0)
|
||||
original_end = event.get("end_sec", original_start)
|
||||
duration = original_end - original_start
|
||||
@@ -870,7 +870,7 @@ class UpdateEventsBlazesWindow(QWidget):
|
||||
if self.mode == EventUpdateMode.WRITE_SNIRF:
|
||||
suggested_name = f"{os.path.splitext(os.path.basename(file_a))[0]}_{suffix}.snirf"
|
||||
save_path, _ = QFileDialog.getSaveFileName(self, "Save SNIRF", suggested_name, "SNIRF Files (*.snirf)")
|
||||
|
||||
|
||||
if not save_path: return
|
||||
if not save_path.lower().endswith(".snirf"): save_path += ".snirf"
|
||||
|
||||
|
||||
Reference in new issue
Block a user