PageRenderTime 27ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/utility/getpc6header.m

http://acq3.googlecode.com/
MATLAB | 237 lines | 189 code | 21 blank | 27 comment | 1 complexity | 8f55544497e7414149de3e1dcd72cce6 MD5 | raw file
  1. function [pc6h] = getpc6header(fid);
  2. %GETPC6HEADER Get header information from a pClamp 6.x Axon Binary File (ABF).
  3. % PC6H = GETPC6HEADER(FID) returns a structure with all header information.
  4. % ABF files should be opened with the appropriate machineformat (IEEE floating
  5. % point with little-endian byte ordering, e.g., fopen(file,'r','l').
  6. % For a description of the fields, see the "abf.asc" file included with the
  7. % "Axon PC File Support Package for Developers".
  8. %
  9. % FID is an integer file identifier obtained from FOPEN.
  10. % Carsten Hohnke 12/99
  11. % Mods and updated for version 1.5, P. Manis, 2/2002
  12. %
  13. if fid == -1, % Check for invalid fid.
  14. error('getpc6header: Invalid fid.');
  15. end
  16. fseek(fid,0,'bof'); % Set the pointer to beginning of the file.
  17. pc6h.size=2048;
  18. % file ID and size information
  19. pc6h.sFileType=fread(fid,4,'char'); % pointing to byte 0 ('ABF')
  20. pc6h.fFileVersionNumber=fread(fid,1,'float'); % 4 (1.5 for current file)
  21. pc6h.nOperationMode=fread(fid,1,'short'); % 8 (3 = gapfree).
  22. pc6h.lActualAcqLength=fread(fid,1,'int'); % 10 (total ADC samples in file)
  23. pc6h.nNumPointsIgnored=fread(fid,1,'short'); % 14 (0)
  24. pc6h.lActualEpisodes=fread(fid,1,'int'); % 16 (1 for gapfree, otherwise # sweeps)
  25. pc6h.lFileStartDate=fread(fid,1,'int'); % 20 (yymmdd)
  26. pc6h.lFileStartTime=fread(fid,1,'int'); % 24 (seconds past midnight)
  27. pc6h.lStopwatchTime=fread(fid,1,'int'); % 28 (0)
  28. pc6h.fHeaderVersionNumber=fread(fid,1,'float'); % 32 (1.5)
  29. pc6h.nFileType=fread(fid,1,'short'); % 36 (1 = ABF)
  30. pc6h.nMSBinFormat=fread(fid,1,'short'); % 38 (0 for IEEE format...)
  31. % file structure
  32. pc6h.lDataSectionPtr=fread(fid,1,'int'); % 40 (block number of DATA section)
  33. pc6h.lTagSectionPtr=fread(fid,1,'int'); % 44 (block number of Tag section)
  34. pc6h.lNumTagEntries=fread(fid,1,'int'); % 48 (Number of Tag entries)
  35. pc6h.lLongDescriptionPtr=fread(fid,1,'int'); % 52 (Block number of Scope Config Pointer)
  36. pc6h.lLongDescriptionLines=fread(fid,1,'int'); % 56 (Number of Scope Config sections)
  37. pc6h.lDACFilePtr=fread(fid,1,'int'); % 60 (block number of start of DAC section)
  38. pc6h.lDACFileNumEpisodes=fread(fid,1,'int'); % 64 (number of sweeps in DAC sectoin)
  39. pc6h.sUnused68=fread(fid,4,'char'); % 4char % 68 (unused)
  40. pc6h.lDeltaArrayPtr=fread(fid,1,'int'); % 72 (block number of Delta array section)
  41. pc6h.lNumDeltas=fread(fid,1,'int'); % 76 (number of entries in Delta array section)
  42. pc6h.lNotebookPtr=fread(fid,1,'int'); % 80 (block number of voice tag section)
  43. pc6h.lNotebookManEntries=fread(fid,1,'int'); % 84 (number of voice tag entries)
  44. pc6h.lNotebookAutoEntries=fread(fid,1,'int'); % 88 (unused)
  45. pc6h.lSynchArrayPtr=fread(fid,1,'int'); % 92 (block number of synch array section_
  46. pc6h.lSynchArraySize=fread(fid,1,'int'); % 96 (number of PAIRS of entries in synch array section)
  47. pc6h.nDataFormat=fread(fid,1,'short'); % 100 (data representation: 0 = 2-byte integer, 1 = IEEE 4 byte float)
  48. pc6h.nSimultaneousScan=fread(fid, 1, 'short'); % 102 (ADC channel scanning mode 0=mux, 1=simul; NOT IMPLEMENTED)
  49. pc6h.sUnused102=fread(fid,16,'char'); % 18char % 102 (
  50. % Trial hierarhcy information
  51. pc6h.nADCNumChannels=fread(fid,1,'short'); % 120 (number of analog input channels sampled)
  52. pc6h.fADCSampleInterval=fread(fid,1,'float'); % 122 (interval between multiplexed channels)
  53. pc6h.fADCSecondSampleInterval=fread(fid,1,'float'); % % 126 (when switching clocks)
  54. pc6h.fSynchTimeUnit=fread(fid,1,'float'); % 130 (synch array time unit: 0 = samples, nn = usec. normally 0)
  55. pc6h.fSecondsPerRun=fread(fid,1,'float'); % 134 (gapfree: duration of acq; otherwise set to -1 (ignore and refer to lEpisodesPerRun))
  56. pc6h.lNumSamplesPerEpisode=fread(fid,1,'int'); % 138 (# muxed ADC samples per sweep if mode is 2, 4 or 5; undefined if mode is 1 or 3)
  57. pc6h.lPreTriggerSamples=fread(fid,1,'int'); % 142 (pretrigger intervals = 0)
  58. pc6h.lEpisodesPerRun=fread(fid,1,'int'); % 146 (sweeps per run. if gapfree, set to 1.
  59. pc6h.lRunsPerTrial=fread(fid,1,'int'); % 150 (runs per trial. if gapfree, set to 1.
  60. pc6h.lNumberOfTrials=fread(fid,1,'int'); % 154 (set to 1)
  61. pc6h.nAveragingMode=fread(fid,1,'short'); % 158 (0 = no averaging)
  62. pc6h.nUndoRunCount=fread(fid,1,'short'); % 160 set to -1
  63. pc6h.nFirstEpisodeInRun=fread(fid,1,'short'); % 162 (set to 1)
  64. pc6h.fTriggerThreshold=fread(fid,1,'float'); % 164 (user units: set to 0)
  65. pc6h.nTriggerSource=fread(fid,1,'short'); % 168 (set to -1 for external, > 0 for physical channel number, -3 for start-to-start interval)
  66. pc6h.nTriggerAction=fread(fid,1,'short'); % 170 (0 = one sweep, 1 = one run, 2 = one trial)
  67. pc6h.nTriggerPolarity=fread(fid,1,'short'); % 172 (0 = rising, 1 == falling)
  68. pc6h.fScopeOutputInterval=fread(fid,1,'float'); % 174 (set to 0)
  69. pc6h.fEpisodeStartToStart=fread(fid,1,'float'); % 178 (time between start of sweeps, in seconds = cycle time)
  70. pc6h.fRunStartToStart=fread(fid,1,'float'); % 182 (time between start of runs (seconds)
  71. pc6h.fTrialStartToStart=fread(fid,1,'float'); % 186 (time between trials (seconds)
  72. pc6h.lAverageCount=fread(fid,1,'int'); % 190 (number of runs for each average: set to 1)
  73. pc6h.lClockChange=fread(fid,1,'int'); % 194 (# samples after which second sampling interval begins: set to -1)
  74. pc6h.nAutoTriggerStrategy=fread(fid,1,'short'); % 2char % 198 (0 = do not auto trig; 1 = autotrig; only when nOpmode = highspeed osc).
  75. % display parameters
  76. pc6h.nDrawingStrategy=fread(fid,1,'short'); % 200 (0 = not draw, 1 = update immed.... set to 0)
  77. pc6h.nTiledDisplay=fread(fid,1,'short'); % 202 (set to 0)
  78. pc6h.nEraseStrategy=fread(fid,1,'short'); % 204 (set to 2)
  79. pc6h.nDataDisplayMode=fread(fid,1,'short'); % 206 (set to 1 = lines)
  80. pc6h.lDisplayAverageUpdate=fread(fid,1,'int'); % 208 (set to -1)
  81. pc6h.nChannelStatsStrategy=fread(fid,1,'short'); % 212 (set to 0)
  82. pc6h.lCalculationPeriod=fread(fid,1,'int'); % 214 (set to 16384)
  83. pc6h.lSamplesPerTrace=fread(fid,1,'int'); % 218 (number of multiplexed adc samples displayed per trace)
  84. pc6h.lStartDisplayNum=fread(fid,1,'int'); % 222 (set to 1)
  85. pc6h.lFinishDisplayNum=fread(fid,1,'int'); % 226 (set to 0 to finish at end of sweep)
  86. pc6h.nMultiColor=fread(fid,1,'short'); % 230 (set to 1 for multicolor)
  87. pc6h.nShowPNRawData=fread(fid,1,'short'); % 232 (set to 0 for display corrected data
  88. pc6h.fStatisticsPeriod=fread(fid, 1, 'float'); % 234 set to 0
  89. pc6h.lStatisticsMeasurements=fread(fid, 1, 'long'); % 238 set to 0
  90. pc6h.nstatisticsSaveStrategy=fread(fid, 1, 'short'); % 242 set to 0 for auto
  91. % hardware information
  92. pc6h.fADCRange=fread(fid,1,'float'); % 244 ADC-full scale (5 or 10 V)
  93. pc6h.fDACRange=fread(fid,1,'float'); % 248 DAC full scale (10V)
  94. pc6h.lADCResolution=fread(fid,1,'int'); % 252 number of adc counts corresponding to full scale voltage: 2048 or 16384
  95. pc6h.lDACResolution=fread(fid,1,'int'); % 256 dac counts for full scale....
  96. % Environment information
  97. pc6h.nExperimentType=fread(fid,1,'short'); % 260 % 0 for voltage clamp, 1 for current clamp
  98. pc6h.nAutosampleEnable=fread(fid,1,'short'); % 262 % set to 0 (disabled)
  99. pc6h.nAutosampleADCNum=fread(fid,1,'short'); % 264 % physical sample number for autosample: set to 1
  100. pc6h.nAutosampleInstrument=fread(fid,1,'short'); % 266 % instrument: set to 0 (unknown)
  101. pc6h.fAutosampleAdditGain=fread(fid,1,'float'); % 268 % additional gain multiplier (set to gain reading or 1)
  102. pc6h.fAutosampleFilter=fread(fid,1,'float'); % 272 % low pass filter (set to LPF reading or 100000)
  103. pc6h.fAutosampleMembraneCapacitance=fread(fid,1,'float'); % 276 cap : set to 0 (not read)
  104. pc6h.nManualInfoStrategy=fread(fid,1,'short'); % 280 set to 0.
  105. pc6h.fCellID1=fread(fid,1,'float'); % 282 numeric cell identifier (set to 1)
  106. pc6h.fCellID2=fread(fid,1,'float'); % 286 numeric identifier (set to 0)
  107. pc6h.fCellID3=fread(fid,1,'float'); % 290 numeric identifier (set to 0)
  108. pc6h.sCreatorInfo=fread(fid,16,'char'); % 16char % 294 write as "Clampex 6.0"
  109. pc6h.sFileComment=fread(fid,56,'char'); % 56char % 310 56 byte ascii comment string (copy comment here)
  110. pc6h.sUnused366=fread(fid,12,'char'); % 12char % 366 unused
  111. % Multichannel information
  112. pc6h.nADCPtoLChannelMap=fread(fid,16,'short'); % 378 physical to logical channel map (end with -1 if fewer than 16)
  113. pc6h.nADCSamplingSeq=fread(fid,16,'short'); % 410 ADC sampling sequence (pad with -1 if fewer than 16)
  114. pc6h.sADCChannelName=fread(fid,16*10,'char'); % 442 channel names (set to spaces)
  115. pc6h.sADCUnits=fread(fid,16*8,'char'); % 8char % 602 user units for adc (set to spaces)
  116. pc6h.fADCProgrammableGain=fread(fid,16,'float'); % 730 adc programmable gain (read it or set to 1)
  117. pc6h.fADCDisplayAmplification=fread(fid,16,'float'); % 794 (set to 1: array)
  118. pc6h.fADCDisplayOffset=fread(fid,16,'float'); % 858 (set to 0: array)
  119. pc6h.fInstrumentScaleFactor=fread(fid,16,'float'); % 922 (set to 1: array)
  120. pc6h.fInstrumentOffset=fread(fid,16,'float'); % 986 (set to 0 array)
  121. pc6h.fSignalGain=fread(fid,16,'float'); % 1050 (set to 1 array)
  122. pc6h.fSignalOffset=fread(fid,16,'float'); % 1114 (set to 0 array)
  123. pc6h.fSignalLowpassFilter=fread(fid,16,'float'); % 1178 (set to 100000 array)
  124. pc6h.fSignalHighpassFilter=fread(fid,16,'float'); % 1242 (set to 0 array)
  125. pc6h.sDACChannelName=fread(fid,4*10,'char'); % 1306 (set to spaces)
  126. pc6h.sDACChannelUnits=fread(fid,4*8,'char'); % 8char % 1346 (set to spaces)
  127. pc6h.fDACScaleFactor=fread(fid,4,'float'); % 1378 (dac channel gains: set to 1)
  128. pc6h.fDACHoldingLevel=fread(fid,4,'float'); % 1394 (set to 0)
  129. pc6h.nSignalType=fread(fid,1,'short'); % 12char % 1410 (set to 0 for no signal conditioner)
  130. pc6h.sUnused1412=fread(fid,10,'char'); % 10char % 1412
  131. % synchronous timer outputs
  132. pc6h.nOUTEnable=fread(fid,1,'short'); % 1422 % set to 0
  133. pc6h.nSampleNumberOUT1=fread(fid,1,'short'); % 1424 % set to 0
  134. pc6h.nSampleNumberOUT2=fread(fid,1,'short'); % 1426 % set to 0
  135. pc6h.nFirstEpisodeOUT=fread(fid,1,'short'); % 1428 % set to 0
  136. pc6h.nLastEpisodeOUT=fread(fid,1,'short'); % 1430 % set to 0
  137. pc6h.nPulseSamplesOUT1=fread(fid,1,'short'); % 1432 % set to 0
  138. pc6h.nPulseSamplesOUT2=fread(fid,1,'short'); % 1434 % set to 0
  139. %Epoch waveform and pulses
  140. pc6h.nDigitalEnable=fread(fid,1,'short'); % 1436 % set to 0
  141. pc6h.nWaveformSource=fread(fid,1,'short'); % 1438 % set to 0
  142. pc6h.nActiveDACChannel=fread(fid,1,'short'); % 1440 % set to 0
  143. pc6h.nInterEpisodeLevel=fread(fid,1,'short'); % 1442 % set to 0
  144. pc6h.nEpochType=fread(fid,10,'short'); % 1444 % set to 0
  145. pc6h.fEpochInitLevel=fread(fid,10,'float'); % 1464 % set to 0
  146. pc6h.fEpochLevelInc=fread(fid,10,'float'); % 1504 % set to 0
  147. pc6h.nEpochInitDuration=fread(fid,10,'short'); % 1544 % set to 0
  148. pc6h.nEpochDurationInc=fread(fid,10,'short'); % 1564 % set to 0
  149. pc6h.nDigitalHolding=fread(fid,1,'short'); % 1584 % set to 0
  150. pc6h.nDigitalInterEpisode=fread(fid,1,'short'); % 1586 % set to 0
  151. pc6h.nDigitalValue=fread(fid,10,'short'); % 1588 ^% set to 0
  152. pc6h.fWaveformOffset=fread(fid,1,'float'); % 1608 % set to 0
  153. pc6h.sUnused1612=fread(fid,8,'char'); % 8char % 1612
  154. % DAC output file
  155. pc6h.fDACFileScale=fread(fid,1,'float'); % 1620 % set to 1
  156. pc6h.fDACFileOffset=fread(fid,1,'float'); % 1624 % set to 0
  157. pc6h.sUnused1628=fread(fid,2,'char'); % 2char % 1628 % unused
  158. pc6h.nDACFileEpisodeNum=fread(fid,1,'short'); % 1630 set to 0
  159. pc6h.nDACFileADCNum=fread(fid,1,'short'); % 1632 set to 0
  160. pc6h.sDACFileName=fread(fid,12,'char'); % 12char % 1634 % set to spaces
  161. pc6h.sDACFilePath=fread(fid,60,'char'); % 60char % 1646 set to spaces
  162. pc6h.sUnused1706=fread(fid,12,'char'); % 12char % 1706
  163. % Conditioning pulse train
  164. pc6h.nConditEnable=fread(fid,1,'short'); % 1718 % set to 0
  165. pc6h.nConditChannel=fread(fid,1,'short'); % 1720 0
  166. pc6h.lConditNumPulses=fread(fid,1,'int'); % 1722 0
  167. pc6h.fBaselineDuration=fread(fid,1,'float'); % 1726 0
  168. pc6h.fBaselineLevel=fread(fid,1,'float'); % 1730 0
  169. pc6h.fStepDuration=fread(fid,1,'float'); % 1734 0
  170. pc6h.fStepLevel=fread(fid,1,'float'); % 1738 0
  171. pc6h.fPostTrainPeriod=fread(fid,1,'float'); % 1742 0
  172. pc6h.fPostTrainLevel=fread(fid,1,'float'); % 1746 0
  173. pc6h.sUnused1750=fread(fid,12,'char'); % 12char % 1750 0
  174. % variable parameter user list
  175. pc6h.nParamToVary=fread(fid,1,'short'); % 1762 % set to 0
  176. pc6h.sParamValueList=fread(fid,80,'char'); % 80char % 1764 % set to 0
  177. % statistics measurement
  178. pc6h.nAutopeakEnable=fread(fid,1,'short'); % 1844 % set to 0
  179. pc6h.nAutopeakPolarity=fread(fid,1,'short'); % 1846 % set to 0
  180. pc6h.nAutopeakADCNum=fread(fid,1,'short'); % 1848 % set to 0
  181. pc6h.nAutopeakSearchMode=fread(fid,1,'short'); % 1850 % set to -1
  182. pc6h.lAutopeakStart=fread(fid,1,'int'); % 1852 % set to 0
  183. pc6h.lAutopeakEnd=fread(fid,1,'int'); % 1856 % set to 0
  184. pc6h.nAutopeakSmoothing=fread(fid,1,'short'); % 1860 % set to 3
  185. pc6h.nAutopeakBaseline=fread(fid,1,'short'); % 1862 % set to =2
  186. pc6h.nAutopeakAverage=fread(fid,1,'short'); % 1864 % set to 0
  187. pc6h.sUnused1866=fread(fid,14,'char'); % 14char % 1866
  188. % Channel arithmetic
  189. pc6h.nArithmeticEnable=fread(fid,1,'short'); % 1880 % % set to 0
  190. pc6h.fArithmeticUpperLimit=fread(fid,1,'float'); % 1882 0
  191. pc6h.fArithmeticLowerLimit=fread(fid,1,'float'); % 1886 0
  192. pc6h.nArithmeticADCNumA=fread(fid,1,'short'); % 1890 0
  193. pc6h.nArithmeticADCNumB=fread(fid,1,'short'); % 1892 0
  194. pc6h.fArithmeticK1=fread(fid,1,'float'); % 1894 0
  195. pc6h.fArithmeticK2=fread(fid,1,'float'); % 1898 0
  196. pc6h.fArithmeticK3=fread(fid,1,'float'); % 1902 0
  197. pc6h.fArithmeticK4=fread(fid,1,'float'); % 1906 0
  198. pc6h.sArithmeticOperator=fread(fid,2,'char'); % 2char % 1910 '+'
  199. pc6h.sArithmeticUnits=fread(fid,8,'char'); % 8char % 1912 % spaces
  200. pc6h.fArithmeticK5=fread(fid,1,'float'); % 1920 0
  201. pc6h.fArithmeticK6=fread(fid,1,'float'); % 1924 0
  202. pc6h.nArithmeticExpression=fread(fid,1,'short'); % 1928 set to 1
  203. pc6h.sUnused1930=fread(fid,2,'char'); % 2char % 1930
  204. % Online subtraction
  205. pc6h.nPNEnable=fread(fid,1,'short'); % 1932 % set to 0
  206. pc6h.nPNPosition=fread(fid,1,'short'); % 1934 % set to 0
  207. pc6h.nPNPolarity=fread(fid,1,'short'); % 1936 % set to -1
  208. pc6h.nPNNumPulses=fread(fid,1,'short'); % 1938 set to 1
  209. pc6h.nPNADCNum=fread(fid,1,'short'); % 1940 set to 1
  210. pc6h.fPNHoldingLevel=fread(fid,1,'float'); % 1942 set to 0
  211. pc6h.fPNSettlingTime=fread(fid,1,'float'); % 1946 set to 1
  212. pc6h.fPNInterpulse=fread(fid,1,'float'); % 1950 set to 1
  213. pc6h.sUnused1954=fread(fid,12,'char'); % 12char % 1954
  214. % Miscellaneous elements placed in "unused space at end of header block"
  215. pc6h.nListEnable=fread(fid,1,'short'); % 1966 set to 0
  216. pc6h.sUnused1966=fread(fid,80,'char'); % 80char % 1968 set to 0's