From c143be340e00e9c865f89fdbd198e7eeaddc7e5c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 6 Oct 2026 08:20:08 +0000 Subject: [PATCH 1/2] Turn the localizer's FOV box with a rotate handle, for oblique planning The handle sets the angle and rotation axis of every sequence as the box's move and resize set its centre and size. On pulserver's console the Transversal plane's turn is written right-handed about its axis, and the box is redrawn turned on the plane it was turned on. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01Afq4fxyjbebF7KbvaNC1uh --- marge/controller/controller_plot3d.py | 21 ++++++++++++++++----- marge/seq/pulserver_console.py | 3 +++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/marge/controller/controller_plot3d.py b/marge/controller/controller_plot3d.py index 3a77bc0f..955c384d 100644 --- a/marge/controller/controller_plot3d.py +++ b/marge/controller/controller_plot3d.py @@ -10,6 +10,12 @@ from marge.widgets.widget_plot3d import Plot3DWidget import marge.configs.hw_config as hw import pyqtgraph as pg +from marge.seq.pulserver_console import console_mode + +#: Sign of the box's turn on the Transversal plane about MaRGE's axis 0. The box +#: turns from axis 2 towards axis 1, about -axis 0; pulserver's console reads +#: the angle as right-handed about the axis, so it takes the sign that says so. +TRANSVERSAL_TURN = -1 if console_mode() else 1 class Plot3DController(Plot3DWidget): @@ -57,7 +63,7 @@ def __init__(self, data=np.array([]), x_label='', y_label='', title='', *args, * self.roiFOV.setPen(pg.mkPen('r', width=3)) self.roiFOV.hoverPen = pg.mkPen('g', width=3) self.roiFOV.addScaleHandle([1, 1], [0.5, 0.5]) - # self.roiFOV.addRotateHandle([0, 0], [0.5, 0.5]) + self.roiFOV.addRotateHandle([0, 0], [0.5, 0.5]) # Manage colors for h in self.roiFOV.handles: @@ -136,13 +142,13 @@ def menuClicked(self): y_axis = 0 z_axis = 2 elif self.title == "Coronal": - a = -1 + a = 1 d = [1, 1] #[RL, IS] x_axis = 2 y_axis = 0 z_axis = 1 elif self.title == "Transversal": - a = 1 + a = TRANSVERSAL_TURN d = [1, 1] #[RL, PA] x_axis = 2 y_axis = 1 @@ -156,9 +162,14 @@ def menuClicked(self): if self.seq_name in defaultsequences.keys(): roi_fov = np.array(defaultsequences[self.seq_name].mapVals['fov']) * 1e-2 # m roi_pos = np.array(defaultsequences[self.seq_name].mapVals['dfov']) * 1e-3 # m + # The box is drawn turned only on the plane whose normal is the rotation axis + seq_vals = defaultsequences[self.seq_name].mapVals + axis = np.asarray(seq_vals.get('rotationAxis', [0, 0, 0]), dtype=float) + roi_angle = a * float(seq_vals.get('angle', 0.0)) if axis[z_axis] != 0 and np.count_nonzero(axis) == 1 else 0.0 else: roi_fov = img_fov roi_pos = [0.0, 0.0, 0.0] + roi_angle = 0.0 img_fov_px = np.array(np.shape(self.getProcessedImage()))[1::] img_fov_ru = [img_fov[x_axis], img_fov[y_axis]] @@ -172,7 +183,7 @@ def menuClicked(self): # Set roi size and angle self.roiFOV.setPos(roi_pos_px, update=False) self.roiFOV.setSize(roi_fov_px, update=False) - self.roiFOV.setAngle(0.0, update=False) + self.roiFOV.setAngle(roi_angle, center=[0.5, 0.5], update=False) self.roiFOV.stateChanged() # Show the roi @@ -212,7 +223,7 @@ def roiFOVChanged(self): y_axis = 0 z_axis = 1 elif self.title == "Transversal": - a = 1 + a = TRANSVERSAL_TURN d = [1, 1] x_axis = 2 y_axis = 1 diff --git a/marge/seq/pulserver_console.py b/marge/seq/pulserver_console.py index 61fae539..cbbad0fd 100644 --- a/marge/seq/pulserver_console.py +++ b/marge/seq/pulserver_console.py @@ -528,6 +528,9 @@ def __init__(self) -> None: self.addParameter(key="pulserverConsole", val=True) self.addParameter(key="fov", val=[25.6, 25.6, 25.6], units=1e-2) self.addParameter(key="dfov", val=[0.0, 0.0, 0.0], units=1e-3) + # Carried so that the localizer's FOV box is redrawn turned as planned. + self.addParameter(key="angle", val=0.0, units=1) + self.addParameter(key="rotationAxis", val=[1.0, 0.0, 0.0], units=1) self.files: list[bytes] = [] def sequenceRun(self, plotSeq=0, demo=False) -> bool: # noqa: N802 -- MaRGE's API From 157b7953b719dd0585a84bf0fc659f03f9c88fdf Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 6 Oct 2026 08:20:45 +0000 Subject: [PATCH 2/2] Fill the browser tab with MaRGE's main window, so its history is in view Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01Afq4fxyjbebF7KbvaNC1uh --- marge/ui/window_main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/marge/ui/window_main.py b/marge/ui/window_main.py index 3c9fd683..44e4aa44 100644 --- a/marge/ui/window_main.py +++ b/marge/ui/window_main.py @@ -5,6 +5,7 @@ """ import datetime +import sys from PyQt5.QtWidgets import ( QMainWindow, QStatusBar, QWidget, QHBoxLayout, QVBoxLayout, QTableWidget, QSizePolicy @@ -158,3 +159,10 @@ def __init__(self, session, demo=False, parent=None): # Add printer self.printer = Printer(main=self) + + def show(self): + """Show the window; in a browser tab, filling the tab, so that the history below the figures is in view.""" + if sys.platform == "emscripten": + self.showMaximized() + else: + super().show()