Skip to content

Commit

Permalink
always convert bads to logical
Browse files Browse the repository at this point in the history
  • Loading branch information
mattansb committed Sep 23, 2018
1 parent 8b37b6e commit d262981
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion tbt/tbt_bcr2.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,16 @@
function [EEG, nbadchan, nbadtrial] = tbt_bcr2(EEG,bads,badsegs,badchans,plot_bads,chanlocs)

%% convert bads from cell to array



if iscell(bads)
fprintf('pop_TBT(): Converting cell-array.')
fprintf('pop_TBT(): Converting cell-array to logical array')
bads = tbt_cell2bool(bads,EEG);
fprintf('.. done.\n')
elseif ~islogical(bads)
fprintf('pop_TBT(): Converting to logical array')
bads = logical(bads);
end

%% Find bad trials and Channels
Expand Down
4 changes: 2 additions & 2 deletions tbt/tbt_cell2bool.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
function bads_array = tbt_cell2bool(bads,EEG)

bads_array = zeros([size(EEG.data,1) size(EEG.data,3)]);
bads_array = false([size(EEG.data,1) size(EEG.data,3)]);

for r = 1:size(bads,1)
% identift channels
chan_i = cellfun(@(x) any(strcmpi(x,bads{r,2})),{EEG.chanlocs.labels});
epoch_i = bads{r,1};
bads_array(chan_i,epoch_i) = 1;
bads_array(chan_i,epoch_i) = true;
end

end

0 comments on commit d262981

Please sign in to comment.