You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of R2024a, MATLAB's sub2ind function throws an error when it encounters NaNs, presumably because of new functionality (see: https://www.mathworks.com/help/matlab/ref/sub2ind.html for more information). This function previously did not check for NaNs in prior iterations of MATLAB (R2023b and earlier), and MathWorks' current documentation makes no mention of this additional requirement.
To replicate: open any mrLoadRet session in MATLAB R2024a or later
Error stack:
Error using sub2ind (line 71)
Out of range subscript.
Error in mrSub2ind (line 28)
linear = sub2ind(dims,x,y,z);
Error in refreshMLRDisplay>getROIImageCoords (line 702)
baseCoordsLinear = mrSub2ind(baseDims,baseCoordsHomogeneous(1,:),baseCoordsHomogeneous(2,:),baseCoordsHomogeneous(3,:));
Error in refreshMLRDisplay>displayROIs (line 824)
[x y s] = getROIImageCoords(view,roi{r}.roiBaseCoords,sliceIndex,baseNum,baseCoordsHomogeneous,imageDims);
Error in refreshMLRDisplay>dispBase (line 544)
[roi,v] = displayROIs(v,hAxis,slice,sliceIndex,baseNum,base.coordsHomogeneous,base.dims,rotate,verbose);
Error in refreshMLRDisplay (line 152)
[v img base roi overlays curSliceBaseCoords] = dispBase(gui.axis,v,baseNum,gui,true,verbose);
Error in mrOpenWindow (line 207)
refreshMLRDisplay(view.viewNum);
Error in mrLoadRet (line 51)
v = mrOpenWindow('Volume',mrLastView);
Relevant change from sub2ind:
R2024a: sub2ind accepts mix of scalars and vectors for subscript inputs sub2ind now leverages scalar expansion and accepts a mix of scalars and vectors for subscript inputs. For example, sub2ind(sz,[1 2 3],2) is now the same as sub2ind(sz,[1 2 3],[2 2 2]). Previously, the subscript inputs were required to be the same size.
Relevant code from sub2ind (lines 69-72):
if ~isempty(v) && (anynan(v) || min(v,[],'all') < 1 || max(v,[],'all') > siz_i)
% Verify subscripts are within range
error(message('MATLAB:sub2ind:IndexOutOfRange'));
end
As a result, the functionality of mrSub2ind no longer works in versions of MATLAB starting from R2024a, due to assigning x(badCoords), y(badCoords), and z(badCoords) a value of NaN.
As of R2024a, MATLAB's
sub2ind
function throws an error when it encounters NaNs, presumably because of new functionality (see: https://www.mathworks.com/help/matlab/ref/sub2ind.html for more information). This function previously did not check for NaNs in prior iterations of MATLAB (R2023b and earlier), and MathWorks' current documentation makes no mention of this additional requirement.To replicate: open any mrLoadRet session in MATLAB R2024a or later
Error stack:
Relevant change from
sub2ind
:Relevant code from
sub2ind
(lines 69-72):As a result, the functionality of
mrSub2ind
no longer works in versions of MATLAB starting from R2024a, due to assigningx(badCoords)
,y(badCoords)
, andz(badCoords)
a value of NaN.Relevant code from
mrSub2ind
(lines 21-28):The text was updated successfully, but these errors were encountered: