the-siesta-group / edfio

Read and write EDF/EDF+ files.
Apache License 2.0
30 stars 4 forks source link

Add public interface to access data array #49

Open cbrnr opened 7 months ago

cbrnr commented 7 months ago

As mentioned in #48, I think it would be useful to have a public method to access the underlying data array. This only works for signals with the same sampling frequency, but I think this would be a rather common use case for EEG recordings. Typically, I want to access the data from all channels as a NumPy array for subsequent processing. I'm not sure what the best way to expose this would look like, but hence this issue 😄.

hofaflo commented 7 months ago

Maybe we could add a method Edf.to_numpy() which tries to return an array of shape (n_signals, n_samples) (raising an exception if the sampling frequencies don't match)?

cbrnr commented 6 months ago

I think this would be a great addition! If there are other signals, users could drop them, e.g. edf.drop_signals([1, 6, 8]).to_numpy(). WDYT?

hofaflo commented 6 months ago

edf.drop_signals() only works in-place and does not return the Edf object, so that would have to be done in two lines, but other than that I agree!

cbrnr commented 6 months ago

Ah OK! Maybe worth discussing if these methods should also return the object in addition so that chaining works?