mne-tools / mne-matlab

MNE scripting with Matlab
BSD 3-Clause "New" or "Revised" License
34 stars 35 forks source link

Error: read_source_spaces #16

Open sivyobe opened 6 years ago

sivyobe commented 6 years ago

Hello, I try to read in matlab (with the mne-matlab tool) a source created in MNE-python with the additional information of patch. I use in python the command mne.setup_source_space(sj, fname=True, spacing='ico4', subject_dir=, add_dist=True), followed by mne.write_source_spaces(...) to have the fif file with patch information. But when I read the file in matlab there isn't any information about the patch, i.e. the values nearest, nearest_info, pinfo, dist and dist_limit are empty.

Then I try to rewrite the file using one more step in python: mne.read_source_spaces(..., patch_stats=True, ...) followed by mne.write_source_spaces(...) and in this case when I try to read the fif file in matlab an error was reported:

Error using fiff_read_tag (line 178) Only two and three dimensional matrices are supported at this time

How can I solve the problem? Because I need the patch information for my work at this step in matlab.

agramfort commented 6 years ago

it seems to be read:

https://github.com/mne-tools/mne-matlab/blob/master/matlab/mne_read_source_spaces.m#L251

if you read it back from Python you recover the info?

sivyobe commented 6 years ago

How can I check if there are the patch informations in python? When I read with the command src=mne.read_source_spaces(..., patch_stats=True, ...), what kind of command can I use to check the information of src?

agramfort commented 6 years ago

please provide a full code snippet using sample data so we can debug faster.

sivyobe commented 6 years ago

In python:

import mne
path = mne.datasets.sample.data_path(download=True)
src = mne.setup_source_space(
    subject='sample', subjects_dir=path + '/subjects', add_dist=True, spacing='ico4')
mne.write_source_spaces('ico4-src.fif', src)
src_p = mne.read_source_spaces('ico4-src.fif', patch_stats=True)
mne.write_source_spaces('ico4-src_p.fif', src_p)

In matlab (working in the folder 'path'): ico4=mne_read_source_spaces('ico4-src.fif'); This command give me the error:

Only two and three dimensional matrices are supported at this time

And also trying with ico4=mne_read_source_spaces('ico4-src_p.fif');

agramfort commented 6 years ago

@sivyobe I edited your code snippet. I can confirm the error. I don't have much time now. It's a bug in the matlab IO.

maybe @SherazKhan knows what to do

SherazKhan commented 6 years ago

@agramfort @sivyobe I can fix the bug in mne-matlab and send the PR @sivyobe do you want to take first take on the PR ?

sivyobe commented 6 years ago

What do you mean @SherazKhan?

solleo commented 5 years ago

@SherazKhan The bug seems to be unfixed in mne-matlab yet?

>> src = mne_read_source_spaces('S01-4098-src.fif', 1);
    Reading a source space...Error using fiff_read_tag (line 178)
Only two and three dimensional matrices are supported at this time
Error in mne_read_source_spaces/read_source_space/find_tag (line
288)

There in fiff_read_tag.m, ndim is read as "1" while only 2 and 3 are allowed for the matrix form.