Home > chronux > dataio > ReadingPLXandDDTfilesinMatlab > plx_info.m

plx_info

PURPOSE ^

plx_info(filename, fullread) -- read and display .plx file info

SYNOPSIS ^

function [tscounts, wfcounts, evcounts] = plx_info(filename, fullread)

DESCRIPTION ^

 plx_info(filename, fullread) -- read and display .plx file info

 [tscounts, wfcounts] = plx_info(filename, fullread)

 INPUT:
   filename - if empty string, will use File Open dialog
   fullread - if 0, reads only the file header
              if 1, reads all the file
 OUTPUT:
   tscounts - 5x130 array of timestamp counts
      tscounts(i, j) is the number of timestamps for channel i, unit j
   wfcounts - 5x130 array of waveform counts
     wfcounts(i, j) is the number of waveforms for channel i, unit j
   evcounts - 1x512 array of external event counts
     evcounts(i) is the number of events for channel i

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [tscounts, wfcounts, evcounts] = plx_info(filename, fullread)
0002 % plx_info(filename, fullread) -- read and display .plx file info
0003 %
0004 % [tscounts, wfcounts] = plx_info(filename, fullread)
0005 %
0006 % INPUT:
0007 %   filename - if empty string, will use File Open dialog
0008 %   fullread - if 0, reads only the file header
0009 %              if 1, reads all the file
0010 % OUTPUT:
0011 %   tscounts - 5x130 array of timestamp counts
0012 %      tscounts(i, j) is the number of timestamps for channel i, unit j
0013 %   wfcounts - 5x130 array of waveform counts
0014 %     wfcounts(i, j) is the number of waveforms for channel i, unit j
0015 %   evcounts - 1x512 array of external event counts
0016 %     evcounts(i) is the number of events for channel i
0017 
0018 if(nargin ~= 2)
0019    disp('2 input arguments are required')
0020    return
0021 end
0022 
0023 if(isempty(filename))
0024    [fname, pathname] = uigetfile('*.plx', 'Select a plx file');
0025     filename = strcat(pathname, fname);
0026 end
0027 fid = fopen(filename, 'r');
0028 
0029 if(fid == -1)
0030     disp('cannot open file');
0031    return
0032 end
0033 
0034 disp(strcat('file = ', filename));
0035 header = fread(fid, 64, 'int32');
0036 version = header(2);
0037 freq = header(35);  % frequency
0038 ndsp = header(36);  % number of dsp channels
0039 nevents = header(37); % number of external events
0040 nslow = header(38);  % number of slow channels
0041 npw = header(39);  % number of points in wave
0042 npr = header(40);  % number of points before threshold
0043 disp(strcat('version = ', num2str(version)));
0044 disp(strcat('frequency = ', num2str(freq)));
0045 disp(strcat('number of DSP headers = ', num2str(ndsp)));
0046 disp(strcat('number of Event headers = ', num2str(nevents)));
0047 disp(strcat('number of A/D headers = ', num2str(nslow)));
0048 tscounts = fread(fid, [5, 130], 'int32');
0049 wfcounts = fread(fid, [5, 130], 'int32');
0050 evcounts = fread(fid, [1, 512], 'int32');
0051 if fullread > 0
0052    % reset counters
0053    tscounts = zeros(5, 130);
0054    wfcounts = zeros(5, 130);
0055    evcounts = zeros(1, 512);
0056    % skip variable headers
0057    fseek(fid, 1020*ndsp + 296*nevents + 296*nslow, 'cof');
0058     record = 0;
0059     while feof(fid) == 0
0060        type = fread(fid, 1, 'int16');
0061         upperbyte = fread(fid, 1, 'int16');
0062         timestamp = fread(fid, 1, 'int32');
0063         channel = fread(fid, 1, 'int16');
0064        unit = fread(fid, 1, 'int16');
0065        nwf = fread(fid, 1, 'int16');
0066        nwords = fread(fid, 1, 'int16');
0067        toread = nwords;
0068         if toread > 0
0069              wf = fread(fid, toread, 'int16');
0070         end
0071       if type == 1
0072          tscounts(unit+1, channel+1) = tscounts(unit+1, channel+1) + 1;
0073          if toread > 0
0074             wfcounts(unit+1, channel+1) = wfcounts(unit+1, channel+1) + 1;
0075          end
0076       end
0077       if type == 4
0078          evcounts(channel+1) = evcounts(channel+1) + 1;
0079       end
0080       
0081        record = record + 1;
0082        if feof(fid) == 1
0083           break
0084        end
0085     end
0086    disp(strcat('number of records = ', num2str(record)));
0087 end
0088 disp(' ');
0089 disp(' Timestamps:');
0090 disp(' ch unit  count');
0091 for i=1:130
0092    for j=1:5
0093       if tscounts(j, i) > 0
0094          disp(sprintf('%3d %4d %6d', i-1, j-1, tscounts(j, i)));
0095       end
0096    end
0097 end
0098 
0099 disp(' ');
0100 disp(' Waveforms:');
0101 disp(' ch unit  count');
0102 for i=1:130
0103    for j=1:5
0104       if wfcounts(j, i) > 0
0105          disp(sprintf('%3d %4d %6d', i-1, j-1, wfcounts(j, i)));
0106       end
0107    end
0108 end
0109 
0110 disp(' ');
0111 disp(' Events:');
0112 disp(' ch count');
0113 for i=1:300
0114   if evcounts(i) > 0
0115      disp(sprintf('%3d %6d', i-1, evcounts(i)));
0116    end
0117 end
0118 
0119 disp(' ');
0120 disp(' A/D channels:');
0121 disp(' ch count');
0122 for i=301:364
0123   if evcounts(i) > 0
0124      disp(sprintf('%3d %6d', i-301, evcounts(i)));
0125    end
0126 end
0127 
0128 
0129 fclose(fid);

Generated on Fri 28-Sep-2012 12:34:30 by m2html © 2005