Fitting water reference error

Dear all, I recently have come across an error in the ‘fitting water reference’ stage of the Ospreyfit analysis pipeline.
The error seems to occur only when I have earlier selected a custom metabolite basis set made up of 26 metabolites (including macromolecules) in the job file. The error does not occur if I select the custom metabolite basis set and then include all metabolites available (36) in the set or if I run it with the metabolites included in the default model plus one extra (glucose)(28 metabolites included). It is drawing from the Philips PRESS, TE 40 set and I am running it through the batch processing commands (Ospreyjob, Ospreyload, Ospreyprocess, Ospreyfit etc), not the gui.
Please see below for the error. Any help/suggestions of what I may be doing, or what is going wrong are appreciated.

Fitting water reference from dataset 1 out of 30 total datasets…

Index in position 2 exceeds array bounds.

Error in fit_resampleBasis (line 48)
specs_interp(:,ll,rr) = interp1(ppmRangeBasis(ppmIsInDataRange), basisSet.specs(ppmIsInDataRange,ll,rr), ppmRangeData, ‘pchip’,
‘extrap’);

Error in fit_runFitWater (line 38)
resBasisSet = fit_resampleBasis(dataToFit, basisSet);

Error in osp_fitWater (line 86)
[fitParamsWater, resBasisSetWater] = fit_runFitWater(dataToFit, basisSet, fitModel, fitOpts);

Error in OspreyFit (line 102)
[MRSCont] = osp_fitWater(MRSCont, kk, ‘ref’);

All the best,
Matt

1 Like

Hi Matt,

Thanks for posting this error. It appears that there is a disconnect between the number of basis functions in the basis set (the second dimension of basisSet.fids) and the looping index for the resampling (ll=1:(basisSet.nMets + basisSet.nMM)). This is probably an easy fix - would you mind describing how you select the custom metabolite basis set as mentioned previously in your post? Do you do anything other than including the cell array of metabolites in the job file?

Thanks,
Georg

1 Like

Hello Georg, thank you for the quick reply.
Ok, so I just select the ‘included metabolites ( custom)’ option when building the job file and select the desired metabolites from the list in the GUI when building the job files. I then save it.
This then produces the following options within the job file:

%%% 1. SPECIFY SEQUENCE INFORMATION %%%

seqType = ‘unedited’;

editTarget = {‘none’};

%%% 2. SPECIFY DATA HANDLING AND MODELING OPTIONS %%%
opts.saveLCM = 1;

opts.savejMRUI = 1;

opts.saveVendor = 1;

opts.fit.method = ‘Osprey’;

opts.fit.includeMetabs = { ‘Asc’ ‘Asp’ ‘Cr’ ‘CrCH2’ ‘GABA’ ‘GPC’ ‘GSH’ ‘Glc’ ‘Gln’ ‘Glu’ ‘Ins’ ‘Lac’ ‘NAA’ ‘NAAG’ ‘PCh’ ‘PCr’ ‘PE’ ‘Scyllo’ ‘MM09’ ‘MM12’ ‘MM14’ ‘MM17’ ‘MM20’ ‘Lip09’ ‘Lip13’ ‘Lip20’};

opts.fit.style = ‘Concatenated’;

opts.fit.range = [0.2 4.2];

opts.fit.rangeWater = [2.0 7.4];

opts.fit.bLineKnotSpace = 0.4;

opts.fit.fitMM = 1;

Below this I would then have the MRS data, water ref files, structural files and a stat.csv file describing the groupings of the data.
All the best,
Matt

1 Like

Hi Matt,

Thank you for your quick response. I think I know where the error comes from - your includeMetabs cell doesn’t include H2O.
Unlike for example LCModel, Osprey doesn’t just integrate the unsuppressed water signal, but does an actual fit to a simulated water signal. (I should say that I’ve done some comparing/testing between integrating and modeling the water signal, and the two estimates correlate with R = 1, so maybe we’ll just opt for the simple integration in future versions). osp_fitWater scans the basis set and selects the basis function corresponding to H2O, but it doesn’t intercept cases where there is no H2O entry, so when it comes to the fit_resampleBasis function, there are no basis functions to resample. (You can check by inserting a break point in line 48, right before the error occurs, and check the dimensions of basisSet.specs. It should be empty).

The solution is to include H2O in the includeMetabs array for now, unless you want to exclude it being fit in the actual metabolite spectra. We’d have to come up with a little more elaborate workaround there. (With decent water suppression/removal, the model shouldn’t allow too much H2O to creep into the fit).

One more question, are you using edited techniques or just straight-up short-TE data? I know the job files have the Concatenated option activated by default, but we aren’t really happy with the modeling performance currently (it’s on our list), so for now I’d recommend sticking with the Separate modeling for edited acquisitions.

Thanks again, happy to help if anything else goes wrong. I’m not sure the trouble-shooting phase is ever going to end. :slight_smile:
Best,
Georg

1 Like

Hi Georg, thanks for the reply. Your fix worked, adding the H20 to the includeMetabs prevented the error and all other functions ran fine.
No, this is not edited data I am running through, its just a standard PRESS sequence. Hoping to put some edited data through it soon :slight_smile:
Thank you for your continued help.
Cheers,
Matt

1 Like

Glad it worked! Excited to see how the editing goes. Let me know if I can help.

Best,
Georg