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