After performing some analysis, it is often desirable to write the results to a new MINC file. Currently, we only have a single image to write, so we will create a MINC file with 1 slice and no frames (because of the integration across frames, time is no longer a variable). We use EMMA function newimage as follows:
new_handle = newimage ('yates_summed.mnc', [0 1], ... 'examples/yates_19445.mnc');To write our single image to slice 1 of the new MINC file, we enter:
putimages (new_handle, PETsummed2, 1);
Alternately, we could create a MINC file with a full 15 slices, and loop through the entire original study to sum every slice. MATLAB will allow us to enter a for loop interactively, so enter the following (note that the newimage call will overwrite yates_summed.mnc; you may want to use a different name or copy the one-slice version):
closeimage (new_handle); new_handle = newimage ('yates_summed.mnc', [0 ns], ... 'examples/yates_19445.mnc'); for slice = 1:ns PET = getimages (handle, slice, 1:nf); PETsummed = trapz (MidFTimes, PET')'; putimages (new_handle, PETsummed, slice); end closeimage (new_handle);