pb_zipblocks.m 1.49 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
function fn = pb_zipblocks(cdir,varargin)
% PB_ZIPBLOCKS
%
% PB_ZIPBLOCKS(cdir) converts and bulks all datafiles for each block in the
% vestibular setup together. Input: experimental folder. Output: merged
% converted data.
%
% See also PB_CONVERTDATA

% PBToolbox (2020): JJH: j.heckman@donders.ru.nl

   if nargin == 0; cdir = pb_getdir('dir','/Users/jjheckman/Documents/Data/PhD/Experiment'); end
   cd(cdir);
   
   listing = dir('block_info_*.mat');
   
   Data     = struct([]);
   for iL = 1:length(listing)
      disp(['>> Unpacking: ' listing(iL).name '...']);
      disp('    >> Converting data...');
      tmp   = pb_convertdata([cd filesep listing(iL).name]);
      disp('    << Data succesfully converted.');
      tmpsz = length(tmp);
      
      %  Zip blocks
      if isempty(Data)
         Data = tmp; 
      else
         Data(end+1:end+tmpsz) = tmp; 
         disp(['    << ' num2str(tmpsz) ' block(s) appended.']);
      end
   end
   
   fn = listing(1).name(1:end-9);
   fn = strrep(fn,'block_info_','converted_data_');
   fn = [fn '.mat'];
   save([cd filesep fn], 'Data');
Jesse Heckman's avatar
Jesse Heckman committed
38
   disp(['<< Zip complete... (fn: ' fn ')']);
39 40 41 42 43 44 45 46 47
end
 
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
%                                                           %
%       Part of Programmeer Beer Toolbox (PBToolbox)        %
%       Written by: Jesse J. Heckman (2020)                 %
%                                                           %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %