MatlabBridge - empty volume by default instead of no volume

Dear 3D-Slicer community,

I am developing an extension using MatlabBridge which involves loading 3D and 4D images into 3D-Slicer. I adapted the automatically generated Matlab function to do so, but unfortunately it only works when I select “Create new volume” in the dropdown IO > “Create new volume” (see Figure 2). I have multiple volumes that need to be displayed by 3D-Slicer and I don’t want the user to click through each volume and select “Create new volume”. When I leave the setting at “None” (default, see Figure 1), the code returns the following error:

Is there a way to create an empty volume by default? Maybe by modifying the xml-file or the Matlab function? When using “Create new volume”, the struct “inputParams.outputvolume” contains a path to a nrrd-file and a params-file which are afterwards created by the function “cli_imagewrite”. I tried to set similar paths (before calling “cli_imagewrite”) when using the setting “None” for “Output volume”. But this does not work either.

Many thanks in advance for your help.

Figure 1 - not working setting:

Figure 2 - working setting:


function outputParams=test2(inputParams)
outputParams.min=0; % just to prevent no outputParams given error

load("/home/user/my_mask.mat") % loads the matrix "mask"

cli_imagewrite(inputParams.outputvolume, img);

By selecting a volume, the user indicates that he is interested in computing that output. Currently, we don’t have an option to automatically create a required output node if the user has not created one. Would you mind creating a feature request in the Slicer issue tracker to keep track of the ideaI?

Done: MatlabBridge - option to set output node as default instead of "None" · Issue #6804 · Slicer/Slicer · GitHub