The GEExam class hierarchy
ExamBase is the general-purpose entry point: point it at a data folder
and it classifies every series for you. Some study designs are common enough to deserve their own
subclass on top of that — one that already knows which series is the anatomical scan, which are
the pre/post-injection spectra, and how they relate to each other, so you don’t have to
re-derive that bookkeeping in every notebook.
| Class | What it adds |
|---|---|
ExamBase | classifies series into GESeries subclasses; load_series/load_all |
DMIExam | + sorts series into anatomical/all_MRS/all_MRSI by folder-name convention |
MS_DMIExam | + picks the one MRSI and the two MRS series flanking it (pre/post) |
DMIinjExam | + splits every MRS/MRSI series into pre-/post-injection lists around a wash-in series |
import numpy as np
from mnutils.GEExam import DMIinjExam
from mnutils.testing import build_fake_exam
DATA_FOLDER = build_fake_exam("brain_mrs_mrsi_exam") / "data"Splitting series around an injection¶
DMIinjExam finds a wash-in series (description containing MRS washin) and uses its series ID
as a reference point: every other MRS/MRSI series sorts into “pre” (the single one immediately
before it) or “post” (all series after it, in order). This is _split_series — a pure function
of a series-ID array and a reference ID, easiest to see without loading any real data.
exam = object.__new__(DMIinjExam) # bypass __init__: _split_series only reads its arguments
pre, post = DMIinjExam._split_series(exam, np.array([3, 7, 9]), 5, "MRS")
print(pre, post)2026-10-16 09:49:41.206 | DEBUG | mnutils.GEExam:_split_series:399 - Splitting MRS series into pre- and post-injection based on reference series 5 for series list: [3 7 9].
3 [7 9]
Loading a real exam¶
DMIinjExam.load_all_series() does the equivalent classification against real series data,
setting pre_MRS/post_MRS/pre_MRSI/post_MRSI/washin once loaded. The general
ExamBase walkthrough already covers classification and loading in
depth — this page only adds the injection-specific splitting on top.