First, let us open the MINC file:
handle = openimage ('examples/yates_19445.mnc');Now, we may wish to find out some basic data about the MINC file. Try the following (note that we will need nf, the number of frames, below):
ns = getimageinfo (handle, 'NumSlices') nf = getimageinfo (handle, 'NumFrames') getimageinfo (handle, 'ImageSize')Note that for the study yates_19445, nf will be 21. However, it is a good idea to always use getimageinfo to find the number of frames rather than assuming that it will always stay the same for a particular type of study.
Now, let us read in the frame lengths and mid-frame times:
FrameLengths = getimageinfo (handle, 'FrameLengths'); MidFTimes = getimageinfo (handle, 'MidFrameTimes');Note that FrameLengths and MidFTimes are both column vectors. This will be important when performing matrix arithmetic with them.
Now, we read in all frames for one slice-slice 8 in this case, although you can work with whatever slice you like:
slice = 8; PET = getimages (handle, slice, 1:nf);Note that this is the step where MATLAB uses up large amounts of memory. If you execute the MATLAB whos command now, you will see that MATLAB's variables alone are taking up nearly 3 megabytes of memory. However, the entire MATLAB workspace generally takes up considerably more memory than is reported by whos, because of MATLAB's overhead and inefficient memory management scheme.