Osprey compatibility with MATLAB R2026a

Hi,

I just got a new PC and attempted to run Osprey (release 2.9.0) on the newest MATLAB version (R2026a). Unfortunately, I encountered multiple issues.

First, I usually saved the PDFs automatically. However, I got the following error message:

Error using validateHandleToPrint
UI components are not supported. To include UI components, use the 'exportapp' function.

Error in validate (line 17)
pj = validateHandleToPrint(pj);
     ^^^^^^^^^^^^^^^^^^^^^^^^^
Error in print (line 37)
pj = validate( pj );
     ^^^^^^^^^^^^^^
Error in saveas (line 140)
        print( h, name, ['-d' dev{i}] )
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in osp_plotModule (line 970)
saveas(out,fullfile(outputFolder,outputFile),'pdf');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in osp_plotAllPDF (line 37)
                osp_plotModule(MRSCont, 'OspreyLoad', kk,[1 1], 'metabolites');
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in OspreyLoad (line 444)
    osp_plotAllPDF(MRSCont, 'OspreyLoad')
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in osp_onLoad (line 35)
    MRSCont = OspreyLoad(MRSCont);
              ^^^^^^^^^^^^^^^^^^^



Error using matlab.ui.internal.controller.uicontrol.UIControlController/triggerActionEvent (line 76)
Error while evaluating UIControl Callback.

I then turned the auto-save option off in the load file and tried to save the PDF from the GUI. I received the following error message:

UI components are not supported. To include UI components, use the 'exportapp' function.

Error in validate (line 17)
pj = validateHandleToPrint(pj);
     ^^^^^^^^^^^^^^^^^^^^^^^^^
Error in print (line 37)
pj = validate( pj );
     ^^^^^^^^^^^^^^
Error in saveas (line 140)
        print( h, name, ['-d' dev{i}] )
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in osp_onPrint (line 1004)
saveas(out,fullfile(outputFolder,outputFile),'pdf');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



Error using matlab.ui.internal.controller.uicontrol.UIControlController/triggerActionEvent (line 76)
Error while evaluating UIControl Callback.

I thought I’d try to continue with the processing of the data to see whether that works. Unfortunately, I got another error message there:

Error using  : 
Colon operands must be real scalars.

Error in OspreyProcess (line 783)
    for kk = 1 : MRSCont.nDatasets
               ^
Error in osp_onProc (line 37)
    MRSCont = OspreyProcess(MRSCont);
              ^^^^^^^^^^^^^^^^^^^^^^



Error using matlab.ui.internal.controller.uicontrol.UIControlController/triggerActionEvent (line 76)
Error while evaluating UIControl Callback.

Based on the error message, I assume this is a compatibility issue with newer MATLAB versions. Also because I had no problems with R2024b. I will download MATLAB R2024b, I’m sure that will work. :slight_smile:

Still, I thought it might be useful to mention this in the forum. Are there plans to adjust Osprey to be compatible with newer MATLAB versions?

Thanks and best,
Laura

Hi Laura,

Yes, MATLAB have completely changed the way their UI toolboxes work in MATLAB2026, and we have not had the resources yet to look at this. I cannot promise that we will be able to do this at this point, but I want to have a go at it for sure.

For now, sticking with 2024b should work, yes.

Thanks,
Georg

@LauraS, I’ve created a workaround for this (see here). But note this will save PDFs as raster and not vector images. Also, I’ve only tested this on one dataset, so consider it as a temporary fix.

I’ve also not tested this using the GUI.

Hi Georg,

Ok, thanks for clarifying! Completely understandable that such an adjustment takes time and might not be top priority. In the end, everything works well with MATLAB2024b and because currently, I have no need to upgrade to a more recent version, I’ll just keep using the older release.

Or implement the workaround posted by Mark. :slight_smile:

Thanks again and best,
Laura

Hi Mark,

Cool, thanks for that! Very useful if/when I need to update to MATLAB’s newer releases!

Best,
Laura

1 Like

Are there two issues going on here? I mean, is the issue with the toolboxes the same as the issue with the MRSCont.nDatasets indexing?

I don’t have the GUI toolboxes installed on my HPC Matlab install, so I was trying to just do command line, but even with that I was running into errors with the MRSCont.nDatasets. I was able to fix it be specifying “MRSCont.nDatasets(1)” instead of “MRSCont.nDatasets” in a couple spots (e.g., in OspreyProcess line 783 as noted above, and also in osp_saveNII.m line 41). This seems to be more consistent with how the nDatasets variable is accessed in most of the rest of the code too. Sorry if this issue has been discussed elsewhere already.

The indexing issue is separate from the figure export, yes.