MATLAB 2025a Volshow Data and AlphaData Size Error

I have both MATLAB 2024b and 2025a installed on my Windows 10 system. I am using the following codes to generetae 3D images. The size of both the Data volume pdSNRVolumedBCropped and AlphaData volume pdAlphaTissueVolumeCropped are 512x512x548.
viewer = viewer3d(BackgroundColor="white",BackgroundGradient="off", ...
CameraZoom=1.1028622, CameraPosition = [1.0890e+03,-1.2065e+03,-157.0506], ...
CameraUpVector = [-0.087,-0.9957,0.0295], Box=true);
volshow(pdSNRVolumedBCropped, Parent = viewer, ...
DisplayRange = [dSNRScale1 dSNRScale2], AlphaData = pdAlphaTissueVolumeCropped, ...
RenderingStyle = 'VolumeRendering', Colormap = flipud(gray), ...
Transformation = tformDisplay);
The above code works perfectly in MATLAB 2024b. However, it gives the following error in MATLAB 2025a.
Error using images.ui.graphics.Volume/validateData
'AlphaData' must match the size [0 0 0] of 'Data'.
Error in images.ui.graphics.Volume/set.AlphaData
Error in images.ui.graphics.internal.AbstractContainer/set
Error in images.ui.graphics.GraphicsContainer
Error in images.ui.graphics.Volume
Error in volshow (line 30)
obj = images.ui.graphics.Volume(viewer, remainingInputs{:}, 'Data', V);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in VisualizeInjuryWithLabel (line 226)
volshow(pdSNRVolumedBCropped, Parent = viewer, ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If I remove the AlphaData argument, then the code does not give any error.
I tried to set AlphaData = pdSNRVolumedBCropped*0 which makes both the Data and AlphaData the same size of 512x512x548. But in that case as well, I am getting the same error.

 Accepted Answer

OP here. I have contacted MATLAB Customer Support. This is an issue with the “volshow” function in MATLAB R2025a. They have notified the development team of this issue, and they are considering it to be fixed in a future MATLAB release.
The customer support has suggested me the following workaround.
Store the output of “volshow” in a variable and modify the “AlphaData” property after it has been created as follows
volOut = volshow(pdSNRVolumedBCropped, Parent = viewer, ...
DisplayRange = [dSNRScale1 dSNRScale2], ...
RenderingStyle = 'VolumeRendering', Colormap = flipud(gray), ...
Transformation = tformDisplay);
volOut.AlphaData = pdAlphaTissueVolumeCropped;
I have tried this and it works. Hope it helps others facing the same problem.

More Answers (0)

Categories

Products

Release

R2025a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!