And the time of onset/offset of the TMS-induced artefacts are also specified. I want to first extract the data between the onset and offset of the artefacts to replace them with NAN.
tms_artefact_pre =0.005 # for rejecting artefact, before TMS pulse
tms_artefact_post=0.015 # for rejecting artefact, after TMS pulse
Could someone provide me a clue how to perform this on a āepoched dataā?
Thank you so much.
Why donāt you just mark the respective data segments as ābadā on the raw data and throw them away? I donāt think thereās any use in interpolating them, as I assume all channels are affected by the TMS pulses, no?
thanks for your reply!
I understand what you suggested - but weād like to avoid the discontinuity in the data as much as possible, thatās why I posted the question above.
Iād appreciate if you could provide any idea!
Thanks a lot.
So you donāt intend to epoch the data? Iām asking because in your example, youāre creating epochs around the TMS events. Could you briefly explain what you intend to so, so we can first assess whether itās feasible?
For example, I donāt think MNE has any machinery for interpolation across time (only across space), unless Iām mistakenā¦
I donāt think MNE has any functionalities to do temporal interpolation. You will have to do this manually:
get the underlying numpy data array with raw.get_data().
determine the corrupted segmentās start/stop indices.
interpolate.
I do know researchers in Geneva doing EEG + TMS, and doing something very similar. They try to use high-sampling rate recordings (5 kHz) and interpolate the TMS-corrupted segments. Maybe this is a required feature for TMS studies? But Iām a bit concerned about the validity of this approach.
The data set we have (itās on here: Dealing with TMS-EEG datasets - FieldTrip toolbox) consists of 2 conditions (marked as 1 and 3 in the data set). At the start of the each condition, there is a TMS pulse (marked as 10001) which causes huge artifacts in the data and we want to remove them -
There are several approaches we want to try to deal with that artifacts:
Replace with baseline (with EEG before the TMS pulse)
Interpolation
Replace with zero or 1 (with constant values)
After applying one of these approaches, we want to epoch the continuous EEG data based on the TMS events, therefore, epoching can also be done after removing and replacing the TMS artifacts.
We want to perform any kinds of preprocessing (resampling, filteringā¦etc.) only after dealing with the TMS artifacts, since it could result in additional noise in the data. For that reason we want to deal with the TMS artifacts in the first place.
To do that, we want to know first whether itās feasible with MNE to remove the data segment of the TMS artifacts (by detecting the segment with the help of the TMS onset marker ā10001ā and the time range before TMS and after TMS pulse we want to remove - depicted as tms_artefact_pre =0.005 and tms_artefact_post=0.015 in the first question above) and replace the values in this data segment with NaN.
Epoching and Interpolation are therefore not the scope of the current question!
Thank you for your suggestion!
Actually, Iām having a problem with indexing on the raw data (mne.io.array.array.RawArray).
The information of the raw data is this (the data contains EEG data of 63 channels) : Out[114]: <RawArray | 63 x 479060 (958.1 s), ~230.3 MB, data loaded>
What Iām trying to do is to replace values in the corresponding columns (affected segments) of the raw data with 0 by using the array below indicating the timing of TMS onset, and then fill them with np.nan.
In this part, ā-100ā and ā+100ā should be replaced with the time range which need to be rejected, am I right?
Assuming we want to reject the data segment between TMS onset - 1 ms and TMS onset + 6 ms, and the sampling frequency is 600Hz, then the time range wonāt be integers anymore.