# Contents of .VP File

**URL:** <https://discourse.slicer.org/t/contents-of-vp-file/10783>\
**Category:** Development\
**Tags:** volume-rendering\
**Created:** [March 23, 2020, 8:00am UTC](https://discourse.slicer.org/t/contents-of-vp-file/10783 "2020-03-23T08:00:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bernland](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/bernland/32/6331_2.png) [@bernland](https://discourse.slicer.org/u/bernland)\
**Post date:** [March 23, 2020, 8:00am UTC](https://discourse.slicer.org/t/contents-of-vp-file/10783/1 "2020-03-23T08:00:52Z")

</div>

I created a MIP in Slicer, the contents of the .VP file are as follows:

```
1: 1
2: 0
3: 1
4: 0.2
5: 0
6: 1
7: 8 -94 0 4.37255859375 0 322.636962890625 1 2706 1
8: 4 -94 1 161 1
9: 16 -94 0 0 1 4.37255859375 0 0 1 322.636962890625 0 0 1 2706 0 0 1

```

I would now like to use the exact same MIP settings in plain **Pyhon** , however, I can’t seem to be able to achieve the same results. I was able to extract Scalar Opacity Mapping from line 7 and Scalar Color Mapping from line 9:

**Scalar Opacity Mapping**

```
self.opacityTransferFunction.AddPoint(-94.0, 0.0)
self.opacityTransferFunction.AddPoint(4.37, 0.0)
self.opacityTransferFunction.AddPoint(322.64, 1)
self.opacityTransferFunction.AddPoint(2706.0, 1)

```

**Scalar Color Mapping**

```
self.colorTransferFunction.AddRGBPoint(-94.0, 0.0, 0.0, 1.0)
self.colorTransferFunction.AddRGBPoint(4.37, 0.0, 0.0, 1.0)
self.colorTransferFunction.AddRGBPoint(322.64, 0.0, 0.0, 1.0)
self.colorTransferFunction.AddRGBPoint(2706.0, 0.0, 0.0, 1.0)

```

What’s encoded in the other lines and is there any piece of (Python) code that reads in a .VP file and applies its settings?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 23, 2020, 1:40pm UTC](https://discourse.slicer.org/t/contents-of-vp-file/10783/2 "2020-03-23T13:40:40Z")

</div>

Format of volume property file is available here: [https://www.slicer.org/wiki/Documentation/Nightly/Modules/VolumeRendering#Format\_of\_Volume\_Property\_.28.vp.29\_file](https://www.slicer.org/wiki/Documentation/Nightly/Modules/VolumeRendering#Format_of_Volume_Property_.28.vp.29_file)

Since the file format is simple text file with fixed number of rows and space-separated values in each row, its parsing does not require any special technique.

In Slicer’s Python environment you may use vtkMRMLVolumePropertyStorageNode to read/write the text file content to/from a vtkMRMLVolumePropertyNode or use convenience functions in slicer.util:

```python
# read node from file
volumeProp = slicer.util.loadNodeFromFile(filename, 'TransferFunctionFile')
# write node to file
slicer.util.saveNode(volumeProp, filename)

```
