Implemented as a script by @clsandt (vectorized version):
"""
This scripts reorders spectral maps that have been recorded in snake instead of raster mode
It must be used ustream of a reshape map
Takes the number of rows and columns in the nR and nCol variables
"""
import numpy as np
from copy import deepcopy
print(in_data.X.shape)
out_data = deepcopy(in_data)
#size of the map, the nR and nCol are given by the user
nT=in_data.X.shape[0] #number of spectra in the image
nR=30 #number of rows in the image
nC=26 #number of columns in the image
if nR*nC==nT:
snakeorder=np.arange(nT).reshape(nR, nC)
snakeorder[1::2]=np.fliplr(snakeorder[1::2])
out_data.X=out_data.X[np.ravel(snakeorder)]
else:
print('nb of columns or rows is wrong')
Implemented as a script by @clsandt (vectorized version):