# Sensor space AR (AR1)

**OLD:** Four parameters refer to the ICA1 AR. Noisy sensors usually produce ICs whose topography is strongly limited to this particular sensor. Such ICs can be detected with **ar.ica\_topo\_z\_value\_th** which defines the z-threshold of sensor weights (a value of 7 is recommended). Trial removal is then performed: **ar.ica\_singleic\_tr\_z\_value\_th** defines the threshold for IC signal variance deviation seen on a single IC (value of 15-20 recommended), **ar.ica\_multipleic\_tr\_z\_value\_th** defines the threshold when the deviation is seen on multiple ICs at the same time (7-8 recommended), while **ar.ica\_multipleic\_cnt\_z\_value\_th** adjusts the number of these multiple ICs to look at (4-6 recommended).



ASCT provides a multi-stage process of artifact rejection (AR). This ensures effective removal of most of the artifactual content. AR is performed just after data epoching to ensure that the parameters of the signal screened for unusual activity will be limited to the experimentally relevant part of data recording. Detection of artifacts starts in the sensor space, which means that the electrode / magnetometer / gradiometer signals are examined first to detect potentially bad channels. After their removal, statistical parameters of trials are estimated to reveal those that deviate from typical values. Sensor-space artifact detection is performed on the EOG-corrected signal if available. This enables estimation of channel / trial statistics that are not biased by the EOG activity.&#x20;

Next stages of AR are performed after decomposition of sensor signals into potentially independent sources (see: XXXX) by examining timecourse and topographies of resulting independent components. The source-space AR is described in XXXXX.

### Bad channel detection

During the initial stage of AR, bad channels are detected and removed. This step is especially important for EEG, where the average reference will be automatically applied before localization of sources.&#x20;

Channel removal is based on the IQR thresholding of sensor variance, set by the **ar.chIQR** parameter (recommended value 5 to 8). For EEG, if EOG signals are available, eye movement correction is temporarily applied before calculation of channel variance. This allows for limiting the oculomotor bias on frontal electrode variance. As MEG does not allow for such eye movement correction, the optimal threshold is typically higher for MEG (around 8) than for EEG (around 5).&#x20;

The **ar.chRmLimit** parameter defines the upper bound of the number of removed channels. If this number is exceeded, the whole dataset is considered of bad quality and removed (around ⅕ of the total sensor number is recommended here).&#x20;

```
% bad channels detection
ar.chIQR     = 8; % iqr threshold for chan rejection. 
ar.chRmLimit = 8; % sets max number of channels that can be removed from the DS. if exceeded, a whole DS is removed   
```

### Trial-based removal

The next AR stage defines trial removal criteria. Detection is performed in three consecutive steps:

* excess trial variance (**ar.var\_iqr**, recommended value 5-8; a lower value can be set if EOG correction are available),&#x20;
* threshold on difference between min/max amplitude in a trial:\
  **ar.range\_th** defines the threshold. This criterion works fine when EOG correction can be performed. Otherwise, blink activity, strongly present on frontal sensors, can be falsely detected as an artifact. In such a case, it is advisable to set this variable to a value high enough to exceed overall blink activity. Recommended values are around 100-250 µV for EOG-corrected EEG data.&#x20;
* muscle activity contamination, which is detected as elevated spectral power for higher frequencies, typically > 35 Hz, which overlaps with a lower range of muscle activity. Threshold is defined by the **ar.musc\_th** as a z-score deviation; a value near or slightly above 20 is recommended).

```
% bad trials detection
ar.varIQR   = 8;   % trial variance
ar.rangeThr = 200; % trial range
ar.muscThr  = 20;  % muscle contamination z-threshold
```

### Customizing AR parameters

The AR logs are stored in the `3_ARTIFREE` subfolder, with detailed information on rejected channels and trials, together with their statistics. The \_REPORT\_ch.txt file contains channel-only information, while in the **\_AR\_Trial\_Report.txt** file, the removed channels and trials are logged with detailed statistical parameters and thresholds. See the example below:

```
DS: 4
04_CTR_SES1_SEGM

REMOVED CHANNEL(S) (iqr = 8)
     O2 (igr val: 20.4)

REMOVED TRIALS (5/384; 1.0%)
   3 trial(s) removed due to VARIANCE (iqr=7)
    162 (41.3)
    215 (7.3)
    237 (9.1) 
  1 trial(s) removed due to RANGE (thr=250)
    147
  4 trial(s) removed due to MUSCLE (zthr=24,freq=(35,50))
    145
    203
    381
    382
```

We recommend reviewing the accuracy of the actual settings, especially in a new measurement environment, by visual inspection of sample datasets. This can be obtained with the `sc_plot()` function with segmented data as an argument.&#x20;

```
% load and plot segmented data 
load('2_SEGMENTED/01_CTR_SES1_SEGM.mat');
sc_plot('data_segm');

% load and plot EOG-corrected segmented data 
load('2_SEGMENTED/01_CTR_SES1_SEGM_EOGcorr.mat');
sc_plot('data_segm_eogcorr');
```

In this case, loading the segmented dataset will allow plotting the data just before the rejection. Hence, the trial numbers in AR logs will correspond to the trial indexes in this file. Verifying the channels / trials qualified for rejection and adjusting the settings accordingly will ensure optimal AR performance.&#x20;

Channel variance plots for all dataset are also saved in the `chanvar` subdirectory. They show plots of sorted channel variances (both uncorrected and EOG-corrected) together with the threshold set. This also helps determine proper thershold value.&#x20;

### Saving data after AR1

Datasets after AR1 procedure are saved in the `3_ARTIFREE` directory as \***\_ARJ.mat files.**
