Home > fmri > utils > shuffle_check.m

shuffle_check

PURPOSE ^

data = shuffle_check(epi_dir, file_stub, nslice);

SYNOPSIS ^

function data = shuffle_check(epi_dir, file_stub, nslice);

DESCRIPTION ^

 data = shuffle_check(epi_dir, file_stub, nslice);

 Checks for shuffling of slices in EPI images.

 You must specify:
  1) the EPI directory, e.g. '/data2/modfmri/28jan02PJ/epi/run1'
  2) the root of the name of the EPI files, e.g. 'r28jan02PJ'
  3) the number of slices, e.g. 27

 A color image will be displayed which shows the sum activity in each slice
 through time.  The color of each slice primarily reflects the number of
 voxels in that slice with signal.  Thus, shuffled or duplicated slices appear
 as a vertical line of shuffled colors.

 Slice shuffling may result in an erroneous data mask that SPM and most other
 programs depend on to decide which slices to analyze.  Thus, it is best to
 fix these problems (see replace_vols.m)

 For scripts that automate this process over multiple subjects and multiple
 runs, see check_slice_intensity.m

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function data = shuffle_check(epi_dir, file_stub, nslice);
0002 % data = shuffle_check(epi_dir, file_stub, nslice);
0003 %
0004 % Checks for shuffling of slices in EPI images.
0005 %
0006 % You must specify:
0007 %  1) the EPI directory, e.g. '/data2/modfmri/28jan02PJ/epi/run1'
0008 %  2) the root of the name of the EPI files, e.g. 'r28jan02PJ'
0009 %  3) the number of slices, e.g. 27
0010 %
0011 % A color image will be displayed which shows the sum activity in each slice
0012 % through time.  The color of each slice primarily reflects the number of
0013 % voxels in that slice with signal.  Thus, shuffled or duplicated slices appear
0014 % as a vertical line of shuffled colors.
0015 %
0016 % Slice shuffling may result in an erroneous data mask that SPM and most other
0017 % programs depend on to decide which slices to analyze.  Thus, it is best to
0018 % fix these problems (see replace_vols.m)
0019 %
0020 % For scripts that automate this process over multiple subjects and multiple
0021 % runs, see check_slice_intensity.m
0022 %
0023 
0024 % v.1.0 06/20/02 Petr Janata
0025 % v.1.1 08/14/02 PJ -- Fixed occassionally incorrect determination of nvol.
0026 %                      Removed requirement to specify nslice
0027 
0028 
0029 if nargin < 2
0030   error(['Too few parameters. You must at least specify the EPI directory and root' ...
0031     ' name'])
0032 end
0033 
0034 P = spm_get('Files',epi_dir,sprintf('%s*.img', file_stub));
0035 nvol = size(P,1);
0036 
0037 fprintf('Analyzing %d volumes beginning with %s in directory %s\n', nvol, file_stub, epi_dir);
0038 
0039 if (nargin < 3)
0040   V = spm_vol(deblank(P(1,:)));
0041   nslice = V.dim(3);
0042 end
0043 
0044 data = zeros(nslice,nvol);
0045 for ivol = 1:nvol
0046   V = spm_vol(deblank(P(ivol,:)));
0047 
0048   fprintf(' .')
0049   for islice = 1:nslice
0050     tmp = spm_slice_vol(V,spm_matrix([0 0 islice]),V.dim(1:2),0);
0051     data(islice,ivol) = sum(tmp(:));
0052   end % for islice=
0053 end % for ivol=
0054     
0055 fprintf('\n')
0056 
0057 imagesc(data)
0058 set(gca,'xtick',[0:10:size(data,2)])
0059 xlabel('Volume')
0060 ylabel('Slice')
0061 title(sprintf('%s/%s*.img',epi_dir, file_stub))

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003