Save a 3D matrix in Nifti (.nii) format or .csv

176 views
Skip to first unread message

g.na...@gmail.com

unread,
Apr 12, 2021, 2:44:32 AM4/12/21
to idl-pvwave

Hi,

I export from IDL two .dat files which are 3D and 4D float matrices respectively. 

I would like to save these .dat files in Nifti format or csv format but I don’t know how to do that. 

I need to do some image-processing in Matlab. I tried many different ways to load the exported IDL .dat data in Matlab without success. 

Thus, I thought to save the IDL output data in a different format. I read my .dat file in the format of a 3D matrix using the following  code:

;Define image dimensions and file name

Image = ‘Mydata.dat’

Nx = 145

Ny = 145

Nt = 249

;specify the .dat file path 

Path = ‘C:Users\’

;create an empty array 

Data = fltarr(Nx,Ny,Nt)

openr, 1, path + Image

readu, 1, data

close, 1

After loading the data as a 3D matrix I would like to save it either in Nifti (.nii) format or csv. Any help would be greatly appreciated.

I am using IDL version 6.4. 

Thank you in advanced!

Yuxi Pang

unread,
Apr 16, 2021, 9:51:13 AM4/16/21
to idl-pvwave
You should load IDL-saved data matrix into Matlab when the proper data type and data size were provided. It is not necessary to save your data into Nifti or CSV.

If you are still struggling, send me your data and I will take a look for you.   

Reply all
Reply to author
Forward
0 new messages