perc_SD from Results Class

Running fsl_mrs.utils.fitting.fit_FSLModel and then trying to extract perc_SD from results except I get the following error: 'ValueError: operands could not be broadcast together with shapes (34,) (33,) '.

I have parced the macromolecules as a separate group. Creatine and phosphocreatine are combined and was wondering if this is why the crlb numpy array and the params array are different sizes.


Hi @daniel,

Need a bit more info as to what code you are trying to run and please provide the full trace back.

I’m trying to obtain percentage percentage standard deviations from a results class, I’ve obtained from single spectra fitting

res_1 = fitting.fit_FSLModel(avg_1,**Fitargs)

ValueError Traceback (most recent call last)
Cell In[33], line 1
----> 1 res_1.perc_SD()

File ~/miniconda3/envs/fsl_mrs_env/lib/python3.9/site-packages/fsl_mrs/utils/, in FitRes.perc_SD(self)
196 “”“Returns the percentage standard deviation”“”
197 with np.errstate(divide=‘ignore’, invalid=‘ignore’):
→ 198 perc_SD = np.sqrt(self.crlb) / self.params * 100
199 perc_SD[perc_SD > 999] = 999 # Like LCModel :slight_smile:
200 perc_SD[np.isnan(perc_SD)] = 999

ValueError: operands could not be broadcast together with shapes (33,) (32,)

That should all work (though quite clearly it doesn’t). Could you send me a minimal piece of data and script to replicate? If that’s not possible then maybe we can have a quick call to figure it out