Commit c5ad62d0 authored by William Clarke's avatar William Clarke
Browse files

Add nuisance parameter outputs to fsl_mrsi.

parent 2f67e6fd
......@@ -3,6 +3,7 @@ This document contains the FSL-MRS release history in reverse chronological orde
1.1.4 (WIP)
------------------------------
- Fixed bug in mrs_tools split
- fsl_mrsi now outputs fitting nuisance parameters: phases, and shifts & linewidths for each metabolite group.
1.1.3 (Tuesday 29th June 2021)
------------------------------
......
......@@ -315,11 +315,13 @@ def main():
# Generate the folders
concs_folder = os.path.join(args.output, 'concs')
uncer_folder = os.path.join(args.output, 'uncertainties')
nuisance_folder = os.path.join(args.output, 'nuisance')
qc_folder = os.path.join(args.output, 'qc')
fit_folder = os.path.join(args.output, 'fit')
os.mkdir(concs_folder)
os.mkdir(uncer_folder)
os.mkdir(nuisance_folder)
os.mkdir(qc_folder)
os.mkdir(fit_folder)
......@@ -367,6 +369,65 @@ def main():
cleanup=True,
dtype=float))
# Fitting nuisance parameters
# Phases - p0, p1
p0_list = [res[0].getPhaseParams()[0] for res in results]
file_p0 = os.path.join(nuisance_folder, 'p0.nii.gz')
save_img_output(file_p0,
mrsi.list_to_matched_array(
p0_list,
indicies=indicies,
cleanup=True,
dtype=float))
p1_list = [res[0].getPhaseParams()[1] for res in results]
file_p1 = os.path.join(nuisance_folder, 'p1.nii.gz')
save_img_output(file_p1,
mrsi.list_to_matched_array(
p1_list,
indicies=indicies,
cleanup=True,
dtype=float))
# Grouped - shifts, widths (gamma, sigma, combined)
for group in range(results[0][0].g):
shiftn_list = [res[0].getShiftParams()[group] for res in results]
file_sn = os.path.join(nuisance_folder, f'shift_group{group}.nii.gz')
save_img_output(file_sn,
mrsi.list_to_matched_array(
shiftn_list,
indicies=indicies,
cleanup=True,
dtype=float))
comb_n_list = [res[0].getLineShapeParams()[0][group] for res in results]
file_comb = os.path.join(nuisance_folder, f'combined_lw_group{group}.nii.gz')
save_img_output(file_comb,
mrsi.list_to_matched_array(
comb_n_list,
indicies=indicies,
cleanup=True,
dtype=float))
gamma_n_list = [res[0].getLineShapeParams()[1][group] for res in results]
file_gam = os.path.join(nuisance_folder, f'gamma_group{group}.nii.gz')
save_img_output(file_gam,
mrsi.list_to_matched_array(
gamma_n_list,
indicies=indicies,
cleanup=True,
dtype=float))
if results[0][0].model == 'voigt':
sigma_n_list = [res[0].getLineShapeParams()[2][group] for res in results]
file_sig = os.path.join(nuisance_folder, f'sigma_group{group}.nii.gz')
save_img_output(file_sig,
mrsi.list_to_matched_array(
sigma_n_list,
indicies=indicies,
cleanup=True,
dtype=float))
# qc - SNR & FWHM
for metab in results[0][0].original_metabs:
metab_fwhm_list = [res[0].getQCParams(metab=metab)[1]
......
......@@ -41,9 +41,17 @@ def test_fsl_mrsi(tmp_path):
assert (tmp_path / 'fit_out/qc').exists()
assert (tmp_path / 'fit_out/uncertainties').exists()
assert (tmp_path / 'fit_out/concs').exists()
assert (tmp_path / 'fit_out/nuisance').exists()
assert (tmp_path / 'fit_out/concs/raw/NAA.nii.gz').exists()
assert (tmp_path / 'fit_out/concs/molality/NAA.nii.gz').exists()
assert (tmp_path / 'fit_out/uncertainties/NAA_sd.nii.gz').exists()
assert (tmp_path / 'fit_out/qc/NAA_snr.nii.gz').exists()
assert (tmp_path / 'fit_out/fit/fit.nii.gz').exists()
assert (tmp_path / 'fit_out/nuisance/p0.nii.gz').exists()
assert (tmp_path / 'fit_out/nuisance/p1.nii.gz').exists()
assert (tmp_path / 'fit_out/nuisance/shift_group0.nii.gz').exists()
assert (tmp_path / 'fit_out/nuisance/combined_lw_group0.nii.gz').exists()
assert (tmp_path / 'fit_out/nuisance/gamma_group0.nii.gz').exists()
assert (tmp_path / 'fit_out/nuisance/sigma_group0.nii.gz').exists()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment