""" Entry point for the MRI Sequence Interpreter GUI. Run from the repo root: python -m seq_interp.gui_app or: python seq_interp/gui_app.py Optionally pass a .seq file as the first CLI argument to pre-load it: python seq_interp/gui_app.py data/input/test1_full.seq """ from __future__ import annotations import os import sys # Ensure the repo root (parent of seq_interp/) is importable regardless of # how the script is invoked. _here = os.path.dirname(os.path.abspath(__file__)) _repo_root = os.path.dirname(_here) if _repo_root not in sys.path: sys.path.insert(0, _repo_root) import argparse from PySide6.QtWidgets import QApplication from seq_interp.src.gui.main_window import MainWindow def main() -> None: parser = argparse.ArgumentParser( description="MRI Sequence Interpreter — interactive GUI" ) parser.add_argument( "seq_file", nargs="?", default=None, help="Optional .seq file to load on startup", ) parser.add_argument( "--hw-config", default=None, help="Optional hardware config JSON to load on startup", ) parser.add_argument( "--output-dir", default=None, help="Optional output directory", ) args = parser.parse_args() app = QApplication(sys.argv) app.setApplicationName("MRI Sequence Interpreter") app.setOrganizationName("LF-MRI") # Qt6 / PySide6: high-DPI is enabled automatically — AA_UseHighDpiPixmaps # is deprecated and emits a DeprecationWarning; omit it. win = MainWindow() # Centre window on primary screen (MainWindow.__init__ sizes it already, # but doesn't centre) screen = app.primaryScreen() if screen is not None: ag = screen.availableGeometry() win.move( ag.x() + (ag.width() - win.width()) // 2, ag.y() + (ag.height() - win.height()) // 2, ) # Pre-load files from CLI arguments if given if args.hw_config and os.path.isfile(args.hw_config): win._hw_config_path = os.path.abspath(args.hw_config) win._log(f"HW config pre-loaded: {win._hw_config_path}") if args.output_dir: win._output_dir = os.path.abspath(args.output_dir) win._log(f"Output dir: {win._output_dir}") if args.seq_file and os.path.isfile(args.seq_file): win._seq_path = os.path.abspath(args.seq_file) name = os.path.basename(win._seq_path) win._set_seq_state("selected", name) win._btn_run.setEnabled(True) win._log(f"Sequence pre-loaded: {win._seq_path}") win.show() sys.exit(app.exec()) if __name__ == "__main__": main()