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

Tweaks whilst working on dynamic mrs.

parent 05395460
......@@ -254,7 +254,7 @@ def main():
if args.hlsvd:
if args.verbose:
print('... Residual water removal ...')
hlsvdlimits = [-0.35, 0.35]
hlsvdlimits = [-0.25, 0.25]
supp_data = nifti_mrs_proc.remove_peaks(supp_data, hlsvdlimits, limit_units='ppm', report=report_dir)
if args.leftshift:
......
......@@ -101,13 +101,14 @@ class dynMRS(object):
x_out = np.mean(x, axis=0)
x_all = x
x_cov = np.cov(x.T)
sol = None
else:
raise (Exception(f'Unrecognised method {method}'))
res_list = self.collect_results(x, model, method, ppmlim, baseline_order)
if verbose:
print(f"Fitting completed in {time.time()-start_time} seconds.")
return {'x': x_out, 'cov': x_cov, 'samples': x_all, 'resList': res_list}
return {'x': x_out, 'cov': x_cov, 'samples': x_all, 'resList': res_list, 'OptimizeResult': sol}
def get_constants(self, model, ppmlim, baseline_order, metab_groups):
"""collect constants for forward model"""
......
......@@ -95,13 +95,13 @@ def synthetic_spectra_from_model(config_file,
'conc': concentrations}
def_vals_int = {}
for key in defined_vals:
if isinstance(defined_vals[key], str) \
and defined_vals[key] in std_vals:
def_vals_int[key] = std_vals[defined_vals[key]]
else:
def_vals_int[key] = defined_vals[key]
if defined_vals is not None:
for key in defined_vals:
if isinstance(defined_vals[key], str) \
and defined_vals[key] in std_vals:
def_vals_int[key] = std_vals[defined_vals[key]]
else:
def_vals_int[key] = defined_vals[key]
rng = np.random.default_rng()
syn_free_params = []
......@@ -257,6 +257,10 @@ def synthetic_spectra_from_model(config_file,
bw=bandwidth,
nucleus='1H',
basis=empty_mrs._basis)
# Sort out basis scaling
mrs_out._indept_scale = empty_mrs._indept_scale
mrs_out._scaling_factor = empty_mrs._scaling_factor
mrs_out.ignore = empty_mrs.ignore
coils_mrs.append(mrs_out)
mrs_list.append(coils_mrs)
else:
......@@ -265,7 +269,10 @@ def synthetic_spectra_from_model(config_file,
bw=bandwidth,
nucleus='1H',
basis=empty_mrs._basis)
# Sort out basis scaling
mrs_out._indept_scale = empty_mrs._indept_scale
mrs_out._scaling_factor = empty_mrs._scaling_factor
mrs_out.ignore = empty_mrs.ignore
mrs_list.append(mrs_out)
return mrs_list, vm, syn_free_params
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