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

[MRG] Simplify raw_to_bids #106

Merged
merged 38 commits into from
Nov 5, 2018

Conversation

jasmainak
Copy link
Member

@jasmainak jasmainak commented Oct 4, 2018

closes #98
closes #105
closes #119
closes #123

@jasmainak jasmainak force-pushed the refactor_raw_to_bids branch 17 times, most recently from 4564c92 to 32b2cf8 Compare October 4, 2018 05:51
mne_bids/mne_bids.py Outdated Show resolved Hide resolved
mne_bids/mne_bids.py Outdated Show resolved Hide resolved
@jasmainak
Copy link
Member Author

@sappelhoff @teonbrooks @monkeyman192 thoughts?

I stop for today. The diff is a bit largish but I think I got two examples to run. We should first agree that this is a more future-compatible / simpler API. Maybe it isn't ... I don't know

@jasmainak
Copy link
Member Author

and your turn to review :-) I take a break from reviewing ...

doc/api.rst Outdated Show resolved Hide resolved
mne_bids/mne_bids.py Outdated Show resolved Hide resolved
mne_bids/mne_bids.py Outdated Show resolved Hide resolved
@@ -60,6 +60,20 @@ def _mkdir_p(path, overwrite=False, verbose=False):
raise


def _parse_bids_filename(fname):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need a test ;-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typically private functions are not tested explicitly. But these lines should be covered since they are being called by the write_raw_bids function

# BrainVision is multifile, copy over all of them and fix pointers
elif ext == '.vhdr':
copyfile_brainvision(raw_fname, raw_file_bids)
copyfile_brainvision(raw_fname, fname)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will not go well together with what you write in the docstring on line 497:

The file path of the BIDS compatible raw file. In the case of multifile
        systems (e.g., vhdr, .ds etc.), this is the path to a folder containing
        all the files.

See also my comment above. Both copyfile_brainvision (a multifile system, always 3 files) and copyfile_eeglab (a facultative multifile system ... can be 1 file or 2 files) expect the location of the header file, i.e., myfile.vhdr or myfile.set ... passing a directory is currently not supported and would maybe also not be a good idea.

Copy link
Member

@sappelhoff sappelhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the approach and the idea to make MNE-BIDS more modular! There is much to be done, but I find this approach promising and also like the idea of an analogous "read_raw_bids" in the future.

@jasmainak
Copy link
Member Author

@agramfort : updated PR to use raw._init_kwargs. CIs should be happy once mne-tools/mne-python#5679 is in

@jasmainak
Copy link
Member Author

@agramfort @teonbrooks CIs are happy

Copy link
Member

@teonbrooks teonbrooks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on the whole, everything looks good and things are cleaned up.

my one concern, which is also inline in the review: I don't think that make_bids_basename should be exposed to the end user and that we should incorporate the arguments into write_raw_bids and privatize to _make_bids_basename. I think it would simplify the api, and since we greatly reduce arg overloading for each edge case with the system-specific implementation, these standard arguments (subject, run, task, and session) can live in the function happily and not overcrowded.

examples/convert_eeg_to_bids.py Show resolved Hide resolved
@@ -18,7 +18,8 @@ Next to `numpy`, `scipy`, and `matplotlib` that are included in the standard
anaconda distribution, you will need to install the following dependencies
to be able to use `mne_bids`:

$ pip install pandas mne
$ pip install pandas
$ pip install -U https://api.github.com/repos/mne-tools/mne-python/zipball/master
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can note the mne-python current version as the minimal in the text above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what you mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we don't specify anywhere minimal version number. like, we should have a section that says mne >= 0.17.X

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's probably because we don't know them. I know only for MNE we need >=0.17.x. For the rest I would say the "latest" :-)

examples/convert_eeg_to_bids.py Show resolved Hide resolved
mne_bids/commands/mne_bids_raw_to_bids.py Outdated Show resolved Hide resolved
mne_bids/io.py Show resolved Hide resolved
mne_bids/pick.py Show resolved Hide resolved
@jasmainak
Copy link
Member Author

I don't think that make_bids_basename should be exposed to the end user and that we should incorporate the arguments into write_raw_bids and privatize to _make_bids_basename

So, we have an example for this function here. Do you envision this example going away if it becomes private?

I would just let the user create the BIDS filename using string formatting but if you think that's adding friction, we can also have it as function arguments. No strong opinion there. My only concern is that since BIDS is still evolving, it might make sense not to tie API decisions to the file naming structure. There are still key-value pairs being added and dropped ...

@teonbrooks
Copy link
Member

There are still key-value pairs being added and dropped ...

grr... yeah, does this include all current applicable key-value pairs? if they are exposed within the function as optional, then I would actually be ok with having this as a separate function.

and yes, i do realize i was the one who suggested the basename function and then critique it afterwards lol ;)

@jasmainak
Copy link
Member Author

grr... yeah, does this include all current applicable key-value pairs?

yep exactly. You would need to give people a way to write filenames with all the key-value pairs in BIDS, not just a subset ...

mne_bids/mne_bids.py Outdated Show resolved Hide resolved
mne_bids/mne_bids.py Outdated Show resolved Hide resolved
mne_bids/mne_bids.py Outdated Show resolved Hide resolved
@jasmainak jasmainak force-pushed the refactor_raw_to_bids branch 3 times, most recently from d4d0ac7 to a9674c3 Compare November 3, 2018 01:35
@agramfort
Copy link
Member

in make_bids_folders you use root for what you call output_path elsewhere no?

@jasmainak
Copy link
Member Author

Good catch. Now I made the variable output_path consistently everywhere

@teonbrooks
Copy link
Member

everything looks good here now and all tests passing. merging.
thanks heaps @jasmainak!

@teonbrooks teonbrooks merged commit c79dc4a into mne-tools:master Nov 5, 2018
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.

certain COILS in pick.py will raise a bug soon [MAINT] make raw_to_bids more modular
6 participants