0001 function [tscounts, wfcounts, evcounts] = plx_info(filename, fullread)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
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);
0038 ndsp = header(36);
0039 nevents = header(37);
0040 nslow = header(38);
0041 npw = header(39);
0042 npr = header(40);
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
0053 tscounts = zeros(5, 130);
0054 wfcounts = zeros(5, 130);
0055 evcounts = zeros(1, 512);
0056
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);