Matlab: Reading specific images and parts of image frames from FITS file with fitsread

In Matlab, it is possible to read specific frame(s) from a FITS file.

That is, you can read frames one at a time from a large multi-frame FITS file in MATLAB. You can also “slice” FITS files to avoid loading the whole file in Octave, but at present the syntax is slightly different. Here’s an example that reads each frame of a 4096-frame FITS file, with each frame being 256x256 pixels.

for i = 1:4096
    currFrame = fitsread('myFile.fits','PixelRegion',{[1 256],[1 256],i);
    imagesc(currFrame)
    pause(0.05)
end