Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow exporting edf where a channel contains only constant values #12911

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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.

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.

2 participants