Skip to content

Conversation

@hofaflo
Copy link
Contributor

@hofaflo hofaflo commented Oct 22, 2024

Currently, exporting to edf fails if one channel contains only constant values and physical_range="auto", because edfio requires that (explicitly passed) physical minimum and maximum differ from each other (link). This requirement is suggested in Q8 in the EDF FAQ, because min == max leads to a division by zero when calculating the signal offset, which might cause an error when loading the file. This PR ensures that physical minimum and maximum are always different when using physical_range="auto". For physical_range="channelwise", edfio takes care of that , as mne passes no physical range to edfio.EdfSignal.

Copy link
Contributor

@cbrnr cbrnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @hofaflo! Could you add a changelog entry please?

Just out of curiosity, what are the implications of having a pmax that is actually not the true maximum of the signal? I mean, the test shows that everything is correctly saved and loaded, but then pmax in the file is just wrong?

@hofaflo
Copy link
Contributor Author

hofaflo commented Oct 22, 2024

what are the implications of having a pmax that is actually not the true maximum of the signal?

None that I know of. The physical range (together with the digital range) is just used to determine signal gain and offset. There is no requirement that they actually occur within the signal. This is already the case for physical_range="auto", as the min/max per channel type is used. In this specific example, every physical 0 is stored as a digital -32767, and a physical 1 would be stored as a digital +32767, but there are none of these, so it doesn't really matter.

@larsoner larsoner merged commit f4597ba into mne-tools:main Oct 28, 2024
@larsoner
Copy link
Member

Thanks @hofaflo !

larsoner added a commit to larsoner/mne-python that referenced this pull request Oct 28, 2024
* upstream/main:
  eegbci api: allow downloading multiple subjects (mne-tools#12918)
  DOC: Document Linux desktop workaround (mne-tools#12900)
  Allow exporting edf where a channel contains only constant values (mne-tools#12911)
  Autogenerate environment.yml file from pyproject.toml (mne-tools#12914)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants