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.