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

Andrew Janke a.janke at gmail.com
Wed Sep 23 21:44:51 EDT 2015


Hi Jon,

Thanks for the pyminc snippet, I've given it a try and the speed is
(as expected) better, still not as fast as I'd like but getting there.

a


On 23 September 2015 at 19:46, Jon Pipitone <jon at pipitone.ca> wrote:
> 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).
> _______________________________________________
> MINC-users at bic.mni.mcgill.ca
> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users


More information about the MINC-users mailing list