MINC/Tutorials/PythonExample

The pyminc version of hello world.
Keeping with other tutorials on how to program with the MINC toolkit, here's a simple example for how to open a volume, add one to every voxel, then write it out again. This being python, the code is nice and short!

Here's what the code does. The first bits are the imports of different modules - the one non-standard module is pyminc.volumes.factory. Most all creation of pyminc volume instances is done through a set of factory methods. They are:

The next line of the code assigns the output files data to be the input files data plus 1. Every pyminc volume has a data attribute, which is a numpy array. Note that the data is not actually read until the data attribute is accessed. The last bits then write the output file to disk and closes both volumes.