python - How can I open a 3D .npy file in R or MATLAB? -


i have .npy files of shape[512, 512, x] x going maximally 400. in these arrays (is right term? i'm not sure right terminology), there floating point numbers between 0 , one. grey levels of noise image. image 512x512 pixels , per npy file have different number of images saved.

i computations noise images have been unable import arrays in r or matlab:

in r tried rcppcnpy - package , got error "unsupported dimension in npyload".

in matlab, tried readnpy - function , got error "this file not appear numpy format based on header." file has no header. function works 2d arrays?

how access 3d-array saved before?

any in matlab or r appreciated!

npy unique numpy file format. , yes, have header block contains information version, dimensions, strides, , dtype.

a quick glance @ readnpy shows relatively new , experimental. check them capabilities.

np.savetxt writes text csv files. used (look @ number of question np.genfromtxt , np.loadtxt), nature of 'paper' 2d - lines of columns. don't know of standard write higher dimensional arrays - reshaping 2d , simplest.

scipy.io.savemat can write matlab compatible .mat files. (and loadmat) capable of reading/writing higher d arrays, , matlab structures , cells. best tested file interchange between numpy , matlab.

a newer matlab save format uses hdf5 files. python h5py package can read , write well. there have been scattering of questions reading type of file produced matlab. python-created hdf5 dataset transposed in matlab

keep in mind matlab dimension ordering equivalent numpy 'f' order.

compare:

xf=np.arange(12).reshape(3,4,order='f')   # saved savemat  >> xf(:).'      # in octave ans =    0   1   2   3   4   5   6   7   8   9  10  11 

without order=f, octave gives

 0   4   8   1   5   9   2   6  10   3   7  11 

and

>> xf xf =    0   3   6   9    1   4   7  10    2   5   8  11  >> x x =    0   1   2   3    4   5   6   7    8   9  10  11 

np.asfortranarray(x) doesn't seem make difference.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -