Loading vector fields (.vf)

Hello everyone,

Is it possible to load vector fields with .vf extension? I tried to load them in the preview release 3D Slicer version but I couldn’t do it.
I would appreciate any help.
Thank you.

What software generated this file?

Can you save it as a NRRD volume file or ITK HDF5 transform file instead? (these are the formats Slicer can read displacement fields from)

If you cannot save your vector field in any of these formats then you can you have a few other options:

  • load the .vf file as a numpy array with some Python package that can read such files, then use slicer.util.updateVolumeFromArray to get it into a volume node (which can then be saved as a .nrrd file)
  • use RawImageGuess extension to generate a NRRD file header (.nhdr file) that Slicer can use to load the volume

Hi Andras, thank you for your response.

I was trying to use the online available dataset popi-model_original_page - Rayonnement, Images, Oncologie (insa-lyon.fr), including CT images, masks and vector fields. I can load them into VV software, but I’m afraid that I cannot save them as a NRRD volume file or another format type. So, I will try to follow your suggestion. Thank you.

The website describes the format of the data. You can use that information in RawImageGuess extension.

1 Like

@marianaslicer Were you able to use RawImageGuess module to load .vf files? If yes, can you please share that? I’m trying to use these .vf data in matlab/python and I don’t see a way to export them from VV software.

Writing a small Python script to read these files could be a nice little project for the upcoming Slicer Project Week. You can still sign up, it is virtual and participation is free of charge. You just need to describe your project in a few sentences and upload it to the project week website; present your project it in 1 minute on the first day, work with experts during the week, and present what you accomplished in 1 minute on the last day.

@lassoan thanks for your suggestion. I was able to write a python script to read these .vf files and convert them to np arrays / .mhd (which works with VV, Slicer)

Great! Would you mind sharing the script so that others can use it, too?

If you want to read these files conveniently (just by drag-and-dropping the file into Slicer) then you can put your script in the load method of a file reader plugin. See example here. I would be happy to help you with this if you are OK to make the script public.

Sure, I would be happy to share the script / add it in file reader plugin. I’m git cloning the slicer repo and adding the code. Not sure on how to test it. Happy to work with you on that.

No need to clone the Slicer repository, as you just add a Python scripted module in an extension. This page should help you getting started and you can ask us here if you have any questions.

Would you please share the script here?I don’t know how to convert it to a format like numpy array or medical image