GESeries.MRSISeries
GESeries.MRSISeries(DATA_FOLDER, SERIES_ID, load_processed_data=False)A raw MRSI series: spectroscopic imaging spectra, fitting, and voxel maps.
Attributes¶
| Name | Description |
|---|---|
RAW_exp | |
SNR_map | The per-voxel SNR, computed from the FIDs via pyAMARES.fidSNR. |
avg_fid | Average fid across voxels with SNR above threshold. |
default_SNR_mask | The default SNR mask, computed with get_SNR_mask’s default threshold. |
dims | |
fids | The FIDs, derived from the spectra via FFT. |
fids_flat | The FIDs with the voxel dimensions stacked into a single voxel dim. |
fitted_metabolite_maps | |
goodness_of_fit_maps | |
npts | |
ppm | |
spec | |
spec_flat | The spectra with the voxel dimensions stacked into a single voxel dim. |
voxel_size | The in-plane voxel size (mm), derived from the field of view and matrix. |
Methods¶
| Name | Description |
|---|---|
| create_MRSI_affine | Return an affine matrix rescaled to the MRSI voxel size and offset. |
| create_MRSI_nii | Return the RAW magnitude image as a NiiBase, with the MRSI affine. |
| create_map_nii | Wrap a per-voxel map array as a NiiBase, with the MRSI affine. |
| fit_all_voxels | Fit all voxels above the SNR threshold with AMARES and store the maps. |
| fit_single_voxel | Fit the FID at voxel (x, y, slice) with AMARES. |
| get_SNR_mask | Return a boolean mask of voxels with SNR at or above threshold. |
| get_voxel_spectrum | Return the spectrum at voxel (x, y, slice). |
| load_processed_data | Load the most recent processed-data HDF5 file for this series. |
| save_processed_data | Save fitted maps, FIDs, and identifying attributes to an HDF5 file. |
| visualize_fitted_metabolite_map | Display the fitted metabolite map for metabolite_name. |
| visualize_fitted_values | Not yet implemented. |
| visualize_goodness_of_fit_map | Display 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¶
| Name | Type | Description | Default |
|---|---|---|---|
| init_params | dict | Initial fit parameters, merged with series-derived MHz/sw/deadtime. | required |
| batch_fitting_params | dict | Forwarded to fitting.AMARES.fit_multiple_fids. | None |
| bad_fit_chisqr_threshold | float | Chi-squared threshold above which a fit is flagged as bad. Defaults to -1.0 (disabled). | -1.0 |
| testing_mode | bool | If True, limit fitting to the first 100 voxels above the SNR threshold. | False |
Returns¶
| Name | Type | Description |
|---|---|---|
| numpy.ndarray | Flattened 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¶
| Name | Type | Description | Default |
|---|---|---|---|
| output_folder | Path | Directory to search in. Defaults to OUTPUT_FOLDER / "processing_data". | None |
| force_load | bool | If True, load the data even if SERIES_ID, exam_number, or acquisition time do not match this series. | False |
Returns¶
| Name | Type | Description |
|---|---|---|
| bool | True 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¶
| Name | Type | Description | Default |
|---|---|---|---|
| output_folder | Path | Directory to save into. Defaults to OUTPUT_FOLDER / "processing_data". | None |
Returns¶
| Name | Type | Description |
|---|---|---|
| Path | Path to the saved (or, if a file already exists, the existing) HDF5 file. |
Raises¶
| Name | Type | Description |
|---|---|---|
| OSError | If 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.