BlockVectorHeader.m 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. classdef BlockVectorHeader < Entry
  2. %BlockVectorHeader Primary data regarding a BlockVectorSet of Data
  3. % This class contains the basic information about an entry of
  4. % Block Vector Data that is necessary to load it as a series of
  5. % vectors.
  6. %
  7. % SamplingFrequency: Recording sampling rate (in Hz) of the data
  8. %
  9. % VoltageScale: Voltage (in Volts) of the conversion factor
  10. % from the stored int16's in the Data vectors
  11. % to a real voltage value. i.e. Signal =
  12. % double(VoltageScale) * Waveform.Data
  13. %
  14. % FileStartTime: DateTime (See DateTime.m) when this
  15. % recording started
  16. %
  17. % ExperimentStartTime: DateTime (See DateTime.m) when the
  18. % device that acquired this data started
  19. % aquiring
  20. %
  21. % FirstBlock: Pointer (# of bytes frome the beginning of
  22. % the file) to the start of the associated
  23. % BlockVectorData entry
  24. %
  25. % NumChannelsPerBlock: Number of Channels of data stored in every
  26. % block of the data.
  27. %
  28. % NumSamplesPerBlock: Number of samples in every channel-wise
  29. % vector of the block.
  30. %
  31. % BlockHeaderSize: Number of bytes used for header of each
  32. % block.
  33. %
  34. properties (Constant = true, GetAccess = public)
  35. SIZE = 64;
  36. end
  37. properties(GetAccess = public, SetAccess = private)
  38. SamplingFrequency
  39. VoltageScale
  40. FileStartTime
  41. ExperimentStartTime
  42. FirstBlock
  43. NumChannelsPerBlock
  44. NumSamplesPerBlock
  45. BlockHeaderSize
  46. end
  47. methods
  48. function this = BlockVectorHeader(aEntryRecord, aFileID)
  49. this = this@Entry(aEntryRecord, int64(ftell(aFileID)));
  50. this.SamplingFrequency = fread(aFileID, 1, 'double=>double');
  51. this.VoltageScale = fread(aFileID, 1, 'double=>double');
  52. this.FileStartTime = DateTime(aFileID);
  53. this.ExperimentStartTime = DateTime(aFileID);
  54. this.FirstBlock = fread(aFileID, 1, 'int64=>int64');
  55. this.NumChannelsPerBlock = fread(aFileID, 1, 'uint32=>uint32');
  56. this.NumSamplesPerBlock = fread(aFileID, 1, 'uint32=>uint32');
  57. this.BlockHeaderSize = fread(aFileID, 1, 'uint32=>uint32');
  58. if(this.EntryRecord.Length ~= -1 && ...
  59. ftell(aFileID) ~= (this.Start + this.EntryRecord.Length))
  60. error('Unexpected BlockVectorHeader length')
  61. end
  62. end
  63. end
  64. methods (Static = true)
  65. function this = Generate(...
  66. aFileID, ...
  67. aSamplingFrequency, ...
  68. aVoltageScale, ...
  69. aFileStartTime, ...
  70. aExperimentStartTime, ...
  71. aFirstBlock, ...
  72. aNumChannelsPerBlock, ...
  73. aNumSamplesPerBlock, ...
  74. aBlockHeaderSize)
  75. this = BlockVectorHeader(EntryRecord(EntryRecordID.BlockVectorHeader, -1), aFileID);
  76. this.SamplingFrequency = aSamplingFrequency;
  77. this.VoltageScale = aVoltageScale;
  78. this.FileStartTime = aFileStartTime;
  79. this.ExperimentStartTime = aExperimentStartTime;
  80. this.FirstBlock = aFirstBlock;
  81. this.NumChannelsPerBlock = aNumChannelsPerBlock;
  82. this.NumSamplesPerBlock = aNumSamplesPerBlock;
  83. this.BlockHeaderSize = aBlockHeaderSize;
  84. end
  85. end
  86. end