Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add support for loading MAT files #314

Merged
merged 4 commits into from
Feb 20, 2022
Merged

Add support for loading MAT files #314

merged 4 commits into from
Feb 20, 2022

Conversation

cbrnr
Copy link
Owner

@cbrnr cbrnr commented Feb 19, 2022

2D arrays from arbitrary MAT files can be loaded by selecting the variable and setting the sampling frequency in a dedicated dialog. Fixes #195.

@cbrnr
Copy link
Owner Author

cbrnr commented Feb 19, 2022

@hofaflo if you have time please test this new feature.

@hofaflo
Copy link
Contributor

hofaflo commented Feb 19, 2022

This works really well, just two notes:

The entries in the "Name" column in the MatDialog are indented:
image

Would it make sense to import 3d-arrays as mne.Epochs?

@cbrnr
Copy link
Owner Author

cbrnr commented Feb 19, 2022

The entries in the "Name" column in the MatDialog are indented:

I haven't noticed that with data I tested. Which file did you use that has this problem? Did you try a file where the entries are not indented?

Would it make sense to import 3d-arrays as mne.Epochs?

Definitely. But I think I'll do that at a later point, because this will require juggling more with the dimensions.

@hofaflo
Copy link
Contributor

hofaflo commented Feb 19, 2022

Happens with all files I found, even with a minimal example created like this:

import numpy as np
from scipy.io import savemat

a = np.zeros((100, 2))
savemat("test.mat", {"a": a})

image

@cbrnr
Copy link
Owner Author

cbrnr commented Feb 19, 2022

Ah, I think that's because I'm displaying that as a QTreeWidget. When there's no nesting, this looks like an indentation where normally there would be an arrow. Try loading a .mat file from e.g. data set 1 from http://bnci-horizon-2020.eu/database/data-sets to see how a nested data structure (MATLAB struct) looks like.

Not sure it's worth special-casing when there is no nesting, only if it's not too much effort.

@cbrnr
Copy link
Owner Author

cbrnr commented Feb 20, 2022

I'm now showing the file name as the root of the tree so there is no stray indentation. Better?
Screen Shot 2022-02-20 at 10 04 36

@cbrnr
Copy link
Owner Author

cbrnr commented Feb 20, 2022

Off-topic: the default icon in the top left corner of a dialog on Windows looks really ugly. Can/should we disable this?

@hofaflo
Copy link
Contributor

hofaflo commented Feb 20, 2022

I'm now showing the file name as the root of the tree so there is no stray indentation. Better?

Yes that's perfect!

Off-topic: the default icon in the top left corner of a dialog on Windows looks really ugly. Can/should we disable this?

Not sure if that's worth the effort 😅

@cbrnr
Copy link
Owner Author

cbrnr commented Feb 20, 2022

Not sure if that's worth the effort 😅

If it's easy to do (e.g. set a flag) then probably yes.

@cbrnr cbrnr merged commit 1dbf8af into main Feb 20, 2022
@cbrnr cbrnr deleted the import-mat branch February 20, 2022 19:57
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Load 2D arrays from .mat and .npy
2 participants