MATLAB: 3.4gb .raw file in MATLAB

raw filesxyz

Hello
I'm trying to read in a 3D .raw file into MATLAB. The file was obtained from Volume Graphics studio max, a licensed program used for CT scans. We are only interested in the middle 2D plane of data, or in other words the middle 2D array. This may be a horizontal or vertical slice. There is no need to read in all of the data.
Is there a way to only read in one column of the data and then use that to find the middle value? The size is N x N x N but we do not know what N is.
This is all information I have. Any suggestions?

Best Answer

Unfortunately, Volume Graphics does not choose to put its manuals online. Fortunately someone else put one of their manuals online.
Page 250 of http://www.esrf.eu/files/live/sites/www/files/UsersAndScience/Experiments/Imaging/ID19/microtomography/vgstudiomax.pdf describes RAW files in section 5.2.2, indicating the data order has x vary most quickly, then y, then z. There is no indication of whether there is a file header; I would expect there to be one.
You would fopen() the file and read the header.
Then for a horizontal slice, you would fseek() forward by N * N * (bytes per element) * (zplane - 1), after which you would fread(fid, [N, N], PRECISION) where PRECISION is '*uint8' or '*uint16' or as required for your data.
For a vertical slice, you would fseek() forward by N * (bytes per element) * (yplane - 1), after which you would fread(fid, [1, N], PRECISION) and then you would fseek forward by N * (N-1) * (bytes per element) and fread() again, and keep repeating that until the entire slice was read.
If the slice is in the other direction, I would have to work it out but I suspect you could make use of the "skip" option.
I suspect, though, that what might be easiest is to memmapfile() and then index into it.
Related Question