[FieldTrip] Invalid file identifier when reading file with fiff_read_raw_segment

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Wed Apr 3 12:02:11 CEST 2024


Hi Alexandria,

Hmm, I am not sure what might be causing this. I cannot reproduce it on my end with the data that you provided (thanks for that!).
I think that you might be working with an outdated copy of the fiff-readers - as provided in fieldtrip/external/mne.

Your error stack mentions the error in fiff_read_raw_segment to be thrown at line 152, which is executing fiff_read_tag(…

However, the most recent version of the code (which should be in line with the ‘original’ version https://github.com/mne-tools/mne-matlab<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmne-tools%2Fmne-matlab&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd6ab124f41c940b268c408dc53c5214f%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638477353345408413%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=PdRDm3wMmu0xz4C081eEAaoUjBWSzuEvhZRA5XNtf20%3D&reserved=0>) with its reads something else: https://github.com/fieldtrip/fieldtrip/blob/8f99c23131e221e1958bf3632a4aa125637ed501/external/mne/fiff_read_raw_segment.m#L152<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffieldtrip%2Ffieldtrip%2Fblob%2F8f99c23131e221e1958bf3632a4aa125637ed501%2Fexternal%2Fmne%2Ffiff_read_raw_segment.m%23L152&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd6ab124f41c940b268c408dc53c5214f%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638477353349939790%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=K1bwmpH9XU7OjtHCirUjGje%2By%2BfV48z%2F0OYBzCTkN1A%3D&reserved=0>

Could you update your fieldtrip version, and try whether your problem persists? If so, we can take it from there.

Best wishes,

Jan-Mathijs

PS: I have a working matlab implementation of a ‘vanilla’ signal-space separation procedure, incorporating both a spatial and subsequent temporal projection, which I wrote to be able to apply SSS to OPM data. Drop me a direct message if you would be interested in working on this together.




On 3 Apr 2024, at 01:07, Xan McPherson via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:

Hello everyone,

My name is Alexandria McPherson and I am a PhD student working with the physics behind MEG at the Institute for Learning and Brain Sciences, University of Washington, Seattle. Currently, I am focusing on ways to modify the signal space separation method for use with on-scalp MEG sensor systems.

 I am running into some issues using FieldTrip to load raw data from .fif files. Specifically, I have been working with the example file "sample-audvis-raw.fif" which is provided by MNE-Python in their "MEG/sample" data folder. Here is a Dropbox link to the data: https://www.dropbox.com/scl/fo/gffle6d9ppa47pkmes8gj/h?rlkey=8swrsnlyiz61si5ycrxg5x9c2&dl=0<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.dropbox.com%2Fscl%2Ffo%2Fgffle6d9ppa47pkmes8gj%2Fh%3Frlkey%3D8swrsnlyiz61si5ycrxg5x9c2%26dl%3D0&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd6ab124f41c940b268c408dc53c5214f%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638477353349939790%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=%2Fz85DWhK31J4Shu5NPAYZm30ObapTTDSsIX6X0uF650%3D&reserved=0>.
I am first loading in the "info" structure, here is the code I am running:
 filename = "C:/Users/.../mne_data/MNE-sample-data/MEG/sample/sample_audvis_raw.fifinfo = fiff_read_meas_info(filename);[raw] = fiff_setup_read_raw(filename);[data,times] = fiff_read_raw_segment(raw);

I am able to read the "info" and "raw" objects, but when I run "fiff_read_raw_segment", I recieve the following error:
Error using fseek. Invalid file identifier. Use fopen to generate a valid file identifier.
Error in fiff_read_tag (line 83)
fseek(fid,pos,'bof');
Error in fiff_read_raw_segment (line 152)
tag = fiff_read_tag(raw.fid,this.ent.pos);

I also get this same error with other MEG "fif" files. Would you have any ideas as to what might be the issue?

Thanks!
Alexandria
Physics PhD Student | I-LABS | University of Washington
B.S. Engineering Physics | Colorado School of Mines
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd6ab124f41c940b268c408dc53c5214f%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638477353350095975%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=cGpVtNALEv6oyEbwcxa0KMOVaqoec31nRPvFNWp%2BnO0%3D&reserved=0>
https://doi.org/10.1371/journal.pcbi.1002202

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20240403/afe45d93/attachment.htm>


More information about the fieldtrip mailing list