title: 4D matrix operations in Matlab
body: <p>I have a set of 4D matrices in Matlab. The first three dimensions are spatial, the last is temporal. That means each voxel is a time series. If Img is the 4D image, Img(x,y,z,:) is the time series of voxel with coordinate (x,y,z).</p>
  
  <p>Now I want to normalize (zero mean and unit variance) each time series of the image. How can I do this? Perhaps with <code>zscore(Img,[],4)</code>?</p>
  
  <p>Second, I want to concatenate the time series of all images. Let's say Img1, Img2, Img3,....Imgn are the 4D images. For each voxel I want to concatenate the time series over all images so that in the end I have one 4D image with the same spatial but extended temporal dimension. So let's say the voxel has the coordinate (x,y,z), then the concatenated time series would be <code>[squeeze(Img1(x,y,z,:)); squeeze(Img2(x,y,z,:));....;squeeze(Imgn(x,y,z,:))]</code>. This should be done for all voxels.</p>
  
  <p>How can I do this? It could be done with for loops but this is not efficient.</p>