Skip to content

Add support for new MNE-BIDS BIDSPath #146

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

Merged
merged 9 commits into from
Jul 3, 2020

Conversation

hoechenberger
Copy link
Member

No description provided.

@hoechenberger
Copy link
Member Author

The somato dataset fails to download on Circle

@hoechenberger
Copy link
Member Author

The somato dataset fails to download on Circle

Opened an issue upstream:
https://github.com/sappelhoff/MNE-somato-data/issues/1

@hoechenberger hoechenberger requested a review from jasmainak July 2, 2020 11:53
@sappelhoff
Copy link
Member

sappelhoff commented Jul 2, 2020

The somato dataset fails to download on Circle

@hoechenberger it should be fixed now. I also wrote a guide so that anyone can fix this problem on their own (click on "details").


These should be the needed steps. I am doing them now and will update this post if it turns out that one of the steps is wrong.

general requirements:

  • datalad
  • git annex

Get data as .tar.gz from MNE OSF and turn into datalad dataset

  1. wget -q -O - https://osf.io/tp4sg/download?version=6 | tar xvzf -
  2. mv MNE-somato-data ..
  3. datalad create MNE-somato-data
  4. cd MNE-somato-data
  5. mv ../../MNE-somato-data/* .
  6. download fsaverage.zip from https://osf.io/rxvq7/, unpack it, and use the resulting fsaverage directory to replace the symlink MNE-somato-data/derivatives/freesurfer/subjects/fsaverage
  7. datalad save
  8. rm -rf ../../MNE-somato-data

Upload file by file to a new OSF repo

  1. export OSF_TOKEN=<your token created from OSF ui>
  2. datalad create-sibling-osf -s osf MNE-somato-data --mode export
  3. git annex export HEAD --to osf

... this may take a long time depending on your upload speed.

... it may happen that not all files get uploaded (due to connection error). In that case, see: datalad/datalad-osf#109

Parse the new OSF, download urls into a CSV and force update a dataset (the GitHub mirror) ... or make a new GitHub mirror

  1. make the new OSF repo public
  2. cd ..
  3. mkdir gh
  4. cd gh
  5. datalad clone https://github.com/sappelhoff/MNE-somato-data
  6. cd MNE-somato-data
  7. python -c "import datalad_osf; datalad_osf.update_recursive(key='nxtqh', csv='./tmp.csv', limit_to_ext=None)" ... replace nxtqh with your OSF key (the suffix of the URL)
  8. rm tmp.csv
  9. datalad save
  10. datalad publish

Copy link
Member

@jasmainak jasmainak left a comment

Choose a reason for hiding this comment

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

I didn't look too closely for typos etc but PR looks good to me otherwise. The copy are a bit awkward but I guess there is no way around it.

@sappelhoff
Copy link
Member

the somato thing still fails, because the fsaverage symlink was not uploaded ... and OSF refuses to accept it, because it thinks it's a directory ...

no luck with osf-client or datalad-osf either. No clue how I managed to do that back then ...

@sappelhoff
Copy link
Member

no luck with osf-client or datalad-osf either. No clue how I managed to do that back then ...

okay, found the issue. I currently don't have freesurfer installled ... so the symlink is broken on my system. and apparently, broken symlinks behave very odd.

@hoechenberger
Copy link
Member Author

Thanks for looking into this, @sappelhoff! Can you ping me when you think it's ready to go? Just tried fetching somato and still hitting the same error :(

@sappelhoff
Copy link
Member

Thanks for looking into this, @sappelhoff! Can you ping me when you think it's ready to go? Just tried fetching somato and still hitting the same error :(

yeah, the plot thickens. I now managed to upload a fsaverage symlink to OSF and also managed to push it to the GitHub mirror ...

now the only question is whether that will work. Because I think beforehand, the git-annex data contained the actual contents of fsaverage, instead of a symlink.

These contents are:

label mri mri.2mm scripts surf xhemi

apparently I copied them from the symlink's destination /usr/local/freesurfer/subjects/fsaverage to the fsaverage in the MNE-somato dataset.

The odd thing is, that the MNE .tar.gz version contains a symlink.

Well ... I just hope it works now. Can you try again?

Else I'll have to ask someone to share these files from their freesurfer installation folder "label mri mri.2mm scripts surf xhemi" and I'll upload them.

@sappelhoff
Copy link
Member

nice, so now we don't have a download error any more ... the symlink seems to work somewhat.

We get a new error though:

17:39:25  A critical error occurred.
 
Traceback (most recent call last):
 
  File "tests/run_tests.py", line 138, in <module>
 
    run_tests(test_suite)
 
  File "tests/run_tests.py", line 106, in run_tests
 
    pipeline()
 
  File "tests/run_tests.py", line 48, in source
 
    mod.main()
 
  File "/home/circleci/project/10-make_forward.py", line 83, in main
 
    itertools.product(config.get_subjects(), config.get_sessions()))
 
  File "/home/circleci/project/10-make_forward.py", line 82, in <genexpr>
 
    parallel(run_func(subject, session) for subject, session in
 
  File "/home/circleci/project/config.py", line 1046, in wrapper
 
    raise(e)
 
  File "/home/circleci/project/config.py", line 1039, in wrapper
 
    return func(*args, **kwargs)
 
  File "/home/circleci/project/10-make_forward.py", line 68, in run_forward
 
    subjects_dir=config.get_fs_subjects_dir())
 
  File "<decorator-gen-72>", line 21, in make_bem_model
 
  File "/home/circleci/miniconda/lib/python3.7/site-packages/mne/bem.py", line 590, in make_bem_model
 
    surfaces = _surfaces_to_bem(surfaces, ids, conductivity, ico)
 
  File "/home/circleci/miniconda/lib/python3.7/site-packages/mne/bem.py", line 500, in _surfaces_to_bem
 
    surfs[si] = read_surface(surf, return_dict=True)[-1]
 
  File "<decorator-gen-66>", line 21, in read_surface
 
  File "/home/circleci/miniconda/lib/python3.7/site-packages/mne/surface.py", line 720, in read_surface
 
    ret = _get_read_geometry()(fname, read_metadata=read_metadata)
 
  File "/home/circleci/miniconda/lib/python3.7/site-packages/nibabel/freesurfer/io.py", line 183, in read_geometry
 
    raise ValueError("File does not appear to be a Freesurfer surface")
 
ValueError: File does not appear to be a Freesurfer surface
 

@hoechenberger
Copy link
Member Author

hoechenberger commented Jul 2, 2020

nice, so now we don't have a download error any more ... the symlink seems to work somewhat.

I'm getting the following error message:

(mne-dev) ➜  tests git:(bidspath) python download_test_data.py -d somato

----------------------
datalad installing "somato"
[INFO   ] Cloning https://github.com/sappelhoff/MNE-somato-data to '/home/parietal/rhochenb/mne_data/somato' 
datalad get data "sub-01" for "somato"
[INFO   ] Actually getting 8 files 
datalad get data "derivatives/freesurfer/subjects" for "somato"                                                  
[INFO   ] Actually getting 504 files                                                                             
Total (503 ok, 1 failed out of 504): 100%|████████████████████████████████████| 345M/345M [01:08<00:00, 12.0MB/s][WARNING] Running get resulted in stderr output:   download failed: Gone                                         
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone                                                                                          
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download failed: Gone
  download faile... 
                                                                                                                 [ERROR  ] from web...
| Unable to access these remotes: web
| Try making some of these repositories available:
|       00000000-0000-0000-0000-000000000001 -- web
|       df1ecd42-2c7f-4e08-ad85-e4255e20fb1b -- stefanappelhoff@arc-lin-004309:~/Desktop/bids/MNE-somato-data
| 
| (Note that these git remotes have annex-ignore set: origin) [get(/home/parietal/rhochenb/mne_data/somato/derivatives/freesurfer/subjects/fsaverage)] 
[WARNING] could not get some content in /home/parietal/rhochenb/mne_data/somato/derivatives/freesurfer/subjects ['/home/parietal/rhochenb/mne_data/somato/derivatives/freesurfer/subjects/fsaverage'] [get(/home/parietal/rhochenb/mne_data/somato/derivatives/freesurfer/subjects)] 
Traceback (most recent call last):
  File "download_test_data.py", line 104, in <module>
    main(dataset)
  File "download_test_data.py", line 93, in main
    dataset.get(to_get, jobs=n_jobs)
  File "/storage/store/work/rhochenb/miniconda3/envs/mne-dev/lib/python3.8/site-packages/datalad/distribution/dataset.py", line 437, in apply_func
    return f(**kwargs)
  File "/storage/store/work/rhochenb/miniconda3/envs/mne-dev/lib/python3.8/site-packages/datalad/interface/utils.py", line 439, in eval_func
    return return_func(generator_func)(*args, **kwargs)
  File "/storage/store/work/rhochenb/miniconda3/envs/mne-dev/lib/python3.8/site-packages/datalad/interface/utils.py", line 427, in return_func
    results = list(results)
  File "/storage/store/work/rhochenb/miniconda3/envs/mne-dev/lib/python3.8/site-packages/datalad/interface/utils.py", line 413, in generator_func
    raise IncompleteResultsError(
datalad.support.exceptions.IncompleteResultsError: Command did not complete successfully [{'type': 'file', 'refds': '/home/parietal/rhochenb/mne_data/somato', 'status': 'error', 'path': '/home/parietal/rhochenb/mne_data/somato/derivatives/freesurfer/subjects/fsaverage', 'action': 'get', 'annexkey': 'MD5E-s0--d41d8cd98f00b204e9800998ecf8427e', 'message': 'from web...\nUnable to access these remotes: web\nTry making some of these repositories available:\n\t00000000-0000-0000-0000-000000000001 -- web\n \tdf1ecd42-2c7f-4e08-ad85-e4255e20fb1b -- stefanappelhoff@arc-lin-004309:~/Desktop/bids/MNE-somato-data\n\n(Note that these git remotes have annex-ignore set: origin)'}, {'action': 'get', 'path': '/home/parietal/rhochenb/mne_data/somato/derivatives/freesurfer/subjects', 'type': 'directory', 'refds': '/home/parietal/rhochenb/mne_data/somato', 'status': 'impossible', 'message': ('could not get some content in %s %s', '/home/parietal/rhochenb/mne_data/somato/derivatives/freesurfer/subjects', ['/home/parietal/rhochenb/mne_data/somato/derivatives/freesurfer/subjects/fsaverage'])}]
(mne-dev) ➜  tests git:(bidspath) 

@sappelhoff
Copy link
Member

it's weird that you get a different error than the CI.

but anyhow, I am now downloading the full fsaverage data, then uploading to OSF, then updating the datalad mirror.

Then everything should be as it was before. 😬

@hoechenberger
Copy link
Member Author

it's weird that you get a different error than the CI.

Yeah idk… I deleted the entire somato directory before retrying. Maybe the CI's cache is playing tricks on us here.

@sappelhoff
Copy link
Member

Can you try again @hoechenberger? I re-did the MNE-somato-data repository. It should be exactly as it was before now.

@hoechenberger
Copy link
Member Author

Can you try again @hoechenberger? I re-did the MNE-somato-data repository. It should be exactly as it was before now.

It's working for me locally! Thanks for your help, @sappelhoff! I will restart CI now.

@hoechenberger
Copy link
Member Author

@sappelhoff Sorry, this was a bit premature. I only checked whether the download of the dataset works properly now, which it does (at least doesn't throw an error message). But locally I also get ValueError: File does not appear to be a Freesurfer surface. Will try to see if I can figure out where the problem is coming from. But I would bet it's related to that symlink thingy you mentioned before…

@hoechenberger
Copy link
Member Author

@sappelhoff There is indeed still sth wrong with the link:

$ ls -lH /home/parietal/rhochenb/mne_data/somato/derivatives/freesurfer/subjects/01/bem/inner_skull.surf
-r--r--r-- 1 rhochenb parietal 32 Jul  2 22:44 /home/parietal/rhochenb/mne_data/somato/derivatives/freesurfer/subjects/01/bem/inner_skull.surf
$ cat /home/parietal/rhochenb/mne_data/somato/derivatives/freesurfer/subjects/01/bem/inner_skull.surf
watershed/01_inner_skull_surface%
$

@sappelhoff
Copy link
Member

this is an absolute nightmare, I hope this gets easier with the great work that @mih is doing in datalad/datalad-osf#106

@agramfort
Copy link
Member

agramfort commented Jul 3, 2020 via email

@hoechenberger
Copy link
Member Author

we can also put the dataset on openneuro so we have all dataset on openneuro.

https://github.com/mne-tools/mne-study-template/blob/master/tests/download_test_data.py#L17

somato is the only one on OSF

+1!!

@sappelhoff
Copy link
Member

I am trying one last thing right now (uploading the fsaverage/bem folder as well), if that doesn't work, I am at my wit's end anyhow.

So the only options would be:

  • upload to OpenNeuro
  • Wait for datalad/datalad-osf/106

@sappelhoff
Copy link
Member

okay, that didn't work either. I give up for now.

@agramfort
Copy link
Member

agramfort commented Jul 3, 2020 via email

@hoechenberger
Copy link
Member Author

Let me know if I can be of any help here!

@sappelhoff
Copy link
Member

Let me know if I can be of any help here!

yes, can you upload what you need to OpenNeuro, please? :)

I already broke the dataset, so I feel my job is done /sarcasm

but for real though, fighting with datalad yesterday and today already cost me several hours, so it'd be nice if you could take over 👍

@hoechenberger
Copy link
Member Author

hoechenberger commented Jul 3, 2020

Ok I will see what I can do, @sappelhoff! Just need to find a source that's not broken ;) Will keep you posted! Thanks for putting so much time & effort into this, I really appreciate it.

@hoechenberger
Copy link
Member Author

I've published it on OpenNeuro: https://openneuro.org/datasets/ds002993/

However, it's yet to be synced to GitHub: https://github.com/OpenNeuroDatasets/ds002993

Anyone know how long this usually takes?

@hoechenberger
Copy link
Member Author

However, it's yet to be synced to GitHub: https://github.com/OpenNeuroDatasets/ds002993

Heh, it just finished syncing! Neat!

@hoechenberger
Copy link
Member Author

Yeeeeesssss!! It's working!!!
@agramfort care to merge? :)

@sappelhoff
Copy link
Member

nice, and interestingly without fsaverage link whatsoever.

I am going ahead and will delete https://github.com/sappelhoff/MNE-somato-data and the corresponding OSF repo.

Thanks for cleaning up @hoechenberger!

@hoechenberger
Copy link
Member Author

nice, and interestingly without fsaverage link whatsoever.

I intentionally removed it – was that a bad idea?

@sappelhoff
Copy link
Member

I intentionally removed it – was that a bad idea?

if it works, it must be fine. The fsaverage is shipped with freesurfer anyways, so it was a mystery to me anyhow why I previously included it in the dataset before 🤷‍♂️

@hoechenberger
Copy link
Member Author

The fsaverage is shipped with freesurfer anyways, so it was a mystery to me anyhow why I previously included it in the dataset before

This was my thinking exactly!

@jasmainak
Copy link
Member

Is this somato data also used in MNE? Something to update there?

@hoechenberger
Copy link
Member Author

Is this somato data also used in MNE? Something to update there?

To my knowledge it's the exact same dataset. MNE should probably start fetching it from OpenNeuro too now, yes :)

@sappelhoff
Copy link
Member

Is this somato data also used in MNE? Something to update there?

yup, MNE uses the BIDS version of the somato data, as stored on OSF

in fact, I don't think there is a non-bids version anymore (except of course in the OSF version history)

MNE should probably start fetching it from OpenNeuro too now, yes :)

xref: mne-tools/mne-python#6687

:)

@agramfort agramfort merged commit fd3bfd5 into mne-tools:master Jul 3, 2020
@hoechenberger hoechenberger deleted the bidspath branch July 3, 2020 21:22
@hoechenberger
Copy link
Member Author

Thanks @agramfort!

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.

4 participants