Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Loading a series and an exam

A GE exam is a pile of series — a NIfTI here, a raw .mat recon there, sometimes both, sometimes neither — and the folders holding them can be named anything. Loading one by hand means knowing in advance whether series 6 is an anatomical scan or a spectrum, and picking the matching GESeries subclass yourself. GEExam exists so you don’t have to: point it at the exam’s data folder and it works that out from the files’ own metadata (the JSON sidecar’s SeriesDescription, or the .mat header’s se_desc).

FunctionWhat it does here
ExamBasescans a data folder and classifies every series
MRSSeriesloaded directly, for when you already know what a series is

1. Point ExamBase at the exam

BASE_FOLDER is the exam’s top-level folder; ExamBase looks for a data/ subfolder inside it by default (override with DATA_FOLDER= if your layout differs). On init it indexes every series’ NIfTI and raw-data presence and prints an overview — useful on its own when you’ve forgotten what’s in a dataset.

Loading...

That overview is also available as a DataFrame, and series_dict shows the classification ExamBase settled on before loading anything — nothing here has touched a NIfTI’s pixel data yet.

Loading...
(mnutils.GESeries.MRSSeries, mnutils.GESeries.MRSISeries)

2. Load one series

load_series instantiates the right class and stores it on exam.all, keyed by series ID. Everything about a series you’d normally want — its spectrum, its header fields, its scan time — comes from that one object afterward.

MRSSeries MRS_unloc

GEExam picked MRSSeries, so the spectrum comes back with an averages dimension — one spectrum per repetition. Averaging over it is the usual first step:

('averages', 'chemical_shift') (64, 2048)
('chemical_shift',) (2048,)

3. Or skip the exam and load a series directly

If you already know a series is single-voxel spectroscopy, you can construct MRSSeries (or any other GESeries subclass — see the class hierarchy) directly with the same (DATA_FOLDER, SERIES_ID) signature ExamBase uses internally. This is what you’d reach for in a one-off script where pulling in the whole exam overview is more than you need.

True

4. Load several series, or all of them

load_series also accepts a list; load_all loads everything ExamBase classified. For an exam with several MRSI grids this can take a while — load only what you need.

[6, 8]