/external/fieldtrip/trunk/utilities/ft_datatype_spike.m

http://open-realtime-fmri.googlecode.com/ · MATLAB · 104 lines · 17 code · 11 blank · 76 comment · 6 complexity · 000dcfbb2cfa043b06b6c53367a13c2f MD5 · raw file

  1. function spike = ft_datatype_spike(spike, varargin)
  2. % FT_DATATYPE_SPIKE describes the FieldTrip MATLAB structure for spike data
  3. %
  4. % Spike data is characterised as a sparse point-process, i.e. each neuronal
  5. % firing is only represented as the time at which the firing happened.
  6. % Optionally, the spike waveform can also be represented. Using the spike
  7. % waveform, the neuronal firing events can be sorted into their single units.
  8. %
  9. % Spike data is obtained using FT_READ_SPIKE to read it from a Plexon,
  10. % Neuralynx or other animal electrophysiology system file format containing
  11. % spikes.
  12. %
  13. % An example spike data structure is:
  14. %
  15. % label: {'chan1', 'chan2', 'chan3'} the channel labels
  16. % timestamp: {[1x993 uint64] [1x423 uint64] [1x3424 uint64]} timestamp in arbitrary units, depends on the acquisition system
  17. % waveform: {[32x993 double] [32x433 double] [32x3424 double]} spike waveform, here described with 32 samples
  18. % hdr: [1x1 struct] the full header information of the original dataset on disk
  19. %
  20. % The example above contains three spike channels, each with varying numbers of
  21. % detected spikes. The timestamps of the spikes are represented, with their
  22. % waveforms (32 samples per waveform). This type of representation can be seen
  23. % as raw spike data, because there is no reference to the experimental trials.
  24. %
  25. % The spike data representation can also represent spike timepoints in relation
  26. % to the experimental trials, as in this example:
  27. %
  28. % label: {'chan1' 'chan2' 'chan3'} the channel labels
  29. % time: {[50481x1 double] [50562x1 double] [50537x1 double]} the time in the trial for each spike (in seconds)
  30. % trial: {[50481x1 double] [50562x1 double] [50537x1 double]} the trial in which each spike was observed
  31. % trialtime: [100x2 double] the begin- and end-time of each trial (in seconds)
  32. % cfg: [1x1 struct] the configuration used by the function that generated this data structure
  33. %
  34. % Required fields:
  35. % - label, timestamp
  36. %
  37. % Optional fields:
  38. % - waveform, hdr, cfg
  39. %
  40. % Deprecated fields:
  41. % - <unknown>
  42. %
  43. % Obsoleted fields:
  44. % - <unknown>
  45. %
  46. % Revision history:
  47. %
  48. % (2010/latest) Introduced the time and the trialtime fields.
  49. %
  50. % (2007) Introduced the spike data structure.
  51. %
  52. % See also FT_DATATYPE and FT_DATATYPE_xxx
  53. % Copyright (C) 2011, Robert Oostenveld
  54. %
  55. % This file is part of FieldTrip, see http://www.ru.nl/neuroimaging/fieldtrip
  56. % for the documentation and details.
  57. %
  58. % FieldTrip is free software: you can redistribute it and/or modify
  59. % it under the terms of the GNU General Public License as published by
  60. % the Free Software Foundation, either version 3 of the License, or
  61. % (at your option) any later version.
  62. %
  63. % FieldTrip is distributed in the hope that it will be useful,
  64. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  65. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  66. % GNU General Public License for more details.
  67. %
  68. % You should have received a copy of the GNU General Public License
  69. % along with FieldTrip. If not, see <http://www.gnu.org/licenses/>.
  70. %
  71. % $Id: ft_datatype_spike.m 3039 2011-03-02 10:16:32Z jansch $
  72. % get the optional input arguments, which should be specified as key-value pairs
  73. version = keyval('version', varargin); if isempty(version), version = 'latest'; end
  74. if strcmp(version, 'latest')
  75. version = '2007';
  76. end
  77. switch version
  78. case '2010'
  79. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  80. % there are no changes required
  81. case '2007'
  82. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  83. % the 2007 format did not contain these fields
  84. if isfield(spike, 'time')
  85. spike = rmfield(spike, 'time');
  86. end
  87. if isfield(spike, 'trialtime')
  88. spike = rmfield(spike, 'trialtime');
  89. end
  90. otherwise
  91. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  92. error('unsupported version "%s" for spike datatype', version);
  93. end