mne-tools / mne-tools/mne-python

support negative times for CTF files

Open
#9,653 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

BUG
Dominant language
Python
Stars
3.5k
Forks
1.6k
Avg merge
1d 6h
Merged PRs (30d)
100

Description

So I didn't know this but it seems like CTF has the ability to start its recordings with negative times by using a sync trigger and asking the scanner to include a baseline period.

Other packages Brainstorm (and presumably fieldtrip) respect this field and adjust their time arrays accordingly.

MNE reads in the required field
https://github.com/mne-tools/mne-python/blob/855edbf48835bcee80e773eb7047d0a4caa14a1c/mne/io/ctf/res4.py#L126

and adjusts annotations and bad_segments to account for it.
https://github.com/mne-tools/mne-python/blob/855edbf48835bcee80e773eb7047d0a4caa14a1c/mne/io/ctf/ctf.py#L147-L156

That MNE shifts other stuff and not the time array leads me to believe that MNE can't have negative time values in raw objects. Is that true?

This cropped up because I was doing some custom event marking for an experiment using mne and the resulting events were read into brainstorm and were all shifted by 1 second. In this particular case, I'm time shifting the events before I save them out, solving my immediate issue but it still seems a bit like a bug?

-Luke

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CTF field handling in mne/io/ctf/res4.py at the linked location, then inspect the annotation and bad_segments adjustments in mne/io/ctf/ctf.py. Trace how the baseline period affects raw time values and event alignment. Done means CTF recordings with negative start times retain consistent time arrays, annotations, bad segments, and events.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.