Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Rubick65/dcemapper/llms.txt

Use this file to discover all available pages before exploring further.

The MainWindow class in src.ui.interface.PyQT_interface is the top-level PyQt6 application window for DCEMapper. It wires together the NIfTI canvas, the slice selector panel, the intensity graph, the toolbar, and all keyboard shortcuts into a single resizable three-panel layout. Understanding its public API lets you launch the application programmatically, pre-load data, and drive the preprocessing and processing pipelines without touching the GUI manually.

MainWindow(nifty_path=None)

Constructs and initialises the main application window.
nifty_path
string
default:"None"
Optional path to a NIfTI file. When provided, set_nifti is called immediately during __init__ so the file is displayed as soon as window.show() is called. When omitted, the window starts empty and the user loads data through the File menu.
Launching the application
from PyQt6.QtWidgets import QApplication
from src.ui.interface.PyQT_interface import MainWindow
import sys

app = QApplication(sys.argv)

# Open an empty window
window = MainWindow()

# — or — auto-load a file on startup
window = MainWindow(nifty_path="path/to/data.nii.gz")

window.show()
sys.exit(app.exec())
You can also run the module directly from the repository root, which mirrors the behaviour of the installed launcher:
python -m src.ui.interface.PyQT_interface
MainWindow must always be instantiated inside a live QApplication context. Creating a MainWindow before calling QApplication(sys.argv) will raise a RuntimeError from Qt.

Key public methods

Internal methods — those prefixed with _, or any method that constructs or modifies Qt widgets directly (e.g. image_selector_layout, main_image_layout, graphic_layout, slider_label) — are not part of the public API and may change between versions without notice.

set_nifti(nifty_path)

Loads a NIfTI file and rebuilds the entire three-panel UI. Resets the canvas, the intensity graph, and all ROI state before constructing fresh left, centre, and right containers. Called internally by set_various_files() when the user opens a file through the menu, and by set_proc_files() when switching to a processed view.
window.set_nifti("derivatives/sub-001/dce_preproc.nii.gz")

preprocessing(selected_preprocess_options)

Runs the selected preprocessing pipeline in sequence: optional denoising followed by optional Gibbs removal. Output is written to the subject’s derivatives folder. On success, calls set_new_data to reload the UI with the preprocessed file.
selected_preprocess_options
tuple
required
A two-element tuple (denoise_filter_name, gibbs_option):
  • denoise_filter_name (str or falsy) — filter string passed to denoise_init_one_file. Set to None or "" to skip denoising.
  • gibbs_option (bool or truthy) — when truthy, Gibbs ringing removal is applied after denoising.
# Denoise with Non-Local Means, then apply Gibbs removal
window.preprocessing(("Non local means skimage", True))

# Gibbs removal only
window.preprocessing((None, True))

# Denoising only (no Gibbs)
window.preprocessing(("Adaptative Soft Coefficient Matching", False))

processing(selected_process_option)

Runs the selected quantitative processing pipeline and updates the canvas with the primary output file. Currently supports semi-quantitative mapping (dispatched when the option string starts with "s" or "S").
selected_process_option
string
required
Processing pipeline name. The function matches on the first character (case-insensitive). Supported values:
StringPipeline
"Semi-quantitative"Calls semi_quantitative; produces RCE, RCE-max, and TTP maps.
window.processing("Semi-quantitative")
After processing completes, the canvas colourmap is switched to "jet" and the viewer toolbar is activated to allow switching between RCE, RCE-max, and TTP views.

set_new_data(data)

Reloads the canvas, slice selector, and toolbar state with a new NIfTI file path without rebuilding the entire layout. Use this to switch between related files (e.g. after applying a preprocessing step) while keeping the current ROI state intact.
data
string
required
Path to the new NIfTI file to display.
window.set_new_data("derivatives/sub-001/dce_preproc.nii.gz")

toggle_movie_mode()

Starts or stops the QTimer-driven cine playback mode. When the timer is active, the canvas advances one time frame every movie_speed milliseconds. When it reaches the last frame, the timer stops and the slider resets to frame 0. The frame interval is controlled by window.movie_speed (in milliseconds, default 30 ms ≈ 33 fps). The FPS slider in the left panel updates movie_speed in real time via 1000 / fps.
# Start/stop playback programmatically (equivalent to pressing Space)
window.toggle_movie_mode()

reset_layout()

Restores the three-panel splitter to its default proportions and resets the vertical split between the intensity graph and the click record. Useful after the user has dragged panels to unusual sizes. Default proportions (relative to window.total_w / window.total_h):
PanelWidth share
Left — slice selector20 %
Centre — main canvas40 %
Right — graph + record40 %
The vertical split in the right panel is also restored: 70 % for the intensity graph and 30 % for the click record.
# Equivalent to pressing the R key
window.reset_layout()

Keyboard shortcuts summary

The shortcuts below are registered by init_shortcuts() every time a file is opened. They map directly to the public methods listed above.
KeyAction
Spacetoggle_movie_mode()
Rreset_layout()
/ Advance / rewind one time frame
/ Navigate slice history (back / forward)
Ctrl+ZUndo last ROI on current slice (restar_mask)
Ctrl+RActivate rectangle ROI selector
Ctrl+EActivate ellipse ROI selector
Ctrl+PActivate polygon ROI selector
TabConfirm and apply current ROI selection
EscCancel current ROI selection
HReset zoom / pan (home view)
ZToggle zoom mode
MToggle pan mode
FToggle fullscreen
For a complete keyboard reference see the Keyboard Shortcuts guide.

Build docs developers (and LLMs) love