Home > vbmeg > demo > tutorial_for_vbmeg2 > advanced > combine_trial_eeg.m

combine_trial_eeg

PURPOSE ^

Combine trials across runs

SYNOPSIS ^

function combine_trial_eeg(p)

DESCRIPTION ^

 Combine trials across runs

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function combine_trial_eeg(p)
0002 % Combine trials across runs
0003 %
0004 % Copyright (C) 2011, ATR All Rights Reserved.
0005 % License : New BSD License(see VBMEG_LICENSE.txt)
0006 
0007 disp(mfilename);
0008 
0009 % Set parameters
0010 Nfile = length(p.file_list);
0011 prefix = 'br_';
0012 
0013 % Set input files
0014 data_files=cell(1,Nfile);
0015 for file=1:Nfile
0016     data_files{file} = fullfile(p.proj_root, p.eeg_dirname, p.trial_dirname, [prefix p.file_list{file} '.eeg.mat']);
0017 end
0018 
0019 % Set output file
0020 combined_file = fullfile(p.proj_root, p.eeg_dirname, p.trial_dirname, 'all.info.mat');
0021 
0022 % Combine trials
0023 vb_get_multi_fileinfo(data_files, combined_file);
0024 
0025 % Add blink and condition information to combined file
0026 load(combined_file, 'fileinfo')
0027 blink = [];
0028 cond_id = [];
0029 for file = 1:Nfile
0030     load(fileinfo.filename{file}, 'EEGinfo')
0031     blink = [blink, EEGinfo.blink];
0032     cond_id = [cond_id, p.cond_list(file)*ones(1, EEGinfo.Nrepeat)];
0033 end
0034 fileinfo.blink = blink;
0035 fileinfo.cond_id = cond_id;
0036 
0037 % Update fileinfo
0038 vb_save(combined_file, 'fileinfo');
0039

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005