0001 function [data,times] = mne_ex_read_raw(fname,from,to,in_samples,dest_comp)
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
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 me='MNE:mne_ex_read_raw';
0055
0056 keep_comp = false;
0057 if nargin == 3
0058 in_samples = false;
0059 keep_comp = true;
0060 elseif nargin == 4
0061 keep_comp = true;
0062 elseif nargin ~= 5
0063 error(me,'Incorrect number of arguments');
0064 end
0065
0066
0067
0068 try
0069 raw = fiff_setup_read_raw(fname);
0070 catch
0071 error(me,'%s',mne_omit_first_line(lasterr));
0072 end
0073
0074
0075
0076 include{1} = 'STI 014';
0077 want_meg = true;
0078 want_eeg = false;
0079 want_stim = false;
0080
0081 picks = fiff_pick_types(raw.info,want_meg,want_eeg,want_stim,include,raw.info.bads);
0082
0083
0084
0085 if isempty(raw.info.projs)
0086 fprintf(1,'No projector specified for these data\n');
0087 raw.proj = [];
0088 else
0089
0090
0091
0092 for k = 1:length(raw.info.projs)
0093 raw.info.projs(k).active = true;
0094 end
0095 fprintf(1,'%d projection items activated\n',length(raw.info.projs));
0096
0097
0098
0099 [proj,nproj] = mne_make_projector_info(raw.info);
0100 if nproj == 0
0101 fprintf(1,'The projection vectors do not apply to these channels\n');
0102 raw.proj = [];
0103 else
0104 fprintf(1,'Created an SSP operator (subspace dimension = %d)\n',nproj);
0105 raw.proj = proj;
0106 end
0107 end
0108
0109
0110
0111 current_comp = mne_get_current_comp(raw.info);
0112 if current_comp > 0
0113 fprintf(1,'Current compensation grade : %d\n',current_comp);
0114 end
0115 if keep_comp
0116 dest_comp = current_comp;
0117 end
0118 if current_comp ~= dest_comp
0119 try
0120 raw.comp = mne_make_compensator(raw.info,current_comp,dest_comp);
0121 raw.info.chs = mne_set_current_comp(raw.info.chs,dest_comp);
0122 fprintf(1,'Appropriate compensator added to change to grade %d.\n',dest_comp);
0123 catch
0124 error(me,'%s',mne_omit_first_line(lasterr));
0125 end
0126 end
0127
0128
0129
0130
0131 try
0132 if in_samples
0133 [ data, times ] = fiff_read_raw_segment(raw,from,to,picks);
0134 else
0135 [ data, times ] = fiff_read_raw_segment_times(raw,from,to,picks);
0136 end
0137 catch
0138 fclose(raw.fid);
0139 error(me,'%s',mne_omit_first_line(lasterr));
0140 end
0141 fprintf(1,'Read %d samples.\n',size(data,2));
0142
0143 return;
0144
0145 end