Flip rows in 3d matrix

I am trying to quickly flip all odd numbered columns (y planes) in a huge (1024,1024,200) matrix.

Sadly, the best solution I've come up with so far involves way too many imagetransforms and is way too slow.
1) Duplicate the matrix (already off to a bad start)
2) Delete all even columns from one matrix and the odds from the other: iterate imagetransform removeyplane
3) on the odd matrix: iterate imagetransform flipcols (could rotate the matrix to avoid iterating and speed up a bit)
4) iterate imagetransform getplane on the odds and imagetransform insertplane on the evens

There has to be a more efficient way to do this. Any ideas?

If it helps:
The data is acquired as a one dimension wave with (1024*1024*200) rows and I redimension it to (1024,1024,200).

I just tried the following:
make/O/N=(1024 * 1024 * 200) wave0
wave0 = p // populate with some data - this takes a long time
redimension/N=(1024, 1024, 200) wave0
make/O/N=(1024, 1024, 200) wave1
wave1[][][] = (q & 1) ? wave0[1023 - p][q][r] : wave0[p][q][r] // reverse odd columns

The last step took about 30 seconds on my rather old PC. I don't know how this timing compares with other methods?

HTH,
Kurt
I think you can change the last statement to:
wave1[][1,1023;2][] = wave0[1023 - p][q][r]


This should set only odd columns starting from column 1.

See the discussion starting with "You can specify not only a range but also a point number increment" here:
DisplayHelpTopic "Indexing and Subranges"
hrodstein wrote:
I think you can change the last statement to:
wave1[][1,1023;2][] = wave0[1023 - p][q][r]


This should set only odd columns starting from column 1.


That is clever!
A quick test shows this is about 3 times faster than the ?: statement.
Since you are asking about speed I assume that you have to execute this sort of task more than once. My advice is to follow a different route:

1. Use WaveTransform with the keyword flip. The result is then stored in W_flipped.
WaveTransform flip srcWave


2. Create two waves of dimensions (1024*1024*200) say w1 and w2.
Make/N=(1024,1024,200) w1,w2


3. Set w1 to 1 for odd cols points and 0 otherwise.
w1=mod(q,2)==1 ? 1:0
w2=mod(q,2)==1 ? 0:1


4. Set w2 to 1 for even cols points and 0 otherwise.

5. Execute
MatrixOP/O result=srcWave*w1+W_flipped*w2


HTH,

A.G.
WaveMetrics, Inc.
Igor,

Thanks a lot.

Perhaps I misunderstood something but it seems that
WaveTransform flip
isn't giving the expected rotation of the 3d volume.

I replaced it with:

matrixop/o m_flipped = transposeVol(srcWave, 3)
imagetransform flipplanes m_flipped
matrixop/o m_flipped2 = transposeVol(m_flipped, 3)