[MINC-users] Quick way to flip data in a MINC file

Jon Pipitone jon at pipitone.ca
Wed Sep 23 05:46:44 EDT 2015


Hey Andrew,

My go-to these days for minc/hdf5 file manipulation is python/numpy, so
you could try that. Using Jason's pyminc interface, do something like: 

    from pyminc.volumes.factory import *
    import numpy as np

    infile = volumeFromFile('input.mnc')
    outfile = volumeLikeFile('input.mnc', 'output.mnc')

    outfile.data = np.copy(infile.data[::-1,...]) # flips first dim

    outfile.writeFile()
    outfile.closeVolume()

Untested, but should save you time on file I/O at least. I used np.copy
there because IIRC pyminc doesn't like numpy views (which is what you
get when you do unfancy indexing operations like this) but I could be
wrong. 

Jon. 

p.s. I've used volflip many many times. Thank you!

On 09/23, Andrew Janke wrote:
> Does anyone have any bright ideas/hackery of how to flip data (for a
> dimension) in a MINC file? Here is what I currently do:
> 
>    https://github.com/BIC-MNI/minc-widgets/blob/master/volflip/volflip#L84
> 
> This takes about 2.5 minutes for a average sized volume (700x272x187).


More information about the MINC-users mailing list