mne-python
mne-python copied to clipboard
Reading and writing TFRs is confusing
I thought about asking in our forum, but I decided to open an issue, because I think this is at least partly a documentation issue:
I am confused by our TFRs API. In particular, it is not clear to me how reading and writing is supposed to work. There are two functions, mne.time_frequency.read_tfrs()
and mne.time_frequency.write_tfrs()
.
-
Let's start with
write_tfrs()
. According to its docstring, I can passAverageTFR | list of AverageTFR | EpochsTFR
– a list ofEpochsTFR
is not supported, but I can still pass it without any problems. So I guess the line in the docstring should be adapted toAverageTFR | list of AverageTFR | EpochsTFR | list of EpochsTFR
.BTW, and this should probably be a separate discussion, but I really think we should use type hint syntax in our docstrings. For example, the previous docstring should really be changed to
AverageTFR | list[AverageTFR] | EpochsTFR | list[EpochsTFR]
. -
I have no idea what this note in the description of the
tfr
parameter means: "Note. If .comment is not None, a name will be generated on the fly, based on the order in which the TFR objects are passed." -
Similarly, the docstring of
read_tfrs()
says that the function returnsAverageTFR | list of AverageTFR | EpochsTFR
, so this is probably also missing alist of EpochsTFR
. -
The docstring also says that the return value of
read_tfrs()
depends oncondition
: "Depending oncondition
either the TFR object or a list of multiple TFR objects." This is only partly true, because I also get a list ofAverageTFR
if I read a file containing only a singleAverageTFR
object (same for a singleEpochsTFR
object). So this comment needs to be adapted, or maybe even better, the function should always return a list (ofEpochsTFR
orAverageTFR
), even when there is only a single TFR. -
I don't understand the
condition
parameter. How are conditions stored inAverageTFR
objects? -
It seems like
condition
does not work forEpochsTFR
, this should be documented. And because I don't understand it in the first place, why does it not work forEpochsTFR
? -
The types of
condition
should be changed toint | str | list of int | list of str | None
.
Sorry for this long list!