Skip to content

Commit

Permalink
Merge pull request #3 from mattansb/next
Browse files Browse the repository at this point in the history
always convert bads to logical
  • Loading branch information
mattansb authored Sep 23, 2018
2 parents 5193af3 + d262981 commit 4032d5b
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 4032d5b

Please sign in to comment.