


Load one or more blocks of data. This script is a effectively a wrapper function that for the routines that actually do the work (SPM nifti routines) The syntax is either: img = prt_load_blocks(filenames, block_size, block_range) just to specify continuous blocks of data or img = prt_load_blocks(filenames, voxel_index) to access non continuous blocks _______________________________________________________________________ Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory


0001 function block = prt_load_blocks(filenames, bs, br) 0002 % Load one or more blocks of data. 0003 % This script is a effectively a wrapper function that for the routines 0004 % that actually do the work (SPM nifti routines) 0005 % 0006 % The syntax is either: 0007 % 0008 % img = prt_load_blocks(filenames, block_size, block_range) just to specify 0009 % continuous blocks of data 0010 % 0011 % or 0012 % 0013 % img = prt_load_blocks(filenames, voxel_index) to access non continuous 0014 % blocks 0015 %_______________________________________________________________________ 0016 % Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory 0017 0018 % Written by A Marquand 0019 % $Id: prt_load_blocks.m 564 2012-07-30 13:24:47Z cphillip $ 0020 0021 if nargin <2 || nargin >3 0022 disp('Usage: img = prt_load_blocks(filenames, block_size, block_range)'); 0023 disp('or') 0024 disp('Usage: img = prt_load_blocks(filenames, voxel_indexes)'); 0025 return; 0026 end 0027 0028 % read the image dimensions from the header 0029 N = nifti(filenames); 0030 dm = size(N(1).dat); 0031 n_vox = prod(dm(1:3)); 0032 0033 if length(dm) == 3 0034 n_vol = 1; 0035 else 0036 n_vol = dm(4); 0037 end 0038 0039 % get the data 0040 if nargin==3 0041 data_range = (br(1)-1)*bs+1:min(br(end)*bs,n_vox); 0042 else 0043 data_range = bs; 0044 end 0045 0046 block=zeros(length(data_range),length(N)); 0047 if n_vol==1 0048 for i=1:length(N) 0049 block(:,i) = N(i).dat(data_range); 0050 end 0051 else 0052 for i=1:n_vol 0053 dat_r = N(1).dat(:,:,:,i); 0054 block(:,i) = dat_r(data_range); 0055 end 0056 end 0057 return