For a Slicer module I am developing, the user selects which image they want to use as an input by selecting its vtkMRMLScalarVolumeNode from a dropdown menu.
Then, the user presses a button to colorize the tumor on that image. Pressing this button calls a function that takes the 3D numpy array from the vtkMRMLScalarVolumeNode, creates a 4D numpy array where the 4th dimension contains RGB color values, converts the 4D numpy array to: np.dtype([(‘R’, ‘u1’), (‘G’, ‘u1’), (‘B’, ‘u1’)]), and saves the final 3D RGB image as a NIFTI file.
Then the user can drag the NIFTI file into Slicer and see something like the image below.
Instead of creating a .nii file that contains both the background image from the input vtkMRMLScalarVolumeNode and a blue/green/purple region on top of the tumor, I would prefer to continue displaying the input image in its original vtkMRMLScalarVolumeNode and display the blue/green/purple region as a separate object that is overlayed on top of the input image. In addition, I would like this blue/green/purple region to remain visible even after the user selects a different vtkMRMLScalarVolumeNode from the dropdown menu.
Is it possible to make this change that I want, and if so, could you please include some example lines of code that would help me figure out how to incorporate this change into my Python scripted module?