Skip to content

Commit

Permalink
Merge pull request HEXRD#1641 from bnmajor/load-images
Browse files Browse the repository at this point in the history
Fix bug with image quick load
  • Loading branch information
bnmajor authored Dec 20, 2023
2 parents 3dbf837 + fb76987 commit 3e03d4f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions hexrdgui/load_images_dialog.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from collections import Counter # To compare two lists' contents
import re
import os
from pathlib import Path

from PySide6.QtWidgets import QMessageBox, QTableWidgetItem, QComboBox
from hexrdgui.constants import TRANSFORM_OPTIONS
Expand Down Expand Up @@ -49,13 +50,14 @@ def exec(self):
if self.ui.exec():
# Perform some validation before returning
results = self.results()
image_files = [v for f in results.values() for v in f]
matches = [Path(v).name for f in results.values() for v in f]
image_files = [Path(f).name for f in self.image_files]
if Counter(results.keys()) != Counter(self.detectors):
msg = 'Detectors do not match the current detectors'
QMessageBox.warning(self.ui, 'HEXRD', msg)
continue
elif (not self.using_roi and
Counter(image_files) != Counter(self.image_files)):
(Counter(matches) != Counter(image_files))):
msg = 'Image files do not match the selected files'
QMessageBox.warning(self.ui, 'HEXRD', msg)
continue
Expand Down Expand Up @@ -121,7 +123,7 @@ def setup_standard_table(self, table):
table.cellWidget(i, 1).currentTextChanged.connect(
lambda v, i=i: self.selection_changed(v, i))

f = QTableWidgetItem(self.image_files[i])
f = QTableWidgetItem(Path(self.image_files[i]).name)
table.setItem(i, 2, f)

def setup_table(self):
Expand Down Expand Up @@ -158,7 +160,7 @@ def update_table(self):
table.cellWidget(i, 2).currentTextChanged.connect(
lambda v, i=i: self.selection_changed(v, i))
else:
f = QTableWidgetItem(image_files[i])
f = QTableWidgetItem(Path(image_files[i]).name)
table.setItem(i, 2, f)

def results(self):
Expand All @@ -182,7 +184,7 @@ def results(self):
det_idx = i
if not self.using_roi:
imgs_per_det = len(self.image_files) / len(self.detectors)
det_idx = i // imgs_per_det
det_idx = int(i / imgs_per_det)
HexrdConfig().load_panel_state['trans'][det_idx] = idx

return results
Expand Down

0 comments on commit 3e03d4f

Please sign in to comment.