I am attempting to import a .vff file I have created from a .mat cube (170x170x182), which is an optical CT reconstruction (through matlab iradon). I am using matlab file to convert my .mat file into .vff. I can open this new .vff file in MicroView (only if I choose the “rescale” option present in the mat_to_vff.m file (otherwise it is black and apparently only 3 slices). I can see in MicroView the image information is present (eg Title, patient position, modality, voxel size). When I attempt to import into 3DSlicer I see 3 related errors of:
“LoadVffFile: Incorrect parameters or required parameters that were not set, vff file failed to load. The required parameters are: rank, type, format, bits, bands, size, spacing, origin, rawsize, data scale, data offset, and title.”
"Warning: In D:\D\P\S-0-E-b\SlicerRT\VffFileReader\Logic\vtkSlicerVffFileReaderLogic.cxx, line 435
vtkSlicerVffFileReaderLogic (0000026065493930): LoadVffFile: Empty filter value! The value must be separated from the parameter with an ‘=’ "
"LoadVffFile: The value entered for the format must be slice.
LoadVffFile: A string was not entered for Handle Scatter. The value must be separated from the parameter with an ‘=’. The value entered for Handle Scatter must be factor."
I’m assuming the first error can be solved by manually entering some meta data (not sure how) but the other two I am stumped.
This was tested with 4.10.2 and 4.11.0 (the errors are the same for both)
Am I correct in assuming there is a way to add in this missing data to the VFF itself (akin to metadata to a DICOM) so it complies with Slicer? I’m not sure I understand how to/am comfortable with editing the actual code slicer is running on. If I were to edit the script per your suggestion, would I have to compile and run slicer from the source code or is there a way to edit this from within the installed application? Thank you!
What I’d do if I didn’t want to touch the reader code in SlicerRT is that I’d
Manually edit a VFF file outputted by your matlab converter script so that the missing metadata indicated by the error messages are in the header so that the VFF is valid as far as SlicerRT is concerned, then
Edit the matlab converter script to add those metadata so you don’t need to add them manually for each volume
I was able to change the Matlab converter to supply the required information and the VFF now loads into Slicer with no errors, however it appears unusable. It loads into MicroView fine, though. I’ve included two pictures to compare them.
It may be a data range issue. We tested the VFF reader with only one manufacturer, as it was the only one available and the one used by the project for which it was developed. Further work may be needed to support your VFF format.
Your data is originally not VFF, but Matlab. Why have you chosen to convert to a non-standard file format such as VFF? If you convert it to nrrd for example Slicer would be able to load it without problems as it is much more widely supported.
NRRD is a simple, capable, and very widely used file format. You can find readers and writers for it in all programming environments. Do not use VFF unless you have absolutely no other option.
nrrdwrite.m in the SlicerMatlabBridge repository should work well. See detailed description and usage examples in its documentation. If you have any questions about it then let us know. If you want, you can use any other nrrd writer implementation in Matlab (there are several), but I would recommend the one in the SlicerMatlabBridge repository because it supports 4D data and allows easy access to image geometry (IJK to LPS transform).
As a side note, it could make sense to make the move from Matlab to Python (unless only a few years left of your professional career, then you may survive with sticking to Matlab), because any time that you spend on dealing with a declining, proprietary technology is time that you don’t spend on learning much more useful and relevant skills.
I see. I gravitated towards VFF as it was the example data given in the tutorial and is the first option listed when a user hovers over “Load non-DICOM data” in the slicelet (assumed it was the preferred format). I found a different nrrd writer here which has worked. The linked nrrdwrite.m gives me dot indexing errors when I try to set the .mat cube I have as the img in order to run the file.
I’m using Matlab as it is part of the research I’m working on and I’m in my second year of my MS so I do not have time to switch the entire process over, as you mention.
I may keep trying to make the initial nrrdwrite.m work but so far this seems to be working…thank you for all the help and guidance!