Channel specific bad epochs

Hello there,

I'm working on 5 min EEG segments * 256 channels. I marked as bad just few channels for short time windows (using linked data). If I import data as "continuous", all bad channels (also the ones marked as bad for a short amount of time) are removed. Thus, I imported "epoched" data (time window 6 sec) BUT if the bad channels are marked as bad for almost all the epoch, it is impossible to compute the PSD. Why?

Anna

What do you mean?
Please post some screen captures illustrating your problem.

Rephrasing:

  • I have one 4 minute segment
  • I cleaned the linked raw file as a continuous file using the option 'mark as bad' for individual channels
  • I imported the segment splitting it in 40 blocks of 6 second each

In other words, I cleaned the 4 minute segment as a continuous file (bc I work in the sleep field and it is easier for me to visualize 30 sec epochs), and I would like to put Nan to few specific channels in different blocks, and for each block I want to compute a separate psd. I know it might sound unconventional, but this is the only reasonable way to clean and use the segments I have.

It seemed to work but crashed for one segment where the sum of 3 different bad artifacts spanned across all the block.
More specifically, for the block 180-186 sec (the one selected in the screenshot) I couldn't generate the PSD. I succeed only when I removed the first bad segment - spanning from 180 to 182 sec. As you can see from the screenshot the other 2 remaining segments span from 182 to 186 sec, meaning that I had bad segments along ALL the 180-186 segment (but marked just for few channels).

Hope this is a little bit clearer

Anna

I imported the segment splitting it in 40 blocks of 6 second each

You could be interested in using a time-frequency decomposition with Hilbert transform of the full 4 min, averaged by time bands, instead.
https://neuroimage.usc.edu/brainstorm/Tutorials/TimeFrequency#Process_options

bc I work in the sleep field and it is easier for me to visualize 30 sec epochs

We've been adding options for sleep staging by blocks of 30s directly from the continuous files. Use custom shortcuts with the option "full page".

https://neuroimage.usc.edu/brainstorm/Tutorials/MontageEditor#Custom_montage

I would like to put Nan to few specific channels in different blocks

You can't put NaN in a data file, these values are not accepted by Brainstorm. Channels are marked as bad for an imported epoch through a flag in the matrix "ChannelFlag" in the epoch structure:
https://neuroimage.usc.edu/brainstorm/Tutorials/Epoching#On_the_hard_drive

When importing an epoch:

  • if it overlaps with at least one bad segment defined for all the channels, the entire epoch is marked as bad (red dot in the database explorer)
  • if it overlaps with at least one bad segment defined only on one or a few channels, this channel is marked as bad for the entire epoch (ChannelFlag(iBad)=-1).

It seemed to work but crashed for one segment where the sum of 3 different bad artifacts spanned across all the block.

Now I understand what happens.
The PSD computation was excluding entirely the channel-specific bad segments, which is silly for imported epochs because the channels are already marked as bad and would not be computed anyway.
I changed this logic: now the PSD computation includes the bad segments that are defined only for a few channels.

Please update Brainstorm and try again.

Thanks for reporting this weird behavior.

Perfect, THANK you! :slight_smile: