mne-tools / mne-matlab

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

.fif epochs import to Fieldtrip fails #12

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hello, CC @robertoostenveld, @agramfort

This is MNE-Fieldtrip format compatibility issue.

I tried to import -epo.fif file created in MNE python, latest version on today (v13) using fieldtrip cookbook:

%%%%%%%%%%%%%%%%%%%%%%% fiff_file = '/MYPATH/myfile-epo.fif'; cfg = [] cfg.dataset = fiff_file; data1 = ft_preprocessing(cfg); %%%%%%%%%%%%%%%%%%%%%%%

I got en error: Reference to non-existent field 'FIFFB_EPOCHS'.

Error using fiff_read_epochs (line 46) Could not find epochs data

Error in fiff_read_epochs (line 46) error(me,'Could not find epochs data');

Error in ft_read_header (line 1665) epochs = fiff_read_epochs(filename);

Error in ft_preprocessing (line 397) hdr = ft_read_header(cfg.headerfile, 'headerformat', cfg.headerformat, 'coordsys', cfg.coordsys, 'coilaccuracy', cfg.coilaccuracy);

I use the latest Fieldtrip version fieldtrip-lite-20161024. It seems that something is wrong with the data structure...?

Elena Orekhova

robertoostenveld commented 7 years ago

the code around line 46 in fiff_read_epochs reads

%
% Locate the data of interest
%
processed = fiff_dir_tree_find(meas, FIFF.FIFFB_PROCESSED_DATA);
if length(processed) == 0
        fclose(fid);
    error(me,'Could not find epochs data');
end

ep = fiff_dir_tree_find(meas, FIFF.FIFFB_EPOCHS);
if length(ep) == 0
        fclose(fid);
    error(me,'Could not find epochs data');  % LINE 46
end

It seems to me that 1) the file was written incorrectly, or that 2) the file does not contain any epochs, perhaps not even MEG data.

error 2 would be your error (i.e. trying to read the wrong file), error 1 would be an error in the writing code, i.e. in MNE-Python.

robertoostenveld commented 7 years ago

Perhaps you should report it as mne-python issue instead. @agramfort, what do you think?

ghost commented 7 years ago

I am sure that my -epo.fif file is OK, since I can browse it in mne-python and the epochs look as they should. I also used these epochs for source localization in MNE. Therefore, it is more likely to be error [1]

Elena

On 25 October 2016 at 12:50, Robert Oostenveld notifications@github.com wrote:

the code around line 46 in fiff_read_epochs reads

% % Locate the data of interest % processed = fiff_dir_tree_find(meas, FIFF.FIFFB_PROCESSED_DATA); if length(processed) == 0 fclose(fid); error(me,'Could not find epochs data'); end

ep = fiff_dir_tree_find(meas, FIFF.FIFFB_EPOCHS); if length(ep) == 0 fclose(fid); error(me,'Could not find epochs data'); % LINE 46 end

It seems to me that 1) the file was written incorrectly, or that 2) the file does not contain any epochs, perhaps not even MEG data.

error 2 would be your error (i.e. trying to read the wrong file), error 1 would be an error in the writing code, i.e. in MNE-Python.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mne-tools/mne-matlab/issues/12#issuecomment-256002104, or mute the thread https://github.com/notifications/unsubscribe-auth/ALeOuvSp4tzqZmXD9Uz9aRfTEXaEiTe_ks5q3d7agaJpZM4Kf0tK .

agramfort commented 7 years ago

elena, can you share the epo.fif file?

ghost commented 7 years ago

OK, but I can only do it tomorrow morning. Elena

On 25 October 2016 at 20:56, Alexandre Gramfort notifications@github.com wrote:

elena, can you share the epo.fif file?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mne-tools/mne-matlab/issues/12#issuecomment-256140484, or mute the thread https://github.com/notifications/unsubscribe-auth/ALeOuncY3-GuvJ2nckYCSGsVRlp1kUzqks5q3lDngaJpZM4Kf0tK .

ghost commented 7 years ago

Hi, Here is the -epo.fif file I was not able to upload to the Fieldtrip.

https://drive.google.com/open?id=0B4vg0ZrqLpGCcnNBODBHSmJFcWM

Best regards, Elena

On 25 October 2016 at 20:56, Alexandre Gramfort notifications@github.com wrote:

elena, can you share the epo.fif file?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mne-tools/mne-matlab/issues/12#issuecomment-256140484, or mute the thread https://github.com/notifications/unsubscribe-auth/ALeOuncY3-GuvJ2nckYCSGsVRlp1kUzqks5q3lDngaJpZM4Kf0tK .

agramfort commented 7 years ago

I think i fixed it in:

https://github.com/mne-tools/mne-matlab/commit/89a8b65e3126199c120c22ebfacc7c08de3f779d

if you confirm it works I'll open a PR on fieldtrip.

it's our mess with change/fix of FIFF constants.

ghost commented 7 years ago

Dear Alex,

How can I try the fixed program? Should I download the new MNE version?

Elena

On 29 October 2016 at 19:40, Alexandre Gramfort notifications@github.com wrote:

I think i fixed it in:

https://github.com/mne-tools/mne-matlab/commit/ 89a8b65e3126199c120c22ebfacc7c08de3f779d

if you confirm it works I'll open a PR on fieldtrip.

it's our mess with change/fix of FIFF constants.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mne-tools/mne-matlab/issues/12#issuecomment-257105087, or mute the thread https://github.com/notifications/unsubscribe-auth/ALeOurPEtrVo682WHt2F9OzcjKc-vE5Fks5q44T-gaJpZM4Kf0tK .

agramfort commented 7 years ago

just get the latest mne-matlab toolbox at:

https://github.com/mne-tools/mne-matlab/archive/master.zip

ghost commented 7 years ago

Thank you! It worked.

Elena

On 1 November 2016 at 14:18, Alexandre Gramfort notifications@github.com wrote:

just get the latest mne-matlab toolbox at:

https://github.com/mne-tools/mne-matlab/archive/master.zip

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mne-tools/mne-matlab/issues/12#issuecomment-257564074, or mute the thread https://github.com/notifications/unsubscribe-auth/ALeOun_gZU6r8Nvf5mN56ojJalV9Jlprks5q5zwxgaJpZM4Kf0tK .

agramfort commented 7 years ago

see https://github.com/fieldtrip/fieldtrip/pull/250

closing.