Computing sources - script stops too many bad channels

Hi

I ran the below script to calculate sources for my subjects. After a few subjects the process stops due to one subject having no good channels. Some of the subjects listed in the report have numerous bad channels. I got the below messagein the MatLab command window. I have not marked any channels as bad and relied solely on ICA/SSP and removed channels +-100uv to deal with artifacts. I noticed on the forum someone else had this problem due to not calculating a noise covariance matrix. I have already calculated both noise and data covariance matrices. Can you advise what I should do?

% Script generated by Brainstorm (20-Jun-2020)

% Input files
sFiles = ;

% Start a new report
bst_report('Start', sFiles);

% Process: Select files using search query
sFiles = bst_process('CallProcess', 'process_select_search', , , ...
'search', '(([path CONTAINS "resample"] AND [name CONTAINS "WAvg:"]))');

% Process: Compute sources [2018]
sFiles = bst_process('CallProcess', 'process_inverse_2018', sFiles, , ...
'output', 1, ... % Kernel only: shared
'inverse', struct(...
'Comment', 'MN: EEG', ...
'InverseMethod', 'minnorm', ...
'InverseMeasure', 'amplitude', ...
'SourceOrient', {{'fixed'}}, ...
'Loose', 0.2, ...
'UseDepth', 1, ...
'WeightExp', 0.5, ...
'WeightLimit', 10, ...
'NoiseMethod', 'reg', ...
'NoiseReg', 0.1, ...
'SnrMethod', 'fixed', ...
'SnrRms', 1e-06, ...
'SnrFixed', 3, ...
'ComputeKernel', 1, ...
'DataTypes', {{'EEG'}}));

% Save and display report
ReportFile = bst_report('Save', sFiles);
bst_report('Open', ReportFile);
% bst_report('Export', ReportFile, ExportDir);

BST_INVERSE (2018) > NOTE: Cross Covariance between sensor modalities IS NOT CALCULATED in the noise covariance matrix

BST_INVERSE > Rank of the 'EEG' channels, keeping 116 noise eigenvalues out of 118 original set
BST_INVERSE > Using the 'reg' method of covariance regularization.
BST_INVERSE > Diagonal of 10.0% of the average eigenvalue added to covariance matrix.
BST_INVERSE > Using 'fixed' surface orientations
BST_INVERSE > Rank of leadfield matrix is 116 out of 118 components
BST_INVERSE > Confirm units
BST_INVERSE > Assumed RMS of the sources is 1.87 nA-m
BST_INVERSE > Assumed SNR is 9.0 (9.5 dB)

Then you DID mark bad channels.
Removing blindly channels that over a fixed peak-to-peak threshold is not usually a solution we recommend. Check your data before running any automated analysis on it.
To get all your channels back without having to import everything again: right-click on a subject (or the entire database) > Good/bad channels > Mark all channels as good.

SSP is not recommend for EEG either. ICA and manual channel rejection might be the best solution for you.

https://neuroimage.usc.edu/brainstorm/Tutorials/BadChannels
https://neuroimage.usc.edu/brainstorm/Tutorials/BadSegments
https://neuroimage.usc.edu/brainstorm/Tutorials/Epilepsy#Artifact_cleaning_with_ICA

I have already calculated both noise and data covariance matrices.

You don't need any data covariance for the minimum norm estimates, only for the LCMV beamformer.
https://neuroimage.usc.edu/brainstorm/Tutorials/NoiseCovariance#Data_covariance

Hi Francois,

Thank you for getting back to me. That explains it. When I had looked at the channel file for the rejected subject for the averaged epoch files the channels were listed as good. I checked my report from running the fixed peak-to-peak threshold and all the channels were listed as bad on at least one of the trials.

I screened fixed peak-to-peak threshold (+-100uv) after importing my epochs from continuous files because I'm replicating the analytical approach used in another study. Could you tell me why this isn't advised?

I had originally intended to use just ICA and fixed peak-to-peak threshold to deal with artifacts. I only included SSP with these later as I found ICA (returning 30 components) did not seem to detect all the ocular artifacts for some subjects. For these subjects I subsequently ran the SSP (following the procedure outlined in - https://neuroimage.usc.edu/brainstorm/Tutorials/BadSegments) and found that this often detected ocular artifacts quite well. If SSP is not the best approach is there a way to improve ICA, such as setting a frequency band 0.5-7Hz?

Additionally, I had not removed the start/ends of the data files (which are not part of the testing period, for example after the last trial). Is it possible to automatically mark these sections as bad segments (i.e. from the beginning of the file to the first event marker and from the last event marker to the end of the file)? Would this improve ICA?

Best,
David

Not advised when used blindly. If you use any automated cleaning procedure, always check manually the quality of the output.

found that this often detected ocular artifacts quite well.

EEG scalp potential maps are very smooth, and the exact same topography may arise from many different brain processes or artifacts. Removing one spatial component removes all the similar-looking scalp topographies from the data, therefore there is a high risk to remove much more than expected.
When cleaning your data, you should be very careful not only to only to evaluate how much of your artifact is gone, but also how much of your data of interest is left.

If SSP is not the best approach is there a way to improve ICA, such as setting a frequency band 0.5-7Hz?

This is impossible to make general statements about this, it depends on too many factors: your EEG equipment, the quality of your data, the kind of artifacts your subjects generate, and of course your experimental design and hypothesis.
Some trial and errors is necessary for understanding what is the best cleaning solution for your data.

Is it possible to automatically mark these sections as bad segments (i.e. from the beginning of the file to the first event marker and from the last event marker to the end of the file)?

No, you have to create these markers manually, or write a Matlab script for automating it. Search the forum, someone recently tried to do this.

Would this improve ICA?

No, ICA uses the time window that is given in input of the process, not the bad segments.
Run the ICA only on the time window of interest.

Hi Francois,

Thank you for your help. I have marked all segments (start, end and short break between testing segments) as 'bad' and the two testing segments as 'good'. I can use this to run the ICA on only the 'good' sections using the 'eventname', parameter.

I had used Re-reference EEG > "AVERAGE" before ICA. I've gone back and deleted all active projectors including the 're-reference' projector. I was wondering when this re-reference process is run does it exclude the bad segments automatically or are the good segments not affected? I couldn't see anything in the GIU or script that requires this to be specified when running this process. I see from the tutorials that bad channels are excluded as in ICA.

Best
David

Hi Francois,

Following from my previous post - could you advise how I should treat the 'event time' parameter in below ICA script? I have 4 'Good' segments marked in each subjects continuous file. The length of each of the 4 segments will vary from subject to subject.

Thanks
David

% Process: ICA components: Infomax
sFiles = bst_process('CallProcess', 'process_ica', sFiles, [], ...
'timewindow', [], ...
'eventname', 'GOOD', ...
'eventtime', [-0.2, 0.2], ...
'resample', 0, ...
'bandpass', [0, 0], ...
'nicacomp', 30, ...
'sensortypes', 'EEG', ...
'icasort', '', ...
'usessp', 1, ...
'ignorebad', 1, ...
'saveerp', 0, ...
'method', 1); % Infomax: EEGLAB / RunICA

Re-referencing or ICA do not use bad segments or any other temporal information. Both processes create a linear operator (Nchannels x Nchannels matrix) that ignores the bad channels only.

could you advise how I should treat the 'event time' parameter in below ICA script?

If your events are "extended events" (that a defined duration), the parameter "eventtime" is ignored. See directly how this is handled in the code (you can even put a breakpoint there to follow how this works line by line):

Thank you Francois

Hi Francois,

Relating to the above problem about computing sources - I went back and improved the cleaning. The same issue occurs where sources can't be computed for one subject due to too many bad channels. I'm not clear on why this occurs. For this subject I have 4 outcomes with around 70 trials for each outcome. I selected one channels as bad before importing these 4 epochs. I then screened out channels above 100uv for these epochs. There was just one trial that had a high number of channels that were marked bad. For the other trials very few or no channels were marked bad (there's a total of 128 channels). I rejected this one trial with the high number of bad channels. The averaged epochs for each outcome looks fine. I tried to compute sources again for this subject but it says there are too many bad channels (image below). The sources were computed for all subjects before this one no problem. Should I proceed by deleting the channels listed in the text box in the image or is this not advised?

image

Indeed, the behavior you describe here is unexpected: The list of bad channels was extracted from all the files in the folder, including the bad trials.
I fixed this in this commit, so that the bad trials are ignored: https://github.com/brainstorm-tools/brainstorm3/commit/888229c957ebeef3e50d4e403aabd345dfb4309f

Update Brainstorm to get this fix. Or simply delete manually the list of bad channels you want to keep in the inverse estimation, as you suggested.

Thank you Francois. I have downloaded the updated version. I had another look and the list of bad channels includes those that were marked bad in at least one good trial (trials that are included and marked good) which results in them being highlighted/selected for removal when computing sources. For example, for one subject I have 644 files for computing sources. A channel which was marked as bad in just one good file/trial is now selected as bad for all files/trials. Is this appropriate or is there a way to remove these bad channels in only the files for which they are marked bad rather than in all the files?

If you compute a single inversion kernel that is shared for multiple files, it has to be the same for all the files. The same list of bad channels has to be set for all the files. If a channel is not included in the computation, it's not available for any file.
https://neuroimage.usc.edu/brainstorm/Tutorials/SourceEstimation#Computing_sources_for_single_trials

You have the option to compute one source file separately for each of your 644 files, and therefore adjust for each trial the list of bad channels in the inverse model. This would multiply the computation time and size of the sources files by the number of trials, for probably not much improvement.

Hi Francois,

Would a way to get around this be to compute sources for just the averaged outcomes for each subject? For example, a subject with four weighted averaged outcomes (each outcome averaged from roughly 80 trials). Instead of computing a single inversion kernel that would be available for every single trial plus the averaged outcomes, I would compute sources for each of the four averaged outcomes for each subject. Would this lead to more accurate source maps for these averaged outcomes for each subject and subsequently more accurate source maps when averaged at group level? I'm assuming it would as this would bypass any channel being marked as bad due to being 'bad' in one single trial?

Best
David

The minimum norm inverse model is computed independently from the recordings, it uses only the noise covariance matrix and the forward model. You would obtain exactly the same model in the two following configurations:

  1. Right-click on the average of the trials > Compute sources, as you described in your last post.
  2. Right-click on the folder > Compute sources, then remove all the bad channels from the input window (= consider all the channels as good), as discussed earlier. Unless the same channel is bad for all the trials, it should not ask you about bad channels and use them all.

The only difference in case #2 is that it would create a "shared kernel" made available for all the individual trials as well. I think this is the best option for you.

Thank you Francois.

Hi Francois,

Following my analysis of ERPs I wanted to explore some of the differences between two groups found in the ERP analysis using source imaging. I could use feedback on my approach and the pipeline.

I used the default anatomy non-linear average of MNI 152 subjects. I computed the forward head models of the cortex surface using the Symmetric Boundary Element Method using default settings. For inverse modelling, I used sLORETA (minimum norm imaging and default setting parameters in Brainstorm (constrained source orientations, 3-dB signal-to-noise ratio, depth weighting and noise covariance regularization = 0.1). The noise covariance was calculated using the baseline period of the included trials. I created the sLORETA maps from the averaged trials per condition and for each subject and then rectified to absolute values. I then obtained the difference in sources (arithmetic average mean(A) - mean(B)) between groups. I ran another approach using Cortical density maps with otherwise the same settings. I rectified these to Z scores and looked at differences which in some cases were different from the prior approach.

I rectified these to Z scores

I don't this this is what you meant, but: don't rectify (absolute value) then compute a Z-score.

looked at differences which in some cases were different from the prior approach

Your first version normalizes the maps based on the projection of the noise covariance in source space.
Your second version normalizes the maps based on the averaged pre-stimulus baseline.
It is expected to observe differences between the two versions.
Both can be valid approaches. Deciding on which is the best one will depend on your hypotheses, your experimental design, your data quality, and perhaps some intuition...

Hopefully the final statistical analysis will not show much difference between the two approaches.

In case of doubts, stay as close as possible to the recommendations we give in the tutorials:

Hi Francois,

Thank you for your reply.

Yes you're right, I didn't mean that. I only used z-score in the CDM approach.

I followed the tutorial/workflows page to run the approach (sLORETA) outlined above. Specifically 'Difference of averages: Between subjects' under the 'Constrained cortical sources' section.

Regards normalizing (Z-score) the subject averages - should this have been done prior to computing absolute values at subject level and then the grand averages for each group? Or am I correct that the sLORETA approach incorporates normalization as part of the process automatically (I read this in the source estimation tutorial)?

I assumed this approach (minimum norm imaging/constrained/sLORETA) was the most appropriate for my purposes - I was exploring differences in sources during ERPs (so used minimum norm/sLORETA) and I did not expect any differences in signs (so used constrained).

Indeed, sLORETA maps are normalizaed values that you don't need to normalize again with a Z-score, for comparisons within a given subject. For comparisons between subjects, I'm not sure.
For group analysis, please refer to the guidelines in the Workflows page. If you compute a Z-score of the source maps (based on the baseline), then you get exactly the same results whether you use "Current density maps" or normalized sLORETA maps. This is why the standard pipeline described in Workflows uses only the former.

Thank you Francois.

I will try both and see. I haven't seen any reference to normalizing wrt baseline in the literature using sLORETA. I assume when calculating differences in sources between groups this is mostly filtered out in the cortical map of 'group differences' regardless. Also, I am comparing groups on the same experiment and with the same default anatomy.