function status=make_ave_bf(prestimsamps,prestimsamps2,lowpass,highpass,infname,outfname) Filter and baseline correct data in an average EGIS file. This function accepts either 4 or 6 input arguments. If the last two arguments are omitted the function is run in interactive mode, and file names are obtained through the std dialog boxes. The parameter prestimsamps1 & 2 are used to baseline correct through a call to zeromeans (c.f.). The parameters lowpass and highpass are used to construct the butterworth filter. If highpass is zero than filtering occurs through a single lowpass filtering of order 20. Otherwise, data is bandpass filtered with a filter of order six, and then refiltered with a lowpass filter of order 20 to improve high-end rolloff. Uses: ave_hdr_offsets_v, rd_egis_hdr_v, zeromeans, rd_onetr_allch
0001 function trialdata=grab_samp_ave(cell,obs,infname) 0002 %function status=make_ave_bf(prestimsamps,prestimsamps2,lowpass,highpass,infname,outfname) 0003 % 0004 %Filter and baseline correct data in an average EGIS file. 0005 % 0006 %This function accepts either 4 or 6 input arguments. If the 0007 %last two arguments are omitted the function is run in 0008 %interactive mode, and file names are obtained through the std 0009 %dialog boxes. 0010 % 0011 %The parameter prestimsamps1 & 2 are used to baseline correct through 0012 %a call to zeromeans (c.f.). The parameters lowpass and highpass 0013 %are used to construct the butterworth filter. If highpass is zero 0014 %than filtering occurs through a single lowpass filtering of order 0015 %20. Otherwise, data is bandpass filtered with a filter of order six, 0016 %and then refiltered with a lowpass filter of order 20 to improve 0017 %high-end rolloff. 0018 % 0019 %Uses: ave_hdr_offsets_v, rd_egis_hdr_v, zeromeans, rd_onetr_allch 0020 0021 %Modification History 0022 % 9/95 Created by Ramesh Srinivasan 0023 % 10/95 Rewrote user interface and added high pas filtering - B. Rakitin 0024 % 10/31/95 Bug fixed in file opening branch - B. Rakitin 0025 % 11/17/95 reordered filters in bad-pass case - RS 0026 status = -1; 0027 0028 %Check number of input arguments 0029 if ~((nargin == 3)) 0030 error('Number of input arguments must be 2'); 0031 end 0032 %Initialize fids 0033 srcfid = -1; 0034 srcfid = fopen(infname,'r') 0035 %Call EGIS hdr index script 0036 ses_hdr_offsets_v; 0037 %Read in the EGIS header 0038 [fhdr,chdr,ename,czeros,cgains,cnames,fcom,ftext, coff]=rd_egis_hdr_v(srcfid); 0039 %Calculate nyquist frequency and compare to lowpass parameter 0040 %Begin looping through cells 0041 c= cell; 0042 t = obs; 0043 trialdata = rd_onetr_allch(srcfid, coff(c), t, fhdr(NChan), chdr(c, NPoints)); 0044 temp=fclose(srcfid); 0045 temp=fclose(destfid); 0046 status = 1;