Skip to content

BaseRaw + io module #1003

Closed
Closed

Description

@agramfort

I'd like to summarize what I feel needs to be done on the BaseRaw class + io module. Here are the few steps I would take

  • rename mne.fiff to mne.io
  • mv mne/fiff/evoked.py to mne/evoked.py. It's much more natural to type mne.read_evoked etc...
  • mv mne/fiff/pick.py to mne/pick.py
  • add all the necessary deprecation warnings
  • make sure all examples still run
  • update all examples
  • make sure the doc still builds

then introduce a BaseRaw class in mne/io/base.py , define the interface and update the base class in every object in the Raw family

do I forget something?

any volunteer? :)

Activity

  1. dengemann commented on Dec 24, 2013

    @dengemann
    Member

    @agramfort I'll take care of it over the holidays.

  2. dengemann commented on Dec 24, 2013

    @dengemann
    Member

    I'm on it now

  3. dengemann commented on Dec 24, 2013

    @dengemann
    Member

    @agramfort now that I'm in the middle of my edits it occurs to me how inconsistent it feels to have mne.Evoked, mne.Epochs but not mne.Raw., it really looks stupid next to each other in any example.
    Also I think it would be cool to be able to say from mne import Raw, Epochs, Evoked
    I think io should really be about converting, low level reading and writing.
    My 2 cents.

  4. agramfort commented on Dec 24, 2013

    @agramfort
    SponsorMemberAuthor

    well the meaning of io is raw io in my mind.

    the io module should contain only the BaseRaw and Raw* classes.

  5. larsoner commented on Dec 24, 2013

    @larsoner
    Member

    @agramfort it would be strange to me to have a submodule named mne.io, but not have things like read_evoked, read_source_estimate, etc. not also be under it. That is what I had been assuming would happen -- all our I/O-related functions would be grouped under that module. Sorry I didn't bring it up earlier when you first proposed this...

  6. dengemann commented on Dec 24, 2013

    @dengemann
    Member

    @agramfort I think we agree on this. We simply should expose the most frequently used callables in mne. To me this would be Raw but not Base classes or conversion classes. It really looks kind of unpractical in an example to import io only to access the Raw constructor while mne.Epochs and mne.Evoked works. Same for pick_types ... cleanup is overdue

  7. agramfort commented on Dec 24, 2013

    @agramfort
    SponsorMemberAuthor

    @Eric89GXL if we move all the read_* functions in io then we move many
    many things there and need to split existing files / classes. Would
    you move the source_estimate.py file there and remove the
    SourceEstimate class from mne namespace? to me it would be too much.

  8. agramfort commented on Dec 24, 2013

    @agramfort
    SponsorMemberAuthor

    I have in mind to type:

    mne.io.read_raw_fif
    mne.io.read_raw_edf
    mne.io.read_raw_kit

    and

    picks = mne.pick_types(...)

    On Tue, Dec 24, 2013 at 5:55 PM, Denis A. Engemann <[email protected]

    wrote:

    @agramfort https://github.com/agramfort I think we agree on this. We
    simply should expose the most frequently used callables in mne. To me
    this would be Raw but not Base classes or conversion classes. It really
    looks kind of unpractical in an example to import io only to access the
    Raw constructor while mne.Epochs and mne.Evoked works. Same for pick_types... cleanup is overdue

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/1003#issuecomment-31178748
    .

  9. dengemann commented on Dec 24, 2013

    @dengemann
    Member

    I know that I suggested this.
    But thinking about it it while editing this I think a data object constructors should have a consistent top-level API. flat is better than nested :-) (don't reply with namespaces are a honking great idea).

    On Dec 24, 2013, at 5:59 PM, Alexandre Gramfort [email protected] wrote:

    I have in mind to type:

    mne.io.read_raw_fif
    mne.io.read_raw_edf
    mne.io.read_raw_kit

    and

    picks = mne.pick_types(...)

    On Tue, Dec 24, 2013 at 5:55 PM, Denis A. Engemann <[email protected]

    wrote:

    @agramfort https://github.com/agramfort I think we agree on this. We
    simply should expose the most frequently used callables in mne. To me
    this would be Raw but not Base classes or conversion classes. It really
    looks kind of unpractical in an example to import io only to access the
    Raw constructor while mne.Epochs and mne.Evoked works. Same for pick_types... cleanup is overdue

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/1003#issuecomment-31178748
    .

    —
    Reply to this email directly or view it on GitHub.

  10. larsoner commented on Dec 24, 2013

    @larsoner
    Member

    @agramfort that makes sense. Do you think we should not expose Raw as a way of reading raw files, but instead have people use read_raw_fif (e.g., for the FIF case)? @dengemann one disadvantage to having mne.Raw is that it would break this pattern, and make FIF-raw reading "exceptional" in how it's accessed/used.

  11. larsoner commented on Dec 24, 2013

    @larsoner
    Member

    I think it makes the most sense to deprecate direct instantiation of raw using Raw(...) and instead have people use read_raw_fif, since it's more explicit. And we can do the same thing with Evoked(...) versus read_evoked. This seems the cleanest, most consistent way to do it to me. I'm fine with having these be under mne or mne.io.

  12. dengemann commented on Dec 24, 2013

    @dengemann
    Member

    i'm fine with functions, but it really should be consistent. no historical excuses ;-)
    also I don't see strong reasons to withhold the most commonly used functions from being exposed as top-level functions. usability over taxonomic desires, please.

  13. dengemann commented on Dec 24, 2013

    @dengemann
    Member

    I won't continue here before we reach consensus, this PR is too fidgety otherwise. Let's shoot for a post-holiday / xmas hangout if necessary.

  14. larsoner commented on Dec 24, 2013

    @larsoner
    Member

    The only remaining debate is over whether to put the read_raw_* functions under mne or mne.io, right?

  15. dengemann commented on Dec 24, 2013

    @dengemann
    Member

    The only remaining debate is over whether to put the read_raw_* functions under mne or mne.io, right?

    and how many of all other read_* functions should follow, e.g. read_ica, etc.

    likewise, how much of pick to expose in mne name space.

  16. 26 remaining items

  17. dengemann commented on Jan 27, 2014

    @dengemann
    Member

    @mluessi I was also thinking about about .to_fieldtrip etc methods ...

  18. dengemann commented on Jan 27, 2014

    @dengemann
    Member

    @agramfort @Eric89GXL @mluessi ...

    To simplify convergence, could we please vote what to include in the interface definition:

    `print '\n - [ ] '.join(dir(raw))``

    • "contains"
    • "del"
    • "delattr"
    • "dict"
    • "doc"
    • "enter"
    • "exit"
    • "format"
    • "getattribute"
    • "getitem"
    • "hash"
    • "init"
    • "len"
    • "module"
    • "new"
    • "reduce"
    • "reduce_ex"
    • "repr"
    • "setattr"
    • "setitem"
    • "sizeof"
    • "str"
    • "subclasshook"
    • "weakref"
    • "_add_eeg_ref"
    • "_first_samps"
    • "_initialize_fids"
    • "_last_samps"
    • "_orig_comp_grade"
    • "_parse_get_set_params"
    • "_preload_data"
    • "_preloaded"
    • "_projector"
    • "_raw_lengths"
    • "_read_raw_file"
    • "_read_segment"
    • add_proj
    • append
    • apply_function
    • apply_hilbert
    • apply_proj
    • as_data_frame
    • cals
    • ch_names
    • close
    • comp
    • copy
    • crop
    • del_proj
    • drop_channels
    • estimate_rank
    • fids
    • filter
    • first_samp
    • index_as_time
    • info
    • last_samp
    • load_bad_channels
    • n_times
    • notch_filter
    • orig_format
    • plot
    • plot_psds
    • proj
    • rawdirs
    • resample
    • save
    • time_as_index
    • to_nitime
    • verbose
  19. mluessi commented on Jan 27, 2014

    @mluessi
    Contributor

    @dengemann I think for saving, maybe we could have a format kwarg in the save methods.

  20. mluessi commented on Jan 27, 2014

    @mluessi
    Contributor

    @dengemann ?? I don't get it..

  21. dengemann commented on Jan 27, 2014

    @dengemann
    Member

    @mluessi vote for the ABCMeta methods ;-)

  22. dengemann commented on Jan 27, 2014

    @dengemann
    Member

    @agramfort @mluessi a few of the attributes are computed during runtime. We would need to make them abc.abstractproperties to make them serve as interface definitions.
    Another question is which things shall already be implemented in RawBase as concrete methods ...

    Any thoughts?

  23. mluessi commented on Jan 27, 2014

    @mluessi
    Contributor

    @agramfort why do you suggest to put the RawBase class into fiff/base.py? Maybe I'm misunderstanding something, but isn't the point of this PR to make IO less fiff-centric? I think it would make more sense to have the base class in mne/raw.py and format specific readers in the .py file for the respective file format.

    @dengemann are you trying to decide which methods/attributes from Raw should go into BaseRaw? I think almost everything except the things that are fiff-specific (read block, etc). You want as many methods as possible in the base class so all the features are available in all derived classes (which implement few format specific methods for reading and writing).

  24. agramfort commented on Jan 27, 2014

    @agramfort
    SponsorMemberAuthor

    whatever method is not specific to fiff files :)

  25. agramfort commented on Jan 27, 2014

    @agramfort
    SponsorMemberAuthor

    first we create the base class then we refactor the io module to move stuff
    from mne/fiff to mne/ ok?

  26. mluessi commented on Jan 27, 2014

    @mluessi
    Contributor

    @agramfort +1 let's create the base class and the derived class for fiff first.

    Given that we are now planing to implement readers for FT, do you guys think it is still the best idea to implement a flat hierarchy or would hierarchical be better? I.e., should we use mne.io.read_epochs_fieldtrip etc or put things for each file format in a separate sub-package, i.e., mne.io.fieldtrip.read_epochs. IMO, the later would allow for a cleaner organization and one could use from mne.io.fieldtrip import * for less typing.

  27. agramfort commented on Jan 27, 2014

    @agramfort
    SponsorMemberAuthor

    fine with mne.io.fieldtrip

  28. dengemann commented on Jan 27, 2014

    @dengemann
    Member

    @agramfort the problem I see is that using a proper ABC class won't allow for inheritance. All methods expected by the API will be needed to be implemented by the advanced user, if only wrapping super calls to the base class. I'm not sure this is really what we want.

  29. agramfort commented on Jan 27, 2014

    @agramfort
    SponsorMemberAuthor

    abstract methods should be only the methods required by subclasses.

    the other methods are inherited

  30. agramfort commented on Jun 11, 2014

    @agramfort
    SponsorMemberAuthor

    duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions