123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/REC-html40/loose.dtd">
- <html>
- <head>
- <title>Description of plx_info</title>
- <meta name="keywords" content="plx_info">
- <meta name="description" content="plx_info(filename, fullread) -- read and display .plx file info">
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="generator" content="m2html © 2005 Guillaume Flandin">
- <meta name="robots" content="index, follow">
- <link type="text/css" rel="stylesheet" href="../../../m2html.css">
- <script type="text/javascript">
- if (top.frames.length == 0) { top.location = "../../../index.html"; };
- </script>
- </head>
- <body>
- <a name="_top"></a>
- <!-- ../../menu.html chronux_2_10 --><!-- ../menu.html dataio --><!-- menu.html ReadingPLXandDDTfilesinMatlab -->
- <h1>plx_info
- </h1>
- <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
- <div class="box"><strong>plx_info(filename, fullread) -- read and display .plx file info</strong></div>
- <h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
- <div class="box"><strong>function [tscounts, wfcounts, evcounts] = plx_info(filename, fullread) </strong></div>
- <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
- <div class="fragment"><pre class="comment"> 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</pre></div>
- <!-- crossreference -->
- <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
- This function calls:
- <ul style="list-style-image:url(../../../matlabicon.gif)">
- </ul>
- This function is called by:
- <ul style="list-style-image:url(../../../matlabicon.gif)">
- </ul>
- <!-- crossreference -->
- <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
- <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [tscounts, wfcounts, evcounts] = plx_info(filename, fullread)</a>
- 0002 <span class="comment">% plx_info(filename, fullread) -- read and display .plx file info</span>
- 0003 <span class="comment">%</span>
- 0004 <span class="comment">% [tscounts, wfcounts] = plx_info(filename, fullread)</span>
- 0005 <span class="comment">%</span>
- 0006 <span class="comment">% INPUT:</span>
- 0007 <span class="comment">% filename - if empty string, will use File Open dialog</span>
- 0008 <span class="comment">% fullread - if 0, reads only the file header</span>
- 0009 <span class="comment">% if 1, reads all the file</span>
- 0010 <span class="comment">% OUTPUT:</span>
- 0011 <span class="comment">% tscounts - 5x130 array of timestamp counts</span>
- 0012 <span class="comment">% tscounts(i, j) is the number of timestamps for channel i, unit j</span>
- 0013 <span class="comment">% wfcounts - 5x130 array of waveform counts</span>
- 0014 <span class="comment">% wfcounts(i, j) is the number of waveforms for channel i, unit j</span>
- 0015 <span class="comment">% evcounts - 1x512 array of external event counts</span>
- 0016 <span class="comment">% evcounts(i) is the number of events for channel i</span>
- 0017
- 0018 <span class="keyword">if</span>(nargin ~= 2)
- 0019 disp(<span class="string">'2 input arguments are required'</span>)
- 0020 <span class="keyword">return</span>
- 0021 <span class="keyword">end</span>
- 0022
- 0023 <span class="keyword">if</span>(isempty(filename))
- 0024 [fname, pathname] = uigetfile(<span class="string">'*.plx'</span>, <span class="string">'Select a plx file'</span>);
- 0025 filename = strcat(pathname, fname);
- 0026 <span class="keyword">end</span>
- 0027 fid = fopen(filename, <span class="string">'r'</span>);
- 0028
- 0029 <span class="keyword">if</span>(fid == -1)
- 0030 disp(<span class="string">'cannot open file'</span>);
- 0031 <span class="keyword">return</span>
- 0032 <span class="keyword">end</span>
- 0033
- 0034 disp(strcat(<span class="string">'file = '</span>, filename));
- 0035 header = fread(fid, 64, <span class="string">'int32'</span>);
- 0036 version = header(2);
- 0037 freq = header(35); <span class="comment">% frequency</span>
- 0038 ndsp = header(36); <span class="comment">% number of dsp channels</span>
- 0039 nevents = header(37); <span class="comment">% number of external events</span>
- 0040 nslow = header(38); <span class="comment">% number of slow channels</span>
- 0041 npw = header(39); <span class="comment">% number of points in wave</span>
- 0042 npr = header(40); <span class="comment">% number of points before threshold</span>
- 0043 disp(strcat(<span class="string">'version = '</span>, num2str(version)));
- 0044 disp(strcat(<span class="string">'frequency = '</span>, num2str(freq)));
- 0045 disp(strcat(<span class="string">'number of DSP headers = '</span>, num2str(ndsp)));
- 0046 disp(strcat(<span class="string">'number of Event headers = '</span>, num2str(nevents)));
- 0047 disp(strcat(<span class="string">'number of A/D headers = '</span>, num2str(nslow)));
- 0048 tscounts = fread(fid, [5, 130], <span class="string">'int32'</span>);
- 0049 wfcounts = fread(fid, [5, 130], <span class="string">'int32'</span>);
- 0050 evcounts = fread(fid, [1, 512], <span class="string">'int32'</span>);
- 0051 <span class="keyword">if</span> fullread > 0
- 0052 <span class="comment">% reset counters</span>
- 0053 tscounts = zeros(5, 130);
- 0054 wfcounts = zeros(5, 130);
- 0055 evcounts = zeros(1, 512);
- 0056 <span class="comment">% skip variable headers</span>
- 0057 fseek(fid, 1020*ndsp + 296*nevents + 296*nslow, <span class="string">'cof'</span>);
- 0058 record = 0;
- 0059 <span class="keyword">while</span> feof(fid) == 0
- 0060 type = fread(fid, 1, <span class="string">'int16'</span>);
- 0061 upperbyte = fread(fid, 1, <span class="string">'int16'</span>);
- 0062 timestamp = fread(fid, 1, <span class="string">'int32'</span>);
- 0063 channel = fread(fid, 1, <span class="string">'int16'</span>);
- 0064 unit = fread(fid, 1, <span class="string">'int16'</span>);
- 0065 nwf = fread(fid, 1, <span class="string">'int16'</span>);
- 0066 nwords = fread(fid, 1, <span class="string">'int16'</span>);
- 0067 toread = nwords;
- 0068 <span class="keyword">if</span> toread > 0
- 0069 wf = fread(fid, toread, <span class="string">'int16'</span>);
- 0070 <span class="keyword">end</span>
- 0071 <span class="keyword">if</span> type == 1
- 0072 tscounts(unit+1, channel+1) = tscounts(unit+1, channel+1) + 1;
- 0073 <span class="keyword">if</span> toread > 0
- 0074 wfcounts(unit+1, channel+1) = wfcounts(unit+1, channel+1) + 1;
- 0075 <span class="keyword">end</span>
- 0076 <span class="keyword">end</span>
- 0077 <span class="keyword">if</span> type == 4
- 0078 evcounts(channel+1) = evcounts(channel+1) + 1;
- 0079 <span class="keyword">end</span>
- 0080
- 0081 record = record + 1;
- 0082 <span class="keyword">if</span> feof(fid) == 1
- 0083 <span class="keyword">break</span>
- 0084 <span class="keyword">end</span>
- 0085 <span class="keyword">end</span>
- 0086 disp(strcat(<span class="string">'number of records = '</span>, num2str(record)));
- 0087 <span class="keyword">end</span>
- 0088 disp(<span class="string">' '</span>);
- 0089 disp(<span class="string">' Timestamps:'</span>);
- 0090 disp(<span class="string">' ch unit count'</span>);
- 0091 <span class="keyword">for</span> i=1:130
- 0092 <span class="keyword">for</span> j=1:5
- 0093 <span class="keyword">if</span> tscounts(j, i) > 0
- 0094 disp(sprintf(<span class="string">'%3d %4d %6d'</span>, i-1, j-1, tscounts(j, i)));
- 0095 <span class="keyword">end</span>
- 0096 <span class="keyword">end</span>
- 0097 <span class="keyword">end</span>
- 0098
- 0099 disp(<span class="string">' '</span>);
- 0100 disp(<span class="string">' Waveforms:'</span>);
- 0101 disp(<span class="string">' ch unit count'</span>);
- 0102 <span class="keyword">for</span> i=1:130
- 0103 <span class="keyword">for</span> j=1:5
- 0104 <span class="keyword">if</span> wfcounts(j, i) > 0
- 0105 disp(sprintf(<span class="string">'%3d %4d %6d'</span>, i-1, j-1, wfcounts(j, i)));
- 0106 <span class="keyword">end</span>
- 0107 <span class="keyword">end</span>
- 0108 <span class="keyword">end</span>
- 0109
- 0110 disp(<span class="string">' '</span>);
- 0111 disp(<span class="string">' Events:'</span>);
- 0112 disp(<span class="string">' ch count'</span>);
- 0113 <span class="keyword">for</span> i=1:300
- 0114 <span class="keyword">if</span> evcounts(i) > 0
- 0115 disp(sprintf(<span class="string">'%3d %6d'</span>, i-1, evcounts(i)));
- 0116 <span class="keyword">end</span>
- 0117 <span class="keyword">end</span>
- 0118
- 0119 disp(<span class="string">' '</span>);
- 0120 disp(<span class="string">' A/D channels:'</span>);
- 0121 disp(<span class="string">' ch count'</span>);
- 0122 <span class="keyword">for</span> i=301:364
- 0123 <span class="keyword">if</span> evcounts(i) > 0
- 0124 disp(sprintf(<span class="string">'%3d %6d'</span>, i-301, evcounts(i)));
- 0125 <span class="keyword">end</span>
- 0126 <span class="keyword">end</span>
- 0127
- 0128
- 0129 fclose(fid);</pre></div>
- <hr><address>Generated on Fri 12-Aug-2011 11:36:15 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> © 2005</address>
- </body>
- </html>
|