Skip to content

Commit

Permalink
bipolar channels
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Treder committed Feb 7, 2013
1 parent 1aefecf commit a3f49d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 69 deletions.
4 changes: 3 additions & 1 deletion fileio/file_readBV.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
% specified as as string or a vector.
% Default 'subsampleByMean'. Other 'subsampleByLag'
% If you specify a vector it has to be the same size as lag.
% 'LinearDerivation' : for creating bipolar channels (see
% procutil_biplist2projection for details)
%
% Remark:
% Properties 'Ival' and 'Start'+'MaxLen' are exclusive, i.e., you may only
Expand All @@ -52,7 +54,7 @@
% multiplexed, INT_16, ... The function does not even check, whether
% the file is in this format!
%
% See also: file_*
% See also: file_* procutil_biplist2projection
%
%Hints:
% A low pass filter to get rid of the line noise can be designed as follows:
Expand Down
79 changes: 11 additions & 68 deletions processing/utils/procutil_biplist2projection.m
Original file line number Diff line number Diff line change
@@ -1,43 +1,18 @@
function proj= procutil_biplist2projection(clab, bip_list, varargin)
% PROCUTIL_BIPLIST2PROJECTION - %%%
%
function proj= procutil_biplist2projection(clab, bip_list)
% PROCUTIL_BIPLIST2PROJECTION - Prepares a projection matrix for creating
% bipolar channels.
%Usage:
% proj = procutil_biplist2projection(clab, bip_list, <OPT>)
%
% ***** TODO
%Arguments:
% CLAB - data structure of continuous or epoched data
% FREQ - Fourier center frequencies of the wavelets (eg [1:100] Hz)
% OPT - struct or property/value list of optional properties:
% 'Mother' - mother wavelet (default 'morlet'). Morlet is currently the
% only implemented wavelet.
% 'w0' - unitless frequency constant defining the trade-off between
% frequency resolution and time resolution. For Morlet
% wavelets, it sets the width of the Gaussian window. (default 7)
% CLAB [CELL ARRAY] - channel labels or struct containing a .clab field
% BIP_LIST [CELL ARRAY] - list specifying bipolar channels
%
%Returns:
% DAT - updated data structure with a higher dimension.
% For continuous data, the dimensions correspond to
% time x frequency x channels. For epoched data, time x
% frequency x channels x epochs.
% INFO - struct with the following fields:
% .fun - wavelet functions (in Fourier domain)
% .length - length of each wavelet in time samples
% .freq - wavelet center frequencies
%Example:
%
% See also PROC_SPECTROGRAM.

props = {'DeletePolicy', 'auto', '!CHAR';
'LabelPolicy', 'auto', '!CHAR'
};

if nargin==0,
proj= props; return
end
% % Creates new channels EOGh from F9-F10 and EOGv from EOGvu-Fp2
% procutil_biplist2projection(clab,{ {'F9' 'F10' 'EOGh'} {'EOGvu' 'Fp2' 'EOGv'})

opt= opt_proplistToStruct(varargin{:});
[opt,isdefault] = opt_setDefaults(opt, props);
opt_checkProplist(opt, props);
misc_checkType(clab,'CELL|STRUCT');
misc_checkType(bip_list,'');

Expand All @@ -46,46 +21,14 @@
clab= clab.clab;
end

proj = struct('chan',[],'filter',[]);
for bb= 1:length(bip_list),
bip= bip_list{bb};
proj(bb).chan= bip{1};
proj(bb).filter= zeros(length(clab), 1);
proj(bb).filter(util_chanind(clab, bip{1:2}))= [1 -1];
if length(bip)>2,
proj(bb).new_clab= bip{3};
else
switch(lower(opt.LabelPolicy)),
case 'auto',
if strcmpi(bip{2}(end-2:end), 'ref'),
proj(bb).new_clab= clab{proj(bb).cidx};
elseif ismember(bip{1}(end), 'pn') & ismember(bip{2}(end),'pn') | ...
ismember(bip{1}(end), 'lr') & ismember(bip{2}(end),'lr'),
proj(bb).new_clab= bip{1}(1:end-1);
end
case 'deletelastchar',
proj(bb).new_clab= bip{1}(1:end-1);
case 'firstlabel',
proj(bb).new_clab= clab{proj(bb).cidx};
otherwise,
error('choice for OPT.LabelPolicy unknown');
end
end
switch(lower(opt.DeletePolicy)),
case 'auto',
if numel(bip{2})>2 && strcmpi(bip{2}(end-2:end), 'ref') | ...
(ismember(bip{1}(end), 'pn') & ismember(bip{2}(end),'pn')) | ...,
(ismember(bip{1}(end), 'lr') & ismember(bip{2}(end),'lr')),
proj(bb).rm_clab= bip{2};
else
proj(bb).rm_clab= {};
end
case 'second',
proj(bb).rm_clab= bip{2};
case 'never',
proj(bb).rm_clab= {};
otherwise,
error('choice for OPT.DeletePolicy unknown');
end
proj(bb).new_clab= bip{3};
proj(bb).rm_clab= {bip{1:2}};
end

[proj.clab]= deal(clab);

0 comments on commit a3f49d7

Please sign in to comment.