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

Unclear how to load connectivity object from disk after saving it #134

Closed
moritz-gerster opened this issue Mar 15, 2023 · 5 comments · Fixed by #135
Closed

Unclear how to load connectivity object from disk after saving it #134

moritz-gerster opened this issue Mar 15, 2023 · 5 comments · Fixed by #135

Comments

@moritz-gerster
Copy link
Contributor

moritz-gerster commented Mar 15, 2023

Describe the bug

The connectivity class enables saving connectivity objects to disk via the save method.

Saving works, however, I cannot load the data once saved. The documentation of that method is not very helpful. It is not clear in which file format the connectivity should be saved and with what function it should be loaded.

I expected to save it as a ".fif" file and loading it using mne.io.read_raw(file). This didn't work. Looking at the code I realized it's supposed to be saved as a ".nc" file. However, loading the ".nc" file using netCDF also didn't work. Please refer to my jupyter notebook for examples.

Steps to reproduce

I used the code from this tutorial to show my failed efforts in this jupyter notebook to reproduce the issue.

Expected results

The documentation should tell me how to save and how to load the connectivity object. Once loaded, I can work with it and extract all data.

Actual results

Loading the file returns

RuntimeError: NetCDF: Can't open HDF5 attribute

Additional information

Platform:         macOS-13.2.1-arm64-arm-64bit
Python:           3.11.0 | packaged by conda-forge | (main, Jan 14 2023, 12:26:40) [Clang 14.0.6 ]
Executable:       /Users/moritzgerster/anaconda3/envs/bids_neu/bin/python
CPU:              arm: 10 cores
Memory:           16.0 GB

mne:              1.3.0
numpy:            1.23.4 {OpenBLAS 0.3.21 with 10 threads}
scipy:            1.9.3
matplotlib:       3.6.2 {backend=module://matplotlib_inline.backend_inline}

sklearn:          1.1.3
numba:            Not found
nibabel:          5.0.1
nilearn:          Not found
dipy:             Not found
openmeeg:         Not found
cupy:             Not found
pandas:           1.5.1
pyvista:          0.38.4 {OpenGL 4.1 Metal - 83 via Apple M1 Pro}
pyvistaqt:        0.9.1
ipyvtklink:       Not found
vtk:              9.2.5
qtpy:             2.3.0 {PyQt5=5.15.6}
ipympl:           Not found
pyqtgraph:        Not found
pooch:            v1.6.0

mne_bids:         0.12
mne_nirs:         Not found
mne_features:     Not found
mne_qt_browser:   Not found
mne_connectivity: 0.5.0
mne_icalabel:     Not found
@ruuskas
Copy link
Contributor

ruuskas commented Mar 15, 2023

Hi @moritz-gerster! I believe you should use the mne_connectivity.read_connectivity function.

@moritz-gerster
Copy link
Contributor Author

Hi @moritz-gerster! I believe you should use the mne_connectivity.read_connectivity function.

That makes sense and it works - thanks!

@moritz-gerster moritz-gerster changed the title Cannot load connectivity object from disk after saving it Unclear how to load connectivity object from disk after saving it Mar 15, 2023
@moritz-gerster
Copy link
Contributor Author

I think the documentation should be updated. I did not figure this out on my own. There is no example showing this.

@adam2392
Copy link
Member

Seems like the docs could be more clear tho if you had a tough time figuring it out. Interested in making a PR to clarify the docs/docstrings @moritz-gerster?

@moritz-gerster
Copy link
Contributor Author

Seems like the docs could be more clear tho if you had a tough time figuring it out. Interested in making a PR to clarify the docs/docstrings @moritz-gerster?

Yes, I will have time for that soon!

adam2392 added a commit that referenced this issue Apr 2, 2023
tsbinns pushed a commit to tsbinns/mne-connectivity that referenced this issue Dec 15, 2023
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 a pull request may close this issue.

3 participants