0001 function vb_saver_eeg_copy_info(old_file, new_file, new_info)
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 if ~exist('old_file', 'var'), old_file = ''; end
0029 if ~exist('new_file', 'var'), new_file = ''; end
0030 if ~exist('new_info', 'var'), new_info = []; end
0031 [old_file, new_file, new_info] = ...
0032 inner_check_arguments(old_file, new_file, new_info);
0033
0034
0035
0036 cur_eeg = load(old_file);
0037 new_eeginfo = cur_eeg.EEGinfo;
0038
0039
0040 if isempty(new_info)
0041 if isfield(new_eeginfo, 'File') && isfield(new_eeginfo.File, 'DataDir')
0042 new_eeginfo.File = rmfield(new_eeginfo.File, 'DataDir');
0043 end
0044
0045 new_info.n_sample = vb_eeginfo_get_sample_number(new_eeginfo);
0046 new_info.sampling_freq = vb_eeginfo_get_sampling_frequency(new_eeginfo);
0047 new_info.pretrigger = vb_eeginfo_get_pre_trigger(new_eeginfo);
0048
0049 else
0050
0051 if isempty(new_info.bin_dir)
0052 if isfield(new_eeginfo, 'File') && isfield(new_eeginfo.File, 'DataDir')
0053 new_eeginfo.File = rmfield(new_eeginfo.File, 'DataDir');
0054 end
0055 else
0056 new_eeginfo.File.DataDir = new_info.bin_dir;
0057 end
0058
0059 if isempty(new_info.n_sample)
0060 new_info.n_sample = vb_eeginfo_get_sample_number(new_eeginfo);
0061 end
0062
0063 if isempty(new_info.sampling_freq)
0064 new_info.sampling_freq = vb_eeginfo_get_sampling_frequency(new_eeginfo);
0065 end
0066
0067 if isempty(new_info.pretrigger)
0068 new_info.pretrigger = vb_eeginfo_get_pre_trigger(new_eeginfo);
0069 end
0070 end
0071
0072
0073 new_eeginfo.Nsample = new_info.n_sample;
0074 new_eeginfo.SampleFrequency = new_info.sampling_freq;
0075 new_eeginfo.Pretrigger = new_info.pretrigger;
0076
0077 cur_eeg.EEGinfo = new_eeginfo;
0078 cur_eeg.eeg_data = [];
0079
0080 vb_save_struct(new_file, cur_eeg);
0081
0082 return
0083 end
0084
0085
0086
0087
0088
0089
0090
0091 function [old_file, new_file, new_info] = ...
0092 inner_check_arguments(old_file, new_file, new_info)
0093 func_ = mfilename;
0094
0095
0096 if isempty(old_file)
0097 error('(%s) old_file is a required parameter', func_);
0098 end
0099
0100 if exist(old_file, 'file') ~= 2
0101 error('(%s) cannot find old_file : %s', func_, old_file);
0102 end
0103
0104
0105 if isempty(new_file)
0106 error('(%s) new_file is a required parameter', func_);
0107 end
0108
0109
0110 if isempty(new_info)
0111
0112 end
0113
0114
0115 if ~isfield(new_info, 'bin_dir')
0116 new_info.bin_dir = '';
0117 end
0118
0119
0120 if ~isfield(new_info, 'n_sample')
0121 new_info.n_sample = [];
0122 end
0123
0124
0125 if ~isfield(new_info, 'sampling_freq')
0126 new_info.sampling_freq = [];
0127 end
0128
0129
0130 if ~isfield(new_info, 'pretrigger')
0131 new_info.pretrigger = [];
0132 end
0133
0134 return
0135 end
0136
0137
0138
0139
0140
0141