Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

plx_info.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. function [tscounts, wfcounts, evcounts] = plx_info(filename, fullread)
  2. % plx_info(filename, fullread) -- read and display .plx file info
  3. %
  4. % [tscounts, wfcounts] = plx_info(filename, fullread)
  5. %
  6. % INPUT:
  7. % filename - if empty string, will use File Open dialog
  8. % fullread - if 0, reads only the file header
  9. % if 1, reads all the file
  10. % OUTPUT:
  11. % tscounts - 5x130 array of timestamp counts
  12. % tscounts(i, j) is the number of timestamps for channel i, unit j
  13. % wfcounts - 5x130 array of waveform counts
  14. % wfcounts(i, j) is the number of waveforms for channel i, unit j
  15. % evcounts - 1x512 array of external event counts
  16. % evcounts(i) is the number of events for channel i
  17. if(nargin ~= 2)
  18. disp('2 input arguments are required')
  19. return
  20. end
  21. if(isempty(filename))
  22. [fname, pathname] = uigetfile('*.plx', 'Select a plx file');
  23. filename = strcat(pathname, fname);
  24. end
  25. fid = fopen(filename, 'r');
  26. if(fid == -1)
  27. disp('cannot open file');
  28. return
  29. end
  30. disp(strcat('file = ', filename));
  31. header = fread(fid, 64, 'int32');
  32. version = header(2);
  33. freq = header(35); % frequency
  34. ndsp = header(36); % number of dsp channels
  35. nevents = header(37); % number of external events
  36. nslow = header(38); % number of slow channels
  37. npw = header(39); % number of points in wave
  38. npr = header(40); % number of points before threshold
  39. disp(strcat('version = ', num2str(version)));
  40. disp(strcat('frequency = ', num2str(freq)));
  41. disp(strcat('number of DSP headers = ', num2str(ndsp)));
  42. disp(strcat('number of Event headers = ', num2str(nevents)));
  43. disp(strcat('number of A/D headers = ', num2str(nslow)));
  44. tscounts = fread(fid, [5, 130], 'int32');
  45. wfcounts = fread(fid, [5, 130], 'int32');
  46. evcounts = fread(fid, [1, 512], 'int32');
  47. if fullread > 0
  48. % reset counters
  49. tscounts = zeros(5, 130);
  50. wfcounts = zeros(5, 130);
  51. evcounts = zeros(1, 512);
  52. % skip variable headers
  53. fseek(fid, 1020*ndsp + 296*nevents + 296*nslow, 'cof');
  54. record = 0;
  55. while feof(fid) == 0
  56. type = fread(fid, 1, 'int16');
  57. upperbyte = fread(fid, 1, 'int16');
  58. timestamp = fread(fid, 1, 'int32');
  59. channel = fread(fid, 1, 'int16');
  60. unit = fread(fid, 1, 'int16');
  61. nwf = fread(fid, 1, 'int16');
  62. nwords = fread(fid, 1, 'int16');
  63. toread = nwords;
  64. if toread > 0
  65. wf = fread(fid, toread, 'int16');
  66. end
  67. if type == 1
  68. tscounts(unit+1, channel+1) = tscounts(unit+1, channel+1) + 1;
  69. if toread > 0
  70. wfcounts(unit+1, channel+1) = wfcounts(unit+1, channel+1) + 1;
  71. end
  72. end
  73. if type == 4
  74. evcounts(channel+1) = evcounts(channel+1) + 1;
  75. end
  76. record = record + 1;
  77. if feof(fid) == 1
  78. break
  79. end
  80. end
  81. disp(strcat('number of records = ', num2str(record)));
  82. end
  83. disp(' ');
  84. disp(' Timestamps:');
  85. disp(' ch unit count');
  86. for i=1:130
  87. for j=1:5
  88. if tscounts(j, i) > 0
  89. disp(sprintf('%3d %4d %6d', i-1, j-1, tscounts(j, i)));
  90. end
  91. end
  92. end
  93. disp(' ');
  94. disp(' Waveforms:');
  95. disp(' ch unit count');
  96. for i=1:130
  97. for j=1:5
  98. if wfcounts(j, i) > 0
  99. disp(sprintf('%3d %4d %6d', i-1, j-1, wfcounts(j, i)));
  100. end
  101. end
  102. end
  103. disp(' ');
  104. disp(' Events:');
  105. disp(' ch count');
  106. for i=1:300
  107. if evcounts(i) > 0
  108. disp(sprintf('%3d %6d', i-1, evcounts(i)));
  109. end
  110. end
  111. disp(' ');
  112. disp(' A/D channels:');
  113. disp(' ch count');
  114. for i=301:364
  115. if evcounts(i) > 0
  116. disp(sprintf('%3d %6d', i-301, evcounts(i)));
  117. end
  118. end
  119. fclose(fid);