Home > bioelectromagnetism > eeg_write_scan4_avg.m

eeg_write_scan4_avg

PURPOSE ^

eeg_write_scan4_avg - Write a Neuroscan 'scan4.x' average file

SYNOPSIS ^

function eeg_write_scan4_avg(f,filename)

DESCRIPTION ^

 eeg_write_scan4_avg - Write a Neuroscan 'scan4.x' average file

 Useage: eeg_write_scan4_avg(f,filename)

 where:    filename is a complete 'path\fileprefix.ext' string;
           the file will be a neuroscan 4.x avg file.

           f is a structure containing:
           
               f.header
               f.electloc
               f.data
               f.variance
               f.tag

           See companion function: eeg_load_scan4_avg.m

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function eeg_write_scan4_avg(f,filename)
0002 
0003 % eeg_write_scan4_avg - Write a Neuroscan 'scan4.x' average file
0004 %
0005 % Useage: eeg_write_scan4_avg(f,filename)
0006 %
0007 % where:    filename is a complete 'path\fileprefix.ext' string;
0008 %           the file will be a neuroscan 4.x avg file.
0009 %
0010 %           f is a structure containing:
0011 %
0012 %               f.header
0013 %               f.electloc
0014 %               f.data
0015 %               f.variance
0016 %               f.tag
0017 %
0018 %           See companion function: eeg_load_scan4_avg.m
0019 %
0020 
0021 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:33 $
0022 
0023 % Licence:  GNU GPL, no implied or express warranties
0024 % Created:  08/2000, Sean.Fitzgibbon_at_flinders.edu.au
0025 % Modified: 08/2001, Darren.Weber_at_radiology.ucsf.edu
0026 %                    distribute under GPL, with Sean's permission
0027 %
0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0029 
0030 ver = '$Revision: 1.1 $';
0031 fprintf('EEG_WRITE_SCAN4_AVG [v %s]\n',ver(11:15)); tic;
0032 
0033 fid = fopen(filename,'w');
0034 
0035 fwrite(fid,f.header.rev,'char');
0036 fwrite(fid,f.header.nextfile,'long');
0037 fwrite(fid,f.header.prevfile,'long');
0038 fwrite(fid,f.header.type,'char');
0039 fwrite(fid,f.header.id,'char');
0040 fwrite(fid,f.header.oper,'char');
0041 fwrite(fid,f.header.doctor,'char');
0042 fwrite(fid,f.header.referral,'char');
0043 fwrite(fid,f.header.hospital,'char');
0044 fwrite(fid,f.header.patient,'char');
0045 fwrite(fid,f.header.age,'short');
0046 fwrite(fid,f.header.sex,'char');
0047 fwrite(fid,f.header.hand,'char');
0048 fwrite(fid,f.header.med,'char');
0049 fwrite(fid,f.header.category,'char');
0050 fwrite(fid,f.header.state,'char');
0051 fwrite(fid,f.header.label,'char');
0052 fwrite(fid,f.header.date,'char');
0053 fwrite(fid,f.header.time,'char');
0054 fwrite(fid,f.header.mean_age,'float');
0055 fwrite(fid,f.header.stdev,'float');
0056 fwrite(fid,f.header.n,'short');
0057 fwrite(fid,f.header.compfile,'char');
0058 fwrite(fid,f.header.spectwincomp,'float');
0059 fwrite(fid,f.header.meanaccuracy,'float');
0060 fwrite(fid,f.header.meanlatency,'float');
0061 fwrite(fid,f.header.sortfile,'char');
0062 fwrite(fid,f.header.numevents,'int');
0063 fwrite(fid,f.header.compoper,'char');
0064 fwrite(fid,f.header.avgmode,'char');
0065 fwrite(fid,f.header.review,'char');
0066 fwrite(fid,f.header.nsweeps,'ushort');
0067 fwrite(fid,f.header.compsweeps,'ushort');
0068 fwrite(fid,f.header.acceptcnt,'ushort');
0069 fwrite(fid,f.header.rejectcnt,'ushort');
0070 fwrite(fid,f.header.pnts,'ushort');
0071 fwrite(fid,f.header.nchannels,'ushort');
0072 fwrite(fid,f.header.avgupdate,'ushort');
0073 fwrite(fid,f.header.domain,'char');
0074 fwrite(fid,f.header.variance,'char');
0075 fwrite(fid,f.header.rate,'ushort');
0076 fwrite(fid,f.header.scale,'double');
0077 fwrite(fid,f.header.veogcorrect,'char');
0078 fwrite(fid,f.header.heogcorrect,'char');
0079 fwrite(fid,f.header.aux1correct,'char');
0080 fwrite(fid,f.header.aux2correct,'char');
0081 fwrite(fid,f.header.veogtrig,'float');
0082 fwrite(fid,f.header.heogtrig,'float');
0083 fwrite(fid,f.header.aux1trig,'float');
0084 fwrite(fid,f.header.aux2trig,'float');
0085 fwrite(fid,f.header.heogchnl,'short');
0086 fwrite(fid,f.header.veogchnl,'short');
0087 fwrite(fid,f.header.aux1chnl,'short');
0088 fwrite(fid,f.header.aux2chnl,'short');
0089 fwrite(fid,f.header.veogdir,'char');
0090 fwrite(fid,f.header.heogdir,'char');
0091 fwrite(fid,f.header.aux1dir,'char');
0092 fwrite(fid,f.header.aux2dir,'char');
0093 fwrite(fid,f.header.veog_n,'short');
0094 fwrite(fid,f.header.heog_n,'short');
0095 fwrite(fid,f.header.aux1_n,'short');
0096 fwrite(fid,f.header.aux2_n,'short');
0097 fwrite(fid,f.header.veogmaxcnt,'short');
0098 fwrite(fid,f.header.heogmaxcnt,'short');
0099 fwrite(fid,f.header.aux1maxcnt,'short');
0100 fwrite(fid,f.header.aux2maxcnt,'short');
0101 fwrite(fid,f.header.veogmethod,'char');
0102 fwrite(fid,f.header.heogmethod,'char');
0103 fwrite(fid,f.header.aux1method,'char');
0104 fwrite(fid,f.header.aux2method,'char');
0105 fwrite(fid,f.header.ampsensitivity,'float');
0106 fwrite(fid,f.header.lowpass,'char');
0107 fwrite(fid,f.header.highpass,'char');
0108 fwrite(fid,f.header.notch,'char');
0109 fwrite(fid,f.header.autoclipadd,'char');
0110 fwrite(fid,f.header.baseline,'char');
0111 fwrite(fid,f.header.offstart,'float');
0112 fwrite(fid,f.header.offstop,'float');
0113 fwrite(fid,f.header.reject,'char');
0114 fwrite(fid,f.header.rejstart,'float');
0115 fwrite(fid,f.header.rejstop,'float');
0116 fwrite(fid,f.header.rejmin,'float');
0117 fwrite(fid,f.header.rejmax,'float');
0118 fwrite(fid,f.header.trigtype,'char');
0119 fwrite(fid,f.header.trigval,'float');
0120 fwrite(fid,f.header.trigchnl,'char');
0121 fwrite(fid,f.header.trigmask,'short');
0122 fwrite(fid,f.header.trigisi,'float');
0123 fwrite(fid,f.header.trigmin,'float');
0124 fwrite(fid,f.header.trigmax,'float');
0125 fwrite(fid,f.header.trigdir,'char');
0126 fwrite(fid,f.header.autoscale,'char');
0127 fwrite(fid,f.header.n2,'short');
0128 fwrite(fid,f.header.dir,'char');
0129 fwrite(fid,f.header.dispmin,'float');
0130 fwrite(fid,f.header.dispmax,'float');
0131 fwrite(fid,f.header.xmin,'float');
0132 fwrite(fid,f.header.xmax,'float');
0133 fwrite(fid,f.header.automin,'float');
0134 fwrite(fid,f.header.automax,'float');
0135 fwrite(fid,f.header.zmin,'float');
0136 fwrite(fid,f.header.zmax,'float');
0137 fwrite(fid,f.header.lowcut,'float');
0138 fwrite(fid,f.header.highcut,'float');
0139 fwrite(fid,f.header.common,'char');
0140 fwrite(fid,f.header.savemode,'char');
0141 fwrite(fid,f.header.manmode,'char');
0142 fwrite(fid,f.header.ref,'char');
0143 fwrite(fid,f.header.rectify,'char');
0144 fwrite(fid,f.header.displayxmin,'float');
0145 fwrite(fid,f.header.displayxmax,'float');
0146 fwrite(fid,f.header.phase,'char');
0147 fwrite(fid,f.header.screen,'char');
0148 fwrite(fid,f.header.calmode,'short');
0149 fwrite(fid,f.header.calmethod,'short');
0150 fwrite(fid,f.header.calupdate,'short');
0151 fwrite(fid,f.header.calbaseline,'short');
0152 fwrite(fid,f.header.calsweeps,'short');
0153 fwrite(fid,f.header.calattenuator,'float');
0154 fwrite(fid,f.header.calpulsevolt,'float');
0155 fwrite(fid,f.header.calpulsestart,'float');
0156 fwrite(fid,f.header.calpulsestop,'float');
0157 fwrite(fid,f.header.calfreq,'float');
0158 fwrite(fid,f.header.taskfile,'char');
0159 fwrite(fid,f.header.seqfile,'char');
0160 fwrite(fid,f.header.spectmethod,'char');
0161 fwrite(fid,f.header.spectscaling,'char');
0162 fwrite(fid,f.header.spectwindow,'char');
0163 fwrite(fid,f.header.spectwinlength,'float');
0164 fwrite(fid,f.header.spectorder,'char');
0165 fwrite(fid,f.header.notchfilter,'char');
0166 fwrite(fid,f.header.headgain,'short');
0167 fwrite(fid,f.header.additionalfiles,'int');
0168 fwrite(fid,f.header.unused,'char');
0169 fwrite(fid,f.header.fspstopmethod,'short');
0170 fwrite(fid,f.header.fspstopmode,'short');
0171 fwrite(fid,f.header.fspfvalue,'float');
0172 fwrite(fid,f.header.fsppoint,'short');
0173 fwrite(fid,f.header.fspblocksize,'short');
0174 fwrite(fid,f.header.fspp1,'ushort');
0175 fwrite(fid,f.header.fspp2,'ushort');
0176 fwrite(fid,f.header.fspalpha,'float');
0177 fwrite(fid,f.header.fspnoise,'float');
0178 fwrite(fid,f.header.fspv1,'short');
0179 fwrite(fid,f.header.montage,'char');
0180 fwrite(fid,f.header.eventfile,'char');
0181 fwrite(fid,f.header.fratio,'float');
0182 fwrite(fid,f.header.minor_rev,'char');
0183 fwrite(fid,f.header.eegupdate,'short');
0184 fwrite(fid,f.header.compressed,'char');
0185 fwrite(fid,f.header.xscale,'float');
0186 fwrite(fid,f.header.yscale,'float');
0187 fwrite(fid,f.header.xsize,'float');
0188 fwrite(fid,f.header.ysize,'float');
0189 fwrite(fid,f.header.acmode,'char');
0190 fwrite(fid,f.header.commonchnl,'uchar');
0191 fwrite(fid,f.header.xtics,'char');
0192 fwrite(fid,f.header.xrange,'char');
0193 fwrite(fid,f.header.ytics,'char');
0194 fwrite(fid,f.header.yrange,'char');
0195 fwrite(fid,f.header.xscalevalue,'float');
0196 fwrite(fid,f.header.xscaleinterval,'float');
0197 fwrite(fid,f.header.yscalevalue,'float');
0198 fwrite(fid,f.header.yscaleinterval,'float');
0199 fwrite(fid,f.header.scaletoolx1,'float');
0200 fwrite(fid,f.header.scaletooly1,'float');
0201 fwrite(fid,f.header.scaletoolx2,'float');
0202 fwrite(fid,f.header.scaletooly2,'float');
0203 fwrite(fid,f.header.port,'short');
0204 fwrite(fid,f.header.numsamples,'long');
0205 fwrite(fid,f.header.filterflag,'char');
0206 fwrite(fid,f.header.lowcutoff,'float');
0207 fwrite(fid,f.header.lowpoles,'short');
0208 fwrite(fid,f.header.highcutoff,'float');
0209 fwrite(fid,f.header.highpoles,'short');
0210 fwrite(fid,f.header.filtertype,'char');
0211 fwrite(fid,f.header.filterdomain,'char');
0212 fwrite(fid,f.header.snrflag,'char');
0213 fwrite(fid,f.header.coherenceflag,'char');
0214 fwrite(fid,f.header.continuoustype,'char');
0215 fwrite(fid,f.header.eventtablepos,'long');
0216 fwrite(fid,f.header.continuousseconds,'float');
0217 fwrite(fid,f.header.channeloffset,'long');
0218 fwrite(fid,f.header.autocorrectflag,'char');
0219 fwrite(fid,f.header.dcthreshold,'uchar');
0220 
0221 for n = 1:f.header.nchannels
0222 fwrite(fid,f.electloc(n).lab,'char');
0223 fwrite(fid,f.electloc(n).reference,'char');
0224 fwrite(fid,f.electloc(n).skip,'char');
0225 fwrite(fid,f.electloc(n).reject,'char');
0226 fwrite(fid,f.electloc(n).display,'char');
0227 fwrite(fid,f.electloc(n).bad,'char');
0228 fwrite(fid,f.electloc(n).n,'ushort');
0229 fwrite(fid,f.electloc(n).avg_reference,'char');
0230 fwrite(fid,f.electloc(n).clipadd,'char');
0231 fwrite(fid,f.electloc(n).x_coord,'float');
0232 fwrite(fid,f.electloc(n).y_coord,'float');
0233 fwrite(fid,f.electloc(n).veog_wt,'float');
0234 fwrite(fid,f.electloc(n).veog_std,'float');
0235 fwrite(fid,f.electloc(n).snr,'float');
0236 fwrite(fid,f.electloc(n).heog_wt,'float');
0237 fwrite(fid,f.electloc(n).heog_std,'float');
0238 fwrite(fid,f.electloc(n).baseline,'short');
0239 fwrite(fid,f.electloc(n).filtered,'char');
0240 fwrite(fid,f.electloc(n).fsp,'char');
0241 fwrite(fid,f.electloc(n).aux1_wt,'float');
0242 fwrite(fid,f.electloc(n).aux1_std,'float');
0243 fwrite(fid,f.electloc(n).senstivity,'float');
0244 fwrite(fid,f.electloc(n).gain,'char');
0245 fwrite(fid,f.electloc(n).hipass,'char');
0246 fwrite(fid,f.electloc(n).lopass,'char');
0247 fwrite(fid,f.electloc(n).page,'uchar');
0248 fwrite(fid,f.electloc(n).size,'uchar');
0249 fwrite(fid,f.electloc(n).impedance,'uchar');
0250 fwrite(fid,f.electloc(n).physicalchnl,'uchar');
0251 fwrite(fid,f.electloc(n).rectify,'char');
0252 fwrite(fid,f.electloc(n).calib,'float');
0253 end
0254 
0255 for i = 1:f.header.nchannels
0256    fwrite(fid,f.data(i).header,'char');
0257    fwrite(fid,f.data(i).samples,'float');
0258 end
0259 
0260 for j = 1:f.header.nchannels
0261    fwrite(fid,f.variance(j).samples,'float');
0262 end
0263 
0264 fwrite(fid,f.tag,'char');
0265 
0266 frewind(fid);
0267 fclose(fid);
0268 
0269 t = toc; fprintf('...done (%6.2f sec).\n\n',t);
0270 
0271 return

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003