plx_info.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/REC-html40/loose.dtd">
  3. <html>
  4. <head>
  5. <title>Description of plx_info</title>
  6. <meta name="keywords" content="plx_info">
  7. <meta name="description" content="plx_info(filename, fullread) -- read and display .plx file info">
  8. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  9. <meta name="generator" content="m2html &copy; 2005 Guillaume Flandin">
  10. <meta name="robots" content="index, follow">
  11. <link type="text/css" rel="stylesheet" href="../../../m2html.css">
  12. <script type="text/javascript">
  13. if (top.frames.length == 0) { top.location = "../../../index.html"; };
  14. </script>
  15. </head>
  16. <body>
  17. <a name="_top"></a>
  18. <!-- ../../menu.html chronux_2_10 --><!-- ../menu.html dataio --><!-- menu.html ReadingPLXandDDTfilesinMatlab -->
  19. <h1>plx_info
  20. </h1>
  21. <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
  22. <div class="box"><strong>plx_info(filename, fullread) -- read and display .plx file info</strong></div>
  23. <h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
  24. <div class="box"><strong>function [tscounts, wfcounts, evcounts] = plx_info(filename, fullread) </strong></div>
  25. <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
  26. <div class="fragment"><pre class="comment"> plx_info(filename, fullread) -- read and display .plx file info
  27. [tscounts, wfcounts] = plx_info(filename, fullread)
  28. INPUT:
  29. filename - if empty string, will use File Open dialog
  30. fullread - if 0, reads only the file header
  31. if 1, reads all the file
  32. OUTPUT:
  33. tscounts - 5x130 array of timestamp counts
  34. tscounts(i, j) is the number of timestamps for channel i, unit j
  35. wfcounts - 5x130 array of waveform counts
  36. wfcounts(i, j) is the number of waveforms for channel i, unit j
  37. evcounts - 1x512 array of external event counts
  38. evcounts(i) is the number of events for channel i</pre></div>
  39. <!-- crossreference -->
  40. <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
  41. This function calls:
  42. <ul style="list-style-image:url(../../../matlabicon.gif)">
  43. </ul>
  44. This function is called by:
  45. <ul style="list-style-image:url(../../../matlabicon.gif)">
  46. </ul>
  47. <!-- crossreference -->
  48. <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
  49. <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [tscounts, wfcounts, evcounts] = plx_info(filename, fullread)</a>
  50. 0002 <span class="comment">% plx_info(filename, fullread) -- read and display .plx file info</span>
  51. 0003 <span class="comment">%</span>
  52. 0004 <span class="comment">% [tscounts, wfcounts] = plx_info(filename, fullread)</span>
  53. 0005 <span class="comment">%</span>
  54. 0006 <span class="comment">% INPUT:</span>
  55. 0007 <span class="comment">% filename - if empty string, will use File Open dialog</span>
  56. 0008 <span class="comment">% fullread - if 0, reads only the file header</span>
  57. 0009 <span class="comment">% if 1, reads all the file</span>
  58. 0010 <span class="comment">% OUTPUT:</span>
  59. 0011 <span class="comment">% tscounts - 5x130 array of timestamp counts</span>
  60. 0012 <span class="comment">% tscounts(i, j) is the number of timestamps for channel i, unit j</span>
  61. 0013 <span class="comment">% wfcounts - 5x130 array of waveform counts</span>
  62. 0014 <span class="comment">% wfcounts(i, j) is the number of waveforms for channel i, unit j</span>
  63. 0015 <span class="comment">% evcounts - 1x512 array of external event counts</span>
  64. 0016 <span class="comment">% evcounts(i) is the number of events for channel i</span>
  65. 0017
  66. 0018 <span class="keyword">if</span>(nargin ~= 2)
  67. 0019 disp(<span class="string">'2 input arguments are required'</span>)
  68. 0020 <span class="keyword">return</span>
  69. 0021 <span class="keyword">end</span>
  70. 0022
  71. 0023 <span class="keyword">if</span>(isempty(filename))
  72. 0024 [fname, pathname] = uigetfile(<span class="string">'*.plx'</span>, <span class="string">'Select a plx file'</span>);
  73. 0025 filename = strcat(pathname, fname);
  74. 0026 <span class="keyword">end</span>
  75. 0027 fid = fopen(filename, <span class="string">'r'</span>);
  76. 0028
  77. 0029 <span class="keyword">if</span>(fid == -1)
  78. 0030 disp(<span class="string">'cannot open file'</span>);
  79. 0031 <span class="keyword">return</span>
  80. 0032 <span class="keyword">end</span>
  81. 0033
  82. 0034 disp(strcat(<span class="string">'file = '</span>, filename));
  83. 0035 header = fread(fid, 64, <span class="string">'int32'</span>);
  84. 0036 version = header(2);
  85. 0037 freq = header(35); <span class="comment">% frequency</span>
  86. 0038 ndsp = header(36); <span class="comment">% number of dsp channels</span>
  87. 0039 nevents = header(37); <span class="comment">% number of external events</span>
  88. 0040 nslow = header(38); <span class="comment">% number of slow channels</span>
  89. 0041 npw = header(39); <span class="comment">% number of points in wave</span>
  90. 0042 npr = header(40); <span class="comment">% number of points before threshold</span>
  91. 0043 disp(strcat(<span class="string">'version = '</span>, num2str(version)));
  92. 0044 disp(strcat(<span class="string">'frequency = '</span>, num2str(freq)));
  93. 0045 disp(strcat(<span class="string">'number of DSP headers = '</span>, num2str(ndsp)));
  94. 0046 disp(strcat(<span class="string">'number of Event headers = '</span>, num2str(nevents)));
  95. 0047 disp(strcat(<span class="string">'number of A/D headers = '</span>, num2str(nslow)));
  96. 0048 tscounts = fread(fid, [5, 130], <span class="string">'int32'</span>);
  97. 0049 wfcounts = fread(fid, [5, 130], <span class="string">'int32'</span>);
  98. 0050 evcounts = fread(fid, [1, 512], <span class="string">'int32'</span>);
  99. 0051 <span class="keyword">if</span> fullread &gt; 0
  100. 0052 <span class="comment">% reset counters</span>
  101. 0053 tscounts = zeros(5, 130);
  102. 0054 wfcounts = zeros(5, 130);
  103. 0055 evcounts = zeros(1, 512);
  104. 0056 <span class="comment">% skip variable headers</span>
  105. 0057 fseek(fid, 1020*ndsp + 296*nevents + 296*nslow, <span class="string">'cof'</span>);
  106. 0058 record = 0;
  107. 0059 <span class="keyword">while</span> feof(fid) == 0
  108. 0060 type = fread(fid, 1, <span class="string">'int16'</span>);
  109. 0061 upperbyte = fread(fid, 1, <span class="string">'int16'</span>);
  110. 0062 timestamp = fread(fid, 1, <span class="string">'int32'</span>);
  111. 0063 channel = fread(fid, 1, <span class="string">'int16'</span>);
  112. 0064 unit = fread(fid, 1, <span class="string">'int16'</span>);
  113. 0065 nwf = fread(fid, 1, <span class="string">'int16'</span>);
  114. 0066 nwords = fread(fid, 1, <span class="string">'int16'</span>);
  115. 0067 toread = nwords;
  116. 0068 <span class="keyword">if</span> toread &gt; 0
  117. 0069 wf = fread(fid, toread, <span class="string">'int16'</span>);
  118. 0070 <span class="keyword">end</span>
  119. 0071 <span class="keyword">if</span> type == 1
  120. 0072 tscounts(unit+1, channel+1) = tscounts(unit+1, channel+1) + 1;
  121. 0073 <span class="keyword">if</span> toread &gt; 0
  122. 0074 wfcounts(unit+1, channel+1) = wfcounts(unit+1, channel+1) + 1;
  123. 0075 <span class="keyword">end</span>
  124. 0076 <span class="keyword">end</span>
  125. 0077 <span class="keyword">if</span> type == 4
  126. 0078 evcounts(channel+1) = evcounts(channel+1) + 1;
  127. 0079 <span class="keyword">end</span>
  128. 0080
  129. 0081 record = record + 1;
  130. 0082 <span class="keyword">if</span> feof(fid) == 1
  131. 0083 <span class="keyword">break</span>
  132. 0084 <span class="keyword">end</span>
  133. 0085 <span class="keyword">end</span>
  134. 0086 disp(strcat(<span class="string">'number of records = '</span>, num2str(record)));
  135. 0087 <span class="keyword">end</span>
  136. 0088 disp(<span class="string">' '</span>);
  137. 0089 disp(<span class="string">' Timestamps:'</span>);
  138. 0090 disp(<span class="string">' ch unit count'</span>);
  139. 0091 <span class="keyword">for</span> i=1:130
  140. 0092 <span class="keyword">for</span> j=1:5
  141. 0093 <span class="keyword">if</span> tscounts(j, i) &gt; 0
  142. 0094 disp(sprintf(<span class="string">'%3d %4d %6d'</span>, i-1, j-1, tscounts(j, i)));
  143. 0095 <span class="keyword">end</span>
  144. 0096 <span class="keyword">end</span>
  145. 0097 <span class="keyword">end</span>
  146. 0098
  147. 0099 disp(<span class="string">' '</span>);
  148. 0100 disp(<span class="string">' Waveforms:'</span>);
  149. 0101 disp(<span class="string">' ch unit count'</span>);
  150. 0102 <span class="keyword">for</span> i=1:130
  151. 0103 <span class="keyword">for</span> j=1:5
  152. 0104 <span class="keyword">if</span> wfcounts(j, i) &gt; 0
  153. 0105 disp(sprintf(<span class="string">'%3d %4d %6d'</span>, i-1, j-1, wfcounts(j, i)));
  154. 0106 <span class="keyword">end</span>
  155. 0107 <span class="keyword">end</span>
  156. 0108 <span class="keyword">end</span>
  157. 0109
  158. 0110 disp(<span class="string">' '</span>);
  159. 0111 disp(<span class="string">' Events:'</span>);
  160. 0112 disp(<span class="string">' ch count'</span>);
  161. 0113 <span class="keyword">for</span> i=1:300
  162. 0114 <span class="keyword">if</span> evcounts(i) &gt; 0
  163. 0115 disp(sprintf(<span class="string">'%3d %6d'</span>, i-1, evcounts(i)));
  164. 0116 <span class="keyword">end</span>
  165. 0117 <span class="keyword">end</span>
  166. 0118
  167. 0119 disp(<span class="string">' '</span>);
  168. 0120 disp(<span class="string">' A/D channels:'</span>);
  169. 0121 disp(<span class="string">' ch count'</span>);
  170. 0122 <span class="keyword">for</span> i=301:364
  171. 0123 <span class="keyword">if</span> evcounts(i) &gt; 0
  172. 0124 disp(sprintf(<span class="string">'%3d %6d'</span>, i-301, evcounts(i)));
  173. 0125 <span class="keyword">end</span>
  174. 0126 <span class="keyword">end</span>
  175. 0127
  176. 0128
  177. 0129 fclose(fid);</pre></div>
  178. <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> &copy; 2005</address>
  179. </body>
  180. </html>