0001 function mdl = set_predef_stim(mdl, stimpat)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 if strcmp(mdl.type, 'image')
0012 img = mdl;
0013 mdl = img.fwd_model;
0014 end
0015
0016 emap = get_elec_map(stimpat);
0017 mdl.electrode = mdl.electrode(emap);
0018 stim = get_stim_pattern(stimpat);
0019 mdl = eidors_obj('set', mdl, 'stimulation', stim);
0020
0021 if exist('img','var')
0022 img.fwd_model = mdl;
0023 mdl = img;
0024 end
0025
0026
0027 end
0028
0029 function stim = get_stim_pattern(str)
0030 switch(str)
0031 case '2x16_planar'
0032 stim = mk_stim_patterns(32,1,[0 6],[0 6],{'no_meas_current','no_rotate_meas'},1);
0033 case {'2x16_odd-even', '2x16_square', '1x32_ring'}
0034 stim = mk_stim_patterns(32,1,[0 5],[0 5],{'no_meas_current','no_rotate_meas'},1);
0035 case '2x16_adjacent'
0036 stim = mk_stim_patterns(32,1,[0 1],[0 1],{'no_meas_current','no_rotate_meas'},1);
0037 otherwise
0038 error('Stim pattern string not understood. Available strings are: \n%s', ...
0039 sprintf('%s\n', pattern_list));
0040 end
0041 end
0042
0043
0044 function ls = pattern_list
0045 ls = {
0046 '2x16_planar'
0047 '2x16_odd-even'
0048 '2x16_square'
0049 '2x16_adjacent'
0050 '1x32_ring'
0051 };
0052 end
0053
0054 function map = get_elec_map(str)
0055
0056 switch str
0057 case {'2x16_odd-even', '2x16_planar'}
0058 map = oddeven32;
0059 case {'2x16_square', '2x16_adjacent'}
0060 map = square32;
0061 case '1x32_ring'
0062 map = ring32;
0063 otherwise
0064 error('No such electrode map');
0065 end
0066 end
0067
0068 function m = square32
0069 o = [48 1 -48 1];
0070 o = repmat(o,1,8);
0071 m = zeros(1,32);
0072 m(1) = 1;
0073 for i = 2:32
0074 m(i) = m(i-1) + o(i-1);
0075 end
0076 end
0077
0078
0079 function m = oddeven32
0080 odd = 49:64;
0081 even = 1:16;
0082 m = [odd; even];
0083 m = m(:)';
0084 end
0085
0086 function m = ring32
0087 m = 17:48;
0088 end