Skip to content

Commit

Permalink
add reshape menu to adjust shape any time
Browse files Browse the repository at this point in the history
  • Loading branch information
sezelt committed Mar 17, 2024
1 parent 1465a76 commit 97b84a8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/py4D_browser/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class DataViewer(QMainWindow):
export_datacube,
export_virtual_image,
show_keyboard_map,
reshape_data,
)

from py4D_browser.update_views import (
Expand Down Expand Up @@ -120,6 +121,10 @@ def setup_menus(self):
self.load_arina_action.triggered.connect(self.load_data_arina)
self.file_menu.addAction(self.load_arina_action)

self.reshape_data_action = QAction("&Reshape Data...", self)
self.reshape_data_action.triggered.connect(self.reshape_data)
self.file_menu.addAction(self.reshape_data_action)

self.file_menu.addSeparator()

export_label = QAction("Export", self)
Expand Down
12 changes: 12 additions & 0 deletions src/py4D_browser/menu_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ def load_file(self, filepath, mmap=False, binning=1):
self.setWindowTitle(filepath)


def reshape_data(self):
new_shape = ResizeDialog.get_new_size(self.datacube.shape[:2], parent=self)
self.datacube.data = self.datacube.data.reshape(
*new_shape, *self.datacube.data.shape[2:]
)

print(f"Reshaping data to {new_shape}")

self.update_diffraction_space_view(reset=True)
self.update_real_space_view(reset=True)


def export_datacube(self, save_format: str):
assert save_format in [
"Raw float32",
Expand Down

0 comments on commit 97b84a8

Please sign in to comment.