ratal / mdfreader

Read Measurement Data Format (MDF) versions 3.x and 4.x file formats in python
Other
169 stars 74 forks source link

mdf.getChannelData() from non-existing channel #102

Closed cristi-neagu closed 6 years ago

cristi-neagu commented 6 years ago

Can this raise a warning instead of an error and let the calling code deal with the missing channel, rather than stop execution completely? The function can either return the channel name as it currently does, or return None.

I usually build a list of channel names, pass that list to mdf.keepChannels(), change sampling rate, then iterate over the list, returning data. If one of the channels is missing i have to do a key check for every channel i want to retrieve (which seems a bit redundant, since mdf.getChannelData() does that check as well), and either remove the channel names (which i might not necessarily want to do), or do some sort of complicated procedure to remove the channel name and replace it with a numpy.zeros_like() vector (which is preferable).

It seems easier to get a warning from mdf.getChannelData() and deal with it on the spot, rather than doing extra checks before hand.

ratal commented 6 years ago

Yes, it could return a None. I will modify. But do you know why a channel got missing ? keepChannels() should keep the channels you gave it. If you already know in advance before read what channels you are interested in, I would rather advise you to use channelList=[ 'list', 'of', 'channels']. You are loading everything and then dump what is not necessary, loading only what you need at once should be quicker and consumming less memory.

cristi-neagu commented 6 years ago

I am missing channels because the mdf files i'm using may not have them to start with.

ratal commented 6 years ago

Ok then, if that's solving your issue, I guess you can close.

cristi-neagu commented 6 years ago

Closed in ee6410b