diff --git a/tbt/tbt_bcr2.m b/tbt/tbt_bcr2.m index 6dc6ac9..ae8fb9d 100644 --- a/tbt/tbt_bcr2.m +++ b/tbt/tbt_bcr2.m @@ -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 diff --git a/tbt/tbt_cell2bool.m b/tbt/tbt_cell2bool.m index a09c20f..a80456b 100644 --- a/tbt/tbt_cell2bool.m +++ b/tbt/tbt_cell2bool.m @@ -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 \ No newline at end of file