Modify MEG recording `sfreq`

Hi!

A colleague of mine did some tests recently with our new MEG machine (TRIUX NEO MEG), and realized that audio stimuli recorded on the STIM channel would get a slight delay that increases in time, progressively throughout the recording.

Here is the audio and the STI channel perfectly aligned at the beginning of the recording:

Here it is after 4 minutes:

My colleague opened a ticket to the MEGIN people, who replied that this delay is actually explained by hardware limitations (for which they are currently developping a patch) - but that the real sampling rate of our recordings was 1000.49 Hz instead of 1000 Hz. The recordings, however, show an sfreq of 1000 Hz.

I am working with data that was already recorded on the machine. The delay is there. I am working with data downsampled at 200 Hz. The thing is, as the original sfreq is set at 1000 Hz, I am downsampling from 1000 Hz to 200 Hz, while ideally I would like to downsample from 1000.49 Hz to 200 Hz.

I am aware that you cannot modify the sfreq of a recording easily - which seems like a good idea. However, in this very case, I would like to do it :sweat_smile:.

Is there a way to set the sfreq of the recording (or to edit the info of the fif file) to set the frequency on 1000.49 Hz?

Thanks!

Yes, you can do:

with raw.info._unlock():
     raw.info["sfreq"] = 1000.49
1 Like

Awesome, thanks :slight_smile:

The caveat here is that of course this is highly dangerous and unsupported. I never did this before, so you might want to check if you need to change other things like raw.times as well.

1 Like

That’s fair. I will check along the way if I see anything weird coming out of it.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.