There isn’t an existing example. It ought to be possible in principle, however: if you can determine in advance your forward model and noise covariance, then you ought to be able to use mne.minimum_norm.apply_inverse to each Realtime epoch as it comes in.
Hi Mainak, thanks for your helpful comments. When I looked at your code, you used ‘compute_source_psd_epochs’. Is there any time delay related to this function?
Using your code, we can implement real-time source localization. One thing that I am worried is time-delay. Didn’t you feel any delay in your realtime system?
If I remember correctly, the total time delay depends on: 1) the buffer length in FieldTrip buffer, 2) the buffer size of the data requested by the FieldTrip buffer client in MNE-Python, and 3) the processing speed. If you precompute the forward, 3) may not be a bottleneck. I would recommend measuring the time with time.time or some such tool. 1) usually depends on the vendor. For Elekta systems on which I tested, I think 28 samples is the minimum buffer length. Now, depending on the timing of the start of the buffer and query from MNE-Python, the actual delay may have a distribution as shown in the figure above. Note that get_data_as_epoch requests only the last n_samples, so you do get pseudo-realtime at the expense of missing some samples. If on the other hand, you’d like to get all the samples corresponding to a trigger, you should use iter_evoked.
Hi Mainak, thanks for you helpful information. Your information is so important for me. I think for your master study you worked very hard and did a lot!