Home > bioelectromagnetism > eeg_load_scan41.m

eeg_load_scan41

PURPOSE ^

eeg_load_scan4_avg - Load a Neuroscan 'scan4.1' average file

SYNOPSIS ^

function [f,fid] = eeg_load_scan4_avg(filename)

DESCRIPTION ^

 eeg_load_scan4_avg - Load a Neuroscan 'scan4.1' average file

 Useage: [f,fid] = eeg_load_scan4_avg(filename)

 where:    filename is a complete 'path\fileprefix.ext' string;
           the file must be a neuroscan 4.1 avg file.

           f is a structure containing:
           
               f.header        - general header parameters
               f.electloc      - channel specific parameters
               f.data.header   - small channel data header
               f.data.samples  - channel data (not uV)
               f.variance      - channel variance
               f.tag           - scan4.1 file tags

           fid is a file handle to 'filename'

           See the .m file for more details on structure fields
           or use the fieldnames command.

 Note:     The f.data.samples are not in uV, they are in
           raw amplifier units.
           To scale data to microvolts, multiply by the channel-specific 
           calibration factor ([f.electloc.calib]) and divide by the 
           number of sweeps in the average ([f.electloc.n]).
           Also, subtract baseline value ([f.electloc.baseline])
           to be sure to obtain baselined averaged values.  eg:
           ampData = [f.data.samples]; % elect in col, samples in row
           baseline = repmat([f.electloc.baseline],[f.header.pnts],1);
           calibration = repmat([f.electloc.calib],[f.header.pnts],1);
           n = repmat([f.electloc.n],[f.header.pnts],1);
           uV = ( ampData - baseline ) .* calibration ./ n;

 See also  eeg_load_scan_avg

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [f,fid] = eeg_load_scan4_avg(filename)
0002 
0003 % eeg_load_scan4_avg - Load a Neuroscan 'scan4.1' average file
0004 %
0005 % Useage: [f,fid] = eeg_load_scan4_avg(filename)
0006 %
0007 % where:    filename is a complete 'path\fileprefix.ext' string;
0008 %           the file must be a neuroscan 4.1 avg file.
0009 %
0010 %           f is a structure containing:
0011 %
0012 %               f.header        - general header parameters
0013 %               f.electloc      - channel specific parameters
0014 %               f.data.header   - small channel data header
0015 %               f.data.samples  - channel data (not uV)
0016 %               f.variance      - channel variance
0017 %               f.tag           - scan4.1 file tags
0018 %
0019 %           fid is a file handle to 'filename'
0020 %
0021 %           See the .m file for more details on structure fields
0022 %           or use the fieldnames command.
0023 %
0024 % Note:     The f.data.samples are not in uV, they are in
0025 %           raw amplifier units.
0026 %           To scale data to microvolts, multiply by the channel-specific
0027 %           calibration factor ([f.electloc.calib]) and divide by the
0028 %           number of sweeps in the average ([f.electloc.n]).
0029 %           Also, subtract baseline value ([f.electloc.baseline])
0030 %           to be sure to obtain baselined averaged values.  eg:
0031 %           ampData = [f.data.samples]; % elect in col, samples in row
0032 %           baseline = repmat([f.electloc.baseline],[f.header.pnts],1);
0033 %           calibration = repmat([f.electloc.calib],[f.header.pnts],1);
0034 %           n = repmat([f.electloc.n],[f.header.pnts],1);
0035 %           uV = ( ampData - baseline ) .* calibration ./ n;
0036 %
0037 % See also  eeg_load_scan_avg
0038 %
0039 
0040 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:33 $
0041 
0042 % Licence:  GNU GPL, no implied or express warranties
0043 % Created:  08/2000, Sean Fitzgibbon <psspf@id.psy.flinders.edu.au>
0044 % Modified: 07/2001, Darren.Weber_at_radiology.ucsf.edu
0045 %                    tab formatted this file and added help, esp.
0046 %                    info about uV conversion
0047 %           04/2002, Darren.Weber_at_radiology.ucsf.edu
0048 %                    added file exist check
0049 %                    added 'ieee-le' to fopen
0050 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0051 
0052 ver = '$Revision: 1.1 $';
0053 fprintf('EEG_LOAD_SCAN41 [v %s]\n',ver(11:15));
0054 
0055 if ~isequal(exist(filename),2),
0056     lookfile = which(filename);
0057     if isempty(lookfile),
0058         msg = sprintf('...cannot locate %s\n', filename);
0059         error(msg);
0060     else
0061         filename = lookfile;
0062     end
0063 end
0064 fprintf('...reading file:\n...%s\n',filename);
0065 
0066 fid = fopen(filename,'r','ieee-le');
0067 
0068 h.rev               = fread(fid,12,'char');
0069 h.nextfile          = fread(fid,1,'long');
0070 h.prevfile          = fread(fid,1,'long');
0071 h.type              = fread(fid,1,'char');
0072 h.id                = fread(fid,20,'char');
0073 h.oper              = fread(fid,20,'char');
0074 h.doctor            = fread(fid,20,'char');
0075 h.referral          = fread(fid,20,'char');
0076 h.hospital          = fread(fid,20,'char');
0077 h.patient           = fread(fid,20,'char');
0078 h.age               = fread(fid,1,'short');
0079 h.sex               = fread(fid,1,'char');
0080 h.hand              = fread(fid,1,'char');
0081 h.med               = fread(fid,20, 'char');
0082 h.category          = fread(fid,20, 'char');
0083 h.state             = fread(fid,20, 'char');
0084 h.label             = fread(fid,20, 'char');
0085 h.date              = fread(fid,10, 'char');
0086 h.time              = fread(fid,12, 'char');
0087 h.mean_age          = fread(fid,1,'float');
0088 h.stdev             = fread(fid,1,'float');
0089 h.n                 = fread(fid,1,'short');
0090 h.compfile          = fread(fid,38,'char');
0091 h.spectwincomp      = fread(fid,1,'float');
0092 h.meanaccuracy      = fread(fid,1,'float');
0093 h.meanlatency       = fread(fid,1,'float');
0094 h.sortfile          = fread(fid,46,'char');
0095 h.numevents         = fread(fid,1,'int');
0096 h.compoper          = fread(fid,1,'char');
0097 h.avgmode           = fread(fid,1,'char');
0098 h.review            = fread(fid,1,'char');
0099 h.nsweeps           = fread(fid,1,'ushort');
0100 h.compsweeps        = fread(fid,1,'ushort');
0101 h.acceptcnt         = fread(fid,1,'ushort');
0102 h.rejectcnt         = fread(fid,1,'ushort');
0103 h.pnts              = fread(fid,1,'ushort');
0104 h.nchannels         = fread(fid,1,'ushort');
0105 h.avgupdate         = fread(fid,1,'ushort');
0106 h.domain            = fread(fid,1,'char');
0107 h.variance          = fread(fid,1,'char');
0108 h.rate              = fread(fid,1,'ushort');
0109 h.scale             = fread(fid,1,'double');
0110 h.veogcorrect       = fread(fid,1,'char');
0111 h.heogcorrect       = fread(fid,1,'char');
0112 h.aux1correct       = fread(fid,1,'char');
0113 h.aux2correct       = fread(fid,1,'char');
0114 h.veogtrig          = fread(fid,1,'float');
0115 h.heogtrig          = fread(fid,1,'float');
0116 h.aux1trig          = fread(fid,1,'float');
0117 h.aux2trig          = fread(fid,1,'float');
0118 h.heogchnl          = fread(fid,1,'short');
0119 h.veogchnl          = fread(fid,1,'short');
0120 h.aux1chnl          = fread(fid,1,'short');
0121 h.aux2chnl          = fread(fid,1,'short');
0122 h.veogdir           = fread(fid,1,'char');
0123 h.heogdir           = fread(fid,1,'char');
0124 h.aux1dir           = fread(fid,1,'char');
0125 h.aux2dir           = fread(fid,1,'char');
0126 h.veog_n            = fread(fid,1,'short');
0127 h.heog_n            = fread(fid,1,'short');
0128 h.aux1_n            = fread(fid,1,'short');
0129 h.aux2_n            = fread(fid,1,'short');
0130 h.veogmaxcnt        = fread(fid,1,'short');
0131 h.heogmaxcnt        = fread(fid,1,'short');
0132 h.aux1maxcnt        = fread(fid,1,'short');
0133 h.aux2maxcnt        = fread(fid,1,'short');
0134 h.veogmethod        = fread(fid,1,'char');
0135 h.heogmethod        = fread(fid,1,'char');
0136 h.aux1method        = fread(fid,1,'char');
0137 h.aux2method        = fread(fid,1,'char');
0138 h.ampsensitivity    = fread(fid,1,'float');
0139 h.lowpass           = fread(fid,1,'char');
0140 h.highpass          = fread(fid,1,'char');
0141 h.notch             = fread(fid,1,'char');
0142 h.autoclipadd       = fread(fid,1,'char');
0143 h.baseline          = fread(fid,1,'char');
0144 h.offstart          = fread(fid,1,'float');
0145 h.offstop           = fread(fid,1,'float');
0146 h.reject            = fread(fid,1,'char');
0147 h.rejstart          = fread(fid,1,'float');
0148 h.rejstop           = fread(fid,1,'float');
0149 h.rejmin            = fread(fid,1,'float');
0150 h.rejmax            = fread(fid,1,'float');
0151 h.trigtype          = fread(fid,1,'char');
0152 h.trigval           = fread(fid,1,'float');
0153 h.trigchnl          = fread(fid,1,'char');
0154 h.trigmask          = fread(fid,1,'short');
0155 h.trigisi           = fread(fid,1,'float');
0156 h.trigmin           = fread(fid,1,'float');
0157 h.trigmax           = fread(fid,1,'float');
0158 h.trigdir           = fread(fid,1,'char');
0159 h.autoscale         = fread(fid,1,'char');
0160 h.n2                = fread(fid,1,'short');
0161 h.dir               = fread(fid,1,'char');
0162 h.dispmin           = fread(fid,1,'float');
0163 h.dispmax           = fread(fid,1,'float');
0164 h.xmin              = fread(fid,1,'float');
0165 h.xmax              = fread(fid,1,'float');
0166 h.automin           = fread(fid,1,'float');
0167 h.automax           = fread(fid,1,'float');
0168 h.zmin              = fread(fid,1,'float');
0169 h.zmax              = fread(fid,1,'float');
0170 h.lowcut            = fread(fid,1,'float');
0171 h.highcut           = fread(fid,1,'float');
0172 h.common            = fread(fid,1,'char');
0173 h.savemode          = fread(fid,1,'char');
0174 h.manmode           = fread(fid,1,'char');
0175 h.ref               = fread(fid,10,'char');
0176 h.rectify           = fread(fid,1,'char');
0177 h.displayxmin       = fread(fid,1,'float');
0178 h.displayxmax       = fread(fid,1,'float');
0179 h.phase             = fread(fid,1,'char');
0180 h.screen            = fread(fid,16,'char');
0181 h.calmode           = fread(fid,1,'short');
0182 h.calmethod         = fread(fid,1,'short');
0183 h.calupdate         = fread(fid,1,'short');
0184 h.calbaseline       = fread(fid,1,'short');
0185 h.calsweeps         = fread(fid,1,'short');
0186 h.calattenuator     = fread(fid,1,'float');
0187 h.calpulsevolt      = fread(fid,1,'float');
0188 h.calpulsestart     = fread(fid,1,'float');
0189 h.calpulsestop      = fread(fid,1,'float');
0190 h.calfreq           = fread(fid,1,'float');
0191 h.taskfile          = fread(fid,34,'char');
0192 h.seqfile           = fread(fid,34,'char');
0193 h.spectmethod       = fread(fid,1,'char');
0194 h.spectscaling      = fread(fid,1,'char');
0195 h.spectwindow       = fread(fid,1,'char');
0196 h.spectwinlength    = fread(fid,1,'float');
0197 h.spectorder        = fread(fid,1,'char');
0198 h.notchfilter       = fread(fid,1,'char');
0199 h.headgain          = fread(fid,1,'short');
0200 h.additionalfiles   = fread(fid,1,'int');
0201 h.unused            = fread(fid,5,'char');
0202 h.fspstopmethod     = fread(fid,1,'short');
0203 h.fspstopmode       = fread(fid,1,'short');
0204 h.fspfvalue         = fread(fid,1,'float');
0205 h.fsppoint          = fread(fid,1,'short');
0206 h.fspblocksize      = fread(fid,1,'short');
0207 h.fspp1             = fread(fid,1,'ushort');
0208 h.fspp2             = fread(fid,1,'ushort');
0209 h.fspalpha          = fread(fid,1,'float');
0210 h.fspnoise          = fread(fid,1,'float');
0211 h.fspv1             = fread(fid,1,'short');
0212 h.montage           = fread(fid,40,'char');
0213 h.eventfile         = fread(fid,40,'char');
0214 h.fratio            = fread(fid,1,'float');
0215 h.minor_rev         = fread(fid,1,'char');
0216 h.eegupdate         = fread(fid,1,'short');
0217 h.compressed        = fread(fid,1,'char');
0218 h.xscale            = fread(fid,1,'float');
0219 h.yscale            = fread(fid,1,'float');
0220 h.xsize             = fread(fid,1,'float');
0221 h.ysize             = fread(fid,1,'float');
0222 h.acmode            = fread(fid,1,'char');
0223 h.commonchnl        = fread(fid,1,'uchar');
0224 h.xtics             = fread(fid,1,'char');
0225 h.xrange            = fread(fid,1,'char');
0226 h.ytics             = fread(fid,1,'char');
0227 h.yrange            = fread(fid,1,'char');
0228 h.xscalevalue       = fread(fid,1,'float');
0229 h.xscaleinterval    = fread(fid,1,'float');
0230 h.yscalevalue       = fread(fid,1,'float');
0231 h.yscaleinterval    = fread(fid,1,'float');
0232 h.scaletoolx1       = fread(fid,1,'float');
0233 h.scaletooly1       = fread(fid,1,'float');
0234 h.scaletoolx2       = fread(fid,1,'float');
0235 h.scaletooly2       = fread(fid,1,'float');
0236 h.port              = fread(fid,1,'short');
0237 h.numsamples        = fread(fid,1,'long');
0238 h.filterflag        = fread(fid,1,'char');
0239 h.lowcutoff         = fread(fid,1,'float');
0240 h.lowpoles          = fread(fid,1,'short');
0241 h.highcutoff        = fread(fid,1,'float');
0242 h.highpoles         = fread(fid,1,'short');
0243 h.filtertype        = fread(fid,1,'char');
0244 h.filterdomain      = fread(fid,1,'char');
0245 h.snrflag           = fread(fid,1,'char');
0246 h.coherenceflag     = fread(fid,1,'char');
0247 h.continuoustype    = fread(fid,1,'char');
0248 h.eventtablepos     = fread(fid,1,'long');
0249 h.continuousseconds = fread(fid,1,'float');
0250 h.channeloffset     = fread(fid,1,'long');
0251 h.autocorrectflag   = fread(fid,1,'char');
0252 h.dcthreshold       = fread(fid,1,'uchar');
0253 
0254 for n = 1:h.nchannels
0255 e(n).lab            = fread(fid,10,'char');
0256 e(n).reference      = fread(fid,1,'char');
0257 e(n).skip           = fread(fid,1,'char');
0258 e(n).reject         = fread(fid,1,'char');
0259 e(n).display        = fread(fid,1,'char');
0260 e(n).bad            = fread(fid,1,'char');
0261 e(n).n              = fread(fid,1,'ushort');
0262 e(n).avg_reference  = fread(fid,1,'char');
0263 e(n).clipadd        = fread(fid,1,'char');
0264 e(n).x_coord        = fread(fid,1,'float');
0265 e(n).y_coord        = fread(fid,1,'float');
0266 e(n).veog_wt        = fread(fid,1,'float');
0267 e(n).veog_std       = fread(fid,1,'float');
0268 e(n).snr            = fread(fid,1,'float');
0269 e(n).heog_wt        = fread(fid,1,'float');
0270 e(n).heog_std       = fread(fid,1,'float');
0271 e(n).baseline       = fread(fid,1,'short');
0272 e(n).filtered       = fread(fid,1,'char');
0273 e(n).fsp            = fread(fid,1,'char');
0274 e(n).aux1_wt        = fread(fid,1,'float');
0275 e(n).aux1_std       = fread(fid,1,'float');
0276 e(n).sensitivity    = fread(fid,1,'float');
0277 e(n).gain           = fread(fid,1,'char');
0278 e(n).hipass         = fread(fid,1,'char');
0279 e(n).lopass         = fread(fid,1,'char');
0280 e(n).page           = fread(fid,1,'uchar');
0281 e(n).size           = fread(fid,1,'uchar');
0282 e(n).impedance      = fread(fid,1,'uchar');
0283 e(n).physicalchnl   = fread(fid,1,'uchar');
0284 e(n).rectify        = fread(fid,1,'char');
0285 e(n).calib          = fread(fid,1,'float');
0286 end
0287 
0288 for i = 1:h.nchannels
0289    d(i).header      = fread(fid,5,'char');
0290    d(i).samples     = fread(fid,h.pnts,'float');
0291 end
0292 
0293 for j = 1:h.nchannels
0294    v(j).samples     = fread(fid,h.pnts,'float');
0295 end
0296 
0297 t = fread(fid,'char');
0298 
0299 f.header = h;
0300 f.electloc = e;
0301 f.data = d;
0302 f.variance = v;
0303 f.tag = t;
0304 
0305 frewind(fid);
0306 fclose(fid);
0307 
0308 return

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