0001 function data = batch_shuffle_check(dataroot, sinfo, outfstub, epidir)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 if nargin < 4
0034 epidir = 'epi';
0035 end
0036
0037 if nargin < 3
0038 outfstub = 'shuffle_check';
0039 end
0040
0041 PRINT_TO_FILE = 1;
0042
0043 proc_sub = 1:length(sinfo);
0044 nsub = length(proc_sub);
0045
0046 for isub = 1:nsub
0047 sub_idx = proc_sub(isub);
0048
0049 runs = sinfo(sub_idx).use_runs;
0050 nruns = length(runs);
0051
0052 figure(1), clf
0053
0054 for irun = 1:nruns
0055 run_idx = runs(irun);
0056 epi_dir = fullfile(dataroot,sinfo(sub_idx).id,epidir,sprintf('run%d', run_idx));
0057 P = spm_get('Files',epi_dir,'*.img');
0058 nvol = length(P);
0059
0060
0061 V = spm_vol(deblank(P(1,:)));
0062 nslice = V.dim(3);
0063
0064 data{sub_idx,irun} = zeros(nslice,nvol);
0065 for ivol = 1:nvol
0066 fprintf('Subject: %s, Run %d, Vol %d\n', sinfo(sub_idx).id,run_idx, ivol)
0067 V = spm_vol(deblank(P(ivol,:)));
0068 for islice = 1:nslice
0069 tmp = spm_slice_vol(V,spm_matrix([0 0 islice]),V.dim(1:2),0);
0070 data{sub_idx,irun}(islice,ivol) = sum(tmp(:));
0071 end
0072 end
0073
0074 subplot(nruns,1,irun);
0075 imagesc(data{sub_idx,irun})
0076 set(gca,'xtick',[0:10:nvol],'xticklabel','')
0077
0078 tick_locs = get(gca,'xtick');
0079 use_ticks = 1:5:length(tick_locs);
0080 for itick = 1:length(use_ticks)
0081 tick_val = tick_locs(use_ticks(itick));
0082 text(tick_val,nslice+1,num2str(tick_val),'rotation',-90)
0083 end
0084
0085 grid
0086 title(sprintf('Subject: %s, Run %d', sinfo(sub_idx).id,run_idx))
0087
0088 end
0089
0090 if PRINT_TO_FILE
0091 if isub ~= 1
0092 append_str = '-append';
0093 else
0094 append_str = '';
0095 end
0096 print('-dpsc',append_str,sprintf('%s.ps',outfstub))
0097 end
0098 end
0099
0100 if PRINT_TO_FILE
0101 unix_str = sprintf('ps2pdf %s.ps %s.pdf', outfstub,outfstub);
0102 unix(unix_str);
0103 end