|
1 | | -import numpy as np |
2 | | -from geff.affine import Affine |
3 | 1 | from qtpy.QtCore import Qt |
4 | 2 | from qtpy.QtWidgets import ( |
5 | 3 | QDoubleSpinBox, |
@@ -44,22 +42,23 @@ def __init__(self): |
44 | 42 | def _prefill_from_metadata(self, metadata: dict) -> None: |
45 | 43 | """Update the scale widget, prefilling with metadata information if possible. |
46 | 44 | Args: |
47 | | - metadata (dict): geff metadata dictionary containing 'affine' and 'axes' keys. |
| 45 | + metadata (dict): geff metadata dictionary containing 'axes' key with scaling |
| 46 | + information. |
48 | 47 | """ |
49 | 48 |
|
50 | 49 | if len(metadata) > 0: |
51 | 50 | self.setVisible(True) |
52 | 51 | clear_layout(self.scale_layout) |
53 | 52 | self.scale_form_layout = QFormLayout() |
54 | 53 |
|
55 | | - affine = metadata.get("affine") |
56 | | - if affine is not None: |
57 | | - affine = affine.get("matrix", None) |
58 | | - affine = Affine(matrix=affine) |
59 | | - linear = affine.linear_matrix |
60 | | - self.scale = tuple(np.diag(linear)) |
61 | | - else: |
62 | | - self.scale = [1] * len(metadata.get("axes")) |
| 54 | + # read scaling information from metadata, prefill with 1 for all axes if not |
| 55 | + # given |
| 56 | + self.scale = list([1.0] * len(metadata.get("axes"))) |
| 57 | + axes = metadata.get("axes", []) |
| 58 | + lookup = {a["name"].lower(): a.get("scale", 1) or 1 for a in axes} |
| 59 | + self.scale[-1], self.scale[-2] = lookup.get("x", 1), lookup.get("y", 1) |
| 60 | + if "z" in lookup: |
| 61 | + self.scale[-3] = lookup.get("z", 1) |
63 | 62 |
|
64 | 63 | # Spinboxes for scaling in (z), y, x. |
65 | 64 | self.z_label = QLabel("z") |
|
0 commit comments