Home > eeg > egis > scripts > lap_ns_data.m

lap_ns_data

PURPOSE ^

status = lap_ns_data(rawfname);

SYNOPSIS ^

function status = lap_ns_data(rawfname,Max_microv,Min_Chan);

DESCRIPTION ^

status = lap_ns_data(rawfname);
rawfname = filename (optional)
Max_microv = maximum micovolt value at a channel (optional)
                defaults to 100
Min_Chan = minimum number of channels to use trial (optional)
                defaults to 100
takes the surface Laplacian of a NSFragger file creating new
NSFragger file.  The new file has NChan + 1 channels.  Event 
codes are transmitted to the new file.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function status = lap_ns_data(rawfname,Max_microv,Min_Chan);
0002 %status = lap_ns_data(rawfname);
0003 %rawfname = filename (optional)
0004 %Max_microv = maximum micovolt value at a channel (optional)
0005 %                defaults to 100
0006 %Min_Chan = minimum number of channels to use trial (optional)
0007 %                defaults to 100
0008 %takes the surface Laplacian of a NSFragger file creating new
0009 %NSFragger file.  The new file has NChan + 1 channels.  Event
0010 %codes are transmitted to the new file.
0011 if nargin < 1
0012         [fid, fname, pathname] = get_fid('rb','*.*');
0013         rawfname = [fname];
0014 else
0015         fid = fopen(rawfname,'rb');
0016 end;
0017 
0018 if rawfname == []
0019     [fid, fname, pathname] = get_fid('rb','*.*');
0020 end
0021 if nargin < 2
0022     Max_microv = 100;
0023     Min_Chan = 100;
0024 end;
0025 
0026 [header_array, EventCodes,Samp_Rate, NChan, scale, NSamp, NEvent] = rd_fragger_hdr(fid);
0027 [Epoch, NEpoch,Max_microv,Min_Chan,NBad_chan,bad_chan,mask] = ns_artifact_edit(fid,Samp_Rate,NChan, NSamp, NEvent,scale,1,Max_microv,Min_Chan);
0028 frewind(fid);
0029 [header_array, EventCodes,Samp_Rate, NChan, scale, NSamp, NEvent] = rd_fragger_hdr(fid);
0030 header_array(13) = header_array(13)/100;
0031 header_array(10) = NChan + 1;
0032 header_array(14) = Samp_Rate*NEpoch;
0033 [xelec,yelec,zelec] = electrodes(NChan+1);
0034 lap_filename = [rawfname '_lap'];
0035 lapfid = fopen(lap_filename,'wb');
0036 
0037 wt_fragger_hdr(lapfid,header_array,EventCodes);
0038 for i = 1:NEpoch
0039     if sum(mask(i,:)) > 1
0040         trialdata = zeros(NChan+NEvent,Samp_Rate);
0041         trialdata = fread(fid,[NChan+NEvent,Samp_Rate],'int16');
0042         trialdata = trialdata';
0043         trialdata2 = zeros(Samp_Rate,NChan+1);
0044         trialdata2(:,1:NChan) = trialdata(:,1:NChan);
0045         good_chan = find(mask(i,:));
0046         lap_trialdata2 = laplacian_trial(trialdata2,good_chan,xelec,yelec,zelec);
0047         plot(lap_trialdata2(:,73));
0048         lap_trialdata2 = 100*lap_trialdata2';
0049         lap_trialdata = zeros(NChan+1+NEvent,Samp_Rate);
0050         lap_trialdata(NChan+2:NChan+1+NEvent,:) = trialdata(NChan+1:NChan+NEvent,:);
0051         lap_trialdata(1:NChan+1,:) = lap_trialdata2;
0052         figure
0053         plot(lap_trialdata(73,:));
0054     else
0055         lap_trialdata = zeros(NChan+1+NEvent,Samp_Rate);
0056     end
0057     fwrite(lapfid,lap_trialdata,'int16');
0058 end;
0059 fclose(fid);
0060 fclose(lapfid);
0061

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003