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 if you already executed the above code, you
should use a new filename in place of yates_summed.mnc or
delete the old one--newimage will die if you try to overwrite
an existing file):
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);