Create bit trigger. [USAGE] vb_bit_trigger_new(ch_name, slope trig_level); [IN] ch_name : extract trigger from this channel [string] slope : trigger slope. ('low_to_high' or 'high_to_low') [string] bit_num : bit number [0-n] [uint] bitmask : bit mask('00001111') [string] offset : data offset [OUT] obj : bit_trigger object [see also] vb_get_trigger_event Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [obj] = vb_bit_trigger_new(ch_name, slope, bit_num, bitmask, offset) 0002 % Create bit trigger. 0003 % 0004 % [USAGE] 0005 % vb_bit_trigger_new(ch_name, slope trig_level); 0006 % [IN] 0007 % ch_name : extract trigger from this channel [string] 0008 % slope : trigger slope. ('low_to_high' or 'high_to_low') [string] 0009 % bit_num : bit number [0-n] [uint] 0010 % bitmask : bit mask('00001111') [string] 0011 % offset : data offset 0012 % [OUT] 0013 % obj : bit_trigger object 0014 % [see also] 0015 % vb_get_trigger_event 0016 % 0017 % Copyright (C) 2011, ATR All Rights Reserved. 0018 % License : New BSD License(see VBMEG_LICENSE.txt) 0019 0020 % 0021 % --- Previous check 0022 % 0023 if nargin < 5 0024 error('This function needs 5 argments. Please check your code.'); 0025 end 0026 if ~strcmp(slope, 'low_to_high') && ~strcmp(slope, 'high_to_low') 0027 error('trigger slope must be ''low_to_high'' or ''high_to_low'''); 0028 end 0029 if ~isinteger(bit_num) 0030 error('Invalid bit number was specified. Input integer value.'); 0031 end 0032 try 0033 % !!! bit num should be double and decimal number. 0034 bit_num = double(2^bit_num); 0035 catch 0036 error('Invalid bit number was specified. Input integer value.'); 0037 end 0038 0039 if ~ischar(bitmask) 0040 error('Bitmask: Binary string may consist only of characters 0 and 1.'); 0041 try 0042 tmp = bin2dec(bitmask); 0043 catch 0044 error('Bitmask: Binary string may consist only of characters 0 and 1.'); 0045 end 0046 end 0047 0048 % 0049 % --- Main Procedure 0050 % 0051 obj = vb_trigger_new(ch_name, 'bit', bit_num); 0052 0053 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0054 % obj.FIELDNAMES SHOULD BE SAME WITH vb_get_trial_time_index 0055 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0056 obj.slope = slope; 0057 obj.status_mask = bitmask; 0058 obj.status_offset = offset; 0059 0060 % 0061 % --- After check 0062 % 0063 if nargout < 1 0064 error('function caller should receive this object.'); 0065 end