function [img] = slice3d(method,whichSlice,data) sz = size(data); img = []; if(method==0) img = data(:,:,whichSlice); end if(method==1) for row = 1:sz(1) for col = 1:sz(3) img(row,col) = data(row,whichSlice,col); end end end if(method==2) for row = 1:sz(2) for col = 1:sz(3) img(row,col) = data(whichSlice,row,col); end end end