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.

GESeries.MRSISeries

GESeries.MRSISeries(DATA_FOLDER, SERIES_ID, load_processed_data=False)

A raw MRSI series: spectroscopic imaging spectra, fitting, and voxel maps.

Attributes

NameDescription
RAW_exp
SNR_mapThe per-voxel SNR, computed from the FIDs via pyAMARES.fidSNR.
avg_fidAverage fid across voxels with SNR above threshold.
default_SNR_maskThe default SNR mask, computed with get_SNR_mask’s default threshold.
dims
fidsThe FIDs, derived from the spectra via FFT.
fids_flatThe FIDs with the voxel dimensions stacked into a single voxel dim.
fitted_metabolite_maps
goodness_of_fit_maps
npts
ppm
spec
spec_flatThe spectra with the voxel dimensions stacked into a single voxel dim.
voxel_sizeThe in-plane voxel size (mm), derived from the field of view and matrix.

Methods

NameDescription
create_MRSI_affineReturn an affine matrix rescaled to the MRSI voxel size and offset.
create_MRSI_niiReturn the RAW magnitude image as a NiiBase, with the MRSI affine.
create_map_niiWrap a per-voxel map array as a NiiBase, with the MRSI affine.
fit_all_voxelsFit all voxels above the SNR threshold with AMARES and store the maps.
fit_single_voxelFit the FID at voxel (x, y, slice) with AMARES.
get_SNR_maskReturn a boolean mask of voxels with SNR at or above threshold.
get_voxel_spectrumReturn the spectrum at voxel (x, y, slice).
load_processed_dataLoad the most recent processed-data HDF5 file for this series.
save_processed_dataSave fitted maps, FIDs, and identifying attributes to an HDF5 file.
visualize_fitted_metabolite_mapDisplay the fitted metabolite map for metabolite_name.
visualize_fitted_valuesNot yet implemented.
visualize_goodness_of_fit_mapDisplay the goodness-of-fit map for metric_name.

create_MRSI_affine

GESeries.MRSISeries.create_MRSI_affine()

Return an affine matrix rescaled to the MRSI voxel size and offset.

create_MRSI_nii

GESeries.MRSISeries.create_MRSI_nii()

Return the RAW magnitude image as a NiiBase, with the MRSI affine.

create_map_nii

GESeries.MRSISeries.create_map_nii(map_data)

Wrap a per-voxel map array as a NiiBase, with the MRSI affine.

fit_all_voxels

GESeries.MRSISeries.fit_all_voxels(
    init_params,
    batch_fitting_params=None,
    bad_fit_chisqr_threshold=-1.0,
    testing_mode=False,
)

Fit all voxels above the SNR threshold with AMARES and store the maps.

Parameters

NameTypeDescriptionDefault
init_paramsdictInitial fit parameters, merged with series-derived MHz/sw/deadtime.required
batch_fitting_paramsdictForwarded to fitting.AMARES.fit_multiple_fids.None
bad_fit_chisqr_thresholdfloatChi-squared threshold above which a fit is flagged as bad. Defaults to -1.0 (disabled).-1.0
testing_modeboolIf True, limit fitting to the first 100 voxels above the SNR threshold.False

Returns

NameTypeDescription
numpy.ndarrayFlattened voxel indices of fits flagged as bad.

fit_single_voxel

GESeries.MRSISeries.fit_single_voxel(x, y, slice, init_params, fit_params=None)

Fit the FID at voxel (x, y, slice) with AMARES.

get_SNR_mask

GESeries.MRSISeries.get_SNR_mask(threshold=1.5)

Return a boolean mask of voxels with SNR at or above threshold.

get_voxel_spectrum

GESeries.MRSISeries.get_voxel_spectrum(x, y, slice)

Return the spectrum at voxel (x, y, slice).

load_processed_data

GESeries.MRSISeries.load_processed_data(output_folder=None, force_load=False)

Load the most recent processed-data HDF5 file for this series.

Parameters

NameTypeDescriptionDefault
output_folderPathDirectory to search in. Defaults to OUTPUT_FOLDER / "processing_data".None
force_loadboolIf True, load the data even if SERIES_ID, exam_number, or acquisition time do not match this series.False

Returns

NameTypeDescription
boolTrue if data was loaded successfully, False otherwise.

save_processed_data

GESeries.MRSISeries.save_processed_data(output_folder=None)

Save fitted maps, FIDs, and identifying attributes to an HDF5 file.

Parameters

NameTypeDescriptionDefault
output_folderPathDirectory to save into. Defaults to OUTPUT_FOLDER / "processing_data".None

Returns

NameTypeDescription
PathPath to the saved (or, if a file already exists, the existing) HDF5 file.

Raises

NameTypeDescription
OSErrorIf the saved file fails the post-save integrity check.

visualize_fitted_metabolite_map

GESeries.MRSISeries.visualize_fitted_metabolite_map(metabolite_name, **kwargs)

Display the fitted metabolite map for metabolite_name.

visualize_fitted_values

GESeries.MRSISeries.visualize_fitted_values()

Not yet implemented.

visualize_goodness_of_fit_map

GESeries.MRSISeries.visualize_goodness_of_fit_map(metric_name, **kwargs)

Display the goodness-of-fit map for metric_name.