mne-tools / mne-tools/mne-python

cannot read times after read_evoked_fieldtrip

Open
#11,296 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hello,
When I load data using mne.read_evoked_fieldtrip, I am not able to read times, I added tmin value in the function by reading it from the fieldtrip structure as follows.

time= np.squeeze(ft_struct['time'])
tmin = time[0]

info = _create_info(ft_struct, info)  # create info structure
data_evoked = ft_struct['avg']  # create evoked data
evoked = EvokedArray(data_evoked, info, comment=comment, tmin=tmin)

This works fine and I am able to plot the data as expected. However, to do baseline correction in this evoked data, I had to add one hack to read_evoked_fieldtrip function:

  if(comment==None):
       comment = ' '

If I don't do this any evoked method that reads the comment field gives error: object of type 'NoneType' has no len().
This error is coming from the following patch:

   def __repr__(self):  # noqa: D105
       max_comment_length = 1000
       if len(self.comment) > max_comment_length:
           comment = self.comment[:max_comment_length]
           comment += "..." 

Originally posted by @transpersonify in https://github.com/mne-tools/mne-python/issues/9769#issuecomment-1300838017

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 at mne.read_evoked_fieldtrip and inspect the EvokedArray construction shown in the issue, including tmin and comment handling. Reproduce the reported time-reading and None-comment errors, then verify that imported evoked data retains its times and evoked methods can handle an omitted comment.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.