⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datastrm.m

📁 神经元信号处理软件
💻 M
📖 第 1 页 / 共 2 页
字号:
function d = datastrm(a,varargin)
% DATASTRM		- data object constructor for opening data recorded with MC Rack 
%
% d = datastrm(a,varargin) is a datastrm constructor for MC Rack data files of all MC Rack versions 
%                           (MC Rack version 1 and above uses the OLE Server Object contained in MCStream.dll)
%                           (MC Rack version 0 is handled by a MATLAB reader and is retained for compatibilty)
% <a> is a filename or a datastrm object or a struct containing fields of earlier datastrm versions.
% <d> is a datastrm object with the header information contained in the MCRack file.
%
% Following properties of the MCRack data file can be retrieved with getfield(d,'propertyxxx').
% Many of them come as arrays as they depend on the MCRack stream(=buffer), of which more
% than one can be contained in an MCRack data file (e.g. Trigger 1 and Spikes 1)
% Please use getstreamnumber(d,'streamname') for converting stream name to stream id, which
% must be used for indexing all stream dependent arrays.
%
% All other methodes than datastrm,nextdata,getfield,getstreamnumber,ad2muvolt in datastrm 
% directory are private or retained for compatibility and should not be used.
%
% Following properties of the datastrm object are accessible with getfield(a,'eg_prop'):
%
% filename                string
% version                 string             of the datastrm object definition in matlab
% softwareversion         string             of the MCRack version which recorded the opened data file
% filesize                double             in byte
% meatype                 string             '8x8' for MEA layout, all types of MEA's; 'nogrid' for hardware/in vivo layout
% TotalChannels           double             number of hardware channel, can be up to 128 for 'nogrid' layout
% NChannels2              double/stream      no. of channels recorded
% ChannelNames2           cell string        strings of channel definitions, 
%                         array/stream       sorted in hardware aquisition order
% HardwareChannelNames2   cell string        strings of channel definitions, 
%                         array/stream       sorted in recording order
% ChannelID2              cell with double   linear channel ID (i.e. number of channel in MCRack channels page, 
%                         array/stream       e.g. 1=#11,2=#12,..,9=#21,10=#22,...),
%                                            sorted in hardware aquisition order
% HardwareChannelID2      cell with double   hardware channel ID (=number of channel in hardware aquisition sequence),
%                         array/stream       e.g. 1=#11,2=#12,..,9=#21,10=#22,...),
%                                            sorted in recording order
% MicrovoltsPerAD2        double/stream      礦 per AD unit
% MicrosecondsPerTick     double             hardware sampling period
% MillisamplesPerSecond2  double/stream      samples per second * 1000, (there will be a downsampling option 
%                                            for Filtered data in later MCRack version)
% ZeroADValue2            double/stream      zero position of the AD conversion
%
% recordingdate           double             start date and time  
%                                                  datestr(getfield(d,'recordingdate'),0) returns a formatted string
% recordingStopDate       double             stop date and time  
%                                                  datestr(getfield(d,'recordingStopDate'),0) returns a formatted string
%                                            filelength in ms
%                                                  filelength=(getfield(d,'recordingStopDate')- 
%                                                                 getfield(d,'recordingdate'))*24*3600*1000 
% sweepStartTime          0                  onset of each window of gap-free, continuous data, given in ms
% sweepStopTime           0                  end of each window of gap-free, continuous data, given in ms
%
% TimeWindow              struct             recording Time Window information (i.e. trigger conditions, extent)
%                Choice:  string             Start On Trigger, Start And Stop On Trigger, or Fixed Window
%                 Time1:  double                   in ms, depending on the Time Window selection either the 
%                                                        Window Distance or the Pre-Trigger interval
%                 Time2:  double                   in ms, depending on the Time Window selection either the 
%                                                         Window Extent, or the Post-Trigger interval with 
%                                                         Start And Stop On Trigger. 
%          StartTrigger:  string                   name of the selected starting trigger
%           StopTrigger:  string                   name of the selected stop trigger
%
% StreamCount             double             no. of data stream in the record
% StreamNames             cell str/stream    'name' of the 'instrument' used, e.g. 'Spikes 1', 'Trigger 2', 'Electrode Raw Data'
% StreamInfo              cell with          cell array of structures with stream specific information 
%                         struct/stream
%
% Case: 'spikes'
%            StreamName:  string             recorded stream/buffer
%              DataType:  string             type of recorded stream: 'analog', 'trigger, 'spikes', 'params
%            PreTrigger:  double             pre-trigger interval in ms
%           PostTrigger:  double             post-trigger interval in ms
%              DeadTime:  double             'refractory period' in ms
%                 Level:  double/channel     trigger level in 礦 for each channel
%                 Slope:  double/channel     detection slope: 0 for negative, 1 for positive, -1 for absolute level
%          ChannelNames:  cell str/channel   channel names sorted as in Level and Slope
%
% Case: 'params'
%            StreamName:  string             recorded stream/buffer
%              DataType:  string             type of recorded stream: 'analog', 'trigger, 'spikes', 'params
%            Parameters:  cell string        actually return values of the analysis: 'min', 'max', 'tmin', 
%                         /parameter               'tmax', 'height', 'width', 'area', 'number', 'amplitude', or 'rate' 
%       InputBufferName:  cell string        analyzed data stream 
%        NumTimeWindows:  double             no. of Time Windows averaged
%      TimeWindowChoice:  string             'Start On Trigger', 'Start And Stop On Trigger', or 'Fixed Window'			
%       TimeWindowTime1:  double             depending on the Time Window selection either the Window Distance 
%                                                  or the Pre-Trigger
%       TimeWindowTime2:  double             depending on the Time Window selection either the Window Extent, 
%                                                  or the Post-Trigger interval with 'Start And Stop On Trigger'.
%TimeWindowStartTrigger:  string             name of the selected starting trigger
% TimeWindowStopTrigger:  string             name of the selected stop trigger
%
% Case: 'trigger'
%            StreamName:  string             recorded stream/buffer
%              DataType:  string             type of recorded stream: 'analog', 'trigger, 'spikes', 'params
%             ChannelID:  double             corresponds to HardwareChannelID2 of the channel used as trigger
%              DeadTime:  double             'refractory period' in ms
%                 Level:  double             trigger level in 礦 for each channel
%                 Slope:  double             detection slope: 0 for negative, 1 for positive
%       InputBufferName:  'not recorded'     data stream used as trigger source
%
% Case: 'other'
%            StreamName:  string             recorded stream/buffer
%              DataType:  string             type of recorded stream: 'analog', 'trigger, 'spikes', 'params
%
% Please refer to help nextdata for information on retrieving data
%
% Author: Th. Knott, NMI Reutlingen, knott@nmi.de

% internal variables and constants
% sorterleft            double  (1  68)      used to convert hardware aquisition order to linear channel order
%                                               linear_sorted_data(sorterleft)=hardware_sorted_data
% sorterright           double  (1  68)      used to convert hardware aquisition order to linear channel order
%                                               linear_sorted_data=hardware_data(sorterright)
% SamplesPerSegment     double/stream        no. of samples per data block in the file
%

% variables retained for compatibility with MCRack V 0
% DataType                raw triggered
% fid                     -1
% BitFlipRemoveFactor     0
% id                      0
% NChannels               0							
% ChannelNames            							
% HardwareChannelNames    
% MicrovoltsPerAD         1
% ZeroADValue             2048						zero position of the AD conversion
% ChannelID               0							
% HardwareChannelID       0
% total_window_ticks      0							
% offset_to_data          0
% sweepStartPointer       0							
% windowTicksPos          0							
% triggerChannel          -1							
% spikeSize               0							
% ticks_pre_event         0							
% maxSpkPerSegmPerChanl   0							
% nSpikesPerSegement      0							
% nSpkPerSegPerChanl      0							
% HeaderVersion           1							
% fileaccess              ole						
% TriggerStreamID         double (1  2)	   ID of the data stream used as trigger source


% versioning remarks:
% - member variables without ..2 are always filled, (ThK)
% - with ..2 only by MCRack version 0 files (ThK)
% - d.ChannelNames and d.ChannelID retrieved from files recorded with MCRack v. 1.0 now 
% 	 complies with the numbering scheme fitting the MEATools indexing style. (UE 12/1/98)

% MCRack version 0: second par can be the BitFlipRemoveFactor (up to now only for spike data used)
% for removing spikes (bitflips) with peaks more than BitFlipRemoveFactor higher than left/right value
% reasonable size: 4

% Author: Th. Knott, NMI Reutlingen

d.filename='';
d.fid=-1;
datastrmStruct = [];

if nargin == 0
	a='not assigned';
elseif isa(a,'datastrm')
   d = a;
   if (~strcmp(d.fileaccess,'ole'))
   	d.fid = fopen(d.filename);
   	if d.fid == -1
   	   warning(['file ' d.filename ' does not exist']);
      end
   end;
   return;
elseif isa(a,'struct')
   % help initializing earlier versions of datastrm
   datastrmStruct=a;
	a='not assigned';
elseif isa(a,'char') & strcmp(a,'open')
   [fn path] = uigetfile('*.*','open data file');
   if (fn == 0) & (path == 0)      % 'cancel'-button pressed
     if nargout == 1 
        d = [];
     end
     return 
   end
   a = [path fn];
end

if ~strcmp(a,'not assigned')
   d.filename = a;   d.fid = fopen(a);   if (d.fid == -1)      error(['file ' d.filename ' does not exist']);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -