<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi Alexandria,
<div class=""><br class="">
</div>
<div class="">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!).</div>
<div class="">I think that you might be working with an outdated copy of the fiff-readers - as provided in fieldtrip/external/mne.</div>
<div class=""><br class="">
</div>
<div class="">Your error stack mentions the error in fiff_read_raw_segment to be thrown at line 152, which is executing fiff_read_tag(…</div>
<div class=""><br class="">
</div>
<div class="">However, the most recent version of the code (which should be in line with the ‘original’ version
<a href="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" originalsrc="https://github.com/mne-tools/mne-matlab" shash="zJ8UXs23wGSaXooXbRjNVP4uP/18Bxag1BYwpFYsrQ/DdddN79wJn9NuZxNtVWANRt4L+cVFUEjwLPW4RIDxOLol28KIMScyB5Fd+H6L0JsStYQ98u1AqmXF2V/Syb4QLlBod/wWKI1bpa6aMOvR5VVVfYlou560oAT9oUgr0Bo=" class="">
https://github.com/mne-tools/mne-matlab</a>) with its reads something else: <font color="#0068da" class="">
<span style="caret-color: rgb(0, 104, 218);" class=""><u class=""><a href="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" originalsrc="https://github.com/fieldtrip/fieldtrip/blob/8f99c23131e221e1958bf3632a4aa125637ed501/external/mne/fiff_read_raw_segment.m#L152" shash="pCvC9RcQyi7hQnFCH/TOKzZRgPHWmVwVd9PRNoq5e6tAZP/kzoZWKO34W0tpMrtfwcECn4DP6bjPXqNwznhgTliZCmKn7K/dS4IR+VZ+7JFHUkG1BMfFKcPPkrR2EXKXL0iFNw+sOT/ud+GCe4vRvOaG85WSLxjm2ReFpSUTIHg=" class="">https://github.com/fieldtrip/fieldtrip/blob/8f99c23131e221e1958bf3632a4aa125637ed501/external/mne/fiff_read_raw_segment.m#L152</a></u></span></font></div>
<div class=""><br class="">
<div>Could you update your fieldtrip version, and try whether your problem persists? If so, we can take it from there.</div>
<div><br class="">
</div>
<div>Best wishes,</div>
<div><br class="">
</div>
<div>Jan-Mathijs</div>
<div><br class="">
</div>
<div>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.</div>
<div> </div>
<div><br class="">
</div>
<div><br class="">
</div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 3 Apr 2024, at 01:07, Xan McPherson via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" class="">fieldtrip@science.ru.nl</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div class="">Hello everyone,</div>
<div class=""><br class="">
</div>
<div class="">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.</div>
<div class=""><br class="">
</div>
<div class=""> 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: <a href="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" originalsrc="https://www.dropbox.com/scl/fo/gffle6d9ppa47pkmes8gj/h?rlkey=8swrsnlyiz61si5ycrxg5x9c2&dl=0" shash="TqErTRCqOw1s/op3ZOtMq28Etjh+CK2nA+/9+aHqYO98mFwzKnDapkcDycNQPlwOY28QWetuo9KMi3Ak8PGlYDhe7jo/qA10Iglv0Br31KS9wz8NyFlO2pRbcrZCbg1utQEr2QNjndyvjTYOPCy+Du0/FTe9tnRDSeksUOitsnQ=" originalsrc="https://www.dropbox.com/scl/fo/gffle6d9ppa47pkmes8gj/h?rlkey=8swrsnlyiz61si5ycrxg5x9c2&dl=0" shash="MGlt6IP3I3DEOkhBs7e8jI4XUqP9GiYe2h7co6Dd4m3GSLWx99jbtiWA9LPMOFn/1pJN1Qzklexz7aYmjOtHO/sEZheADp5O4QqplpYWoVIhQJEOZF8AnSWooNcFM/m1KWmlL0WnivWDYo7l0gFe+WHJYtn/naFISyJP5D8HArs=" target="_blank" class="">https://www.dropbox.com/scl/fo/gffle6d9ppa47pkmes8gj/h?rlkey=8swrsnlyiz61si5ycrxg5x9c2&dl=0</a>. </div>
<div class="">I am first loading in the "info" structure, here is the code I am running:</div>
<div class=""> <span style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">filename =
</span><span style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace;color:rgb(167,9,245)" class="">"C:/Users/.../mne_data/MNE-sample-data/MEG/sample/sample_audvis_raw.fif</span><span style="font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:10pt" class="">info
 = fiff_read_meas_info(filename);</span><span style="font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:10pt" class="">[raw] = fiff_setup_read_raw(filename);</span><span style="font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:10pt" class="">[data,times]
 = fiff_read_raw_segment(raw);</span><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I am able to read the "info" and "raw" objects, but when I run "fiff_read_raw_segment", I recieve the following error: <br class="">
</div>
<div class=""><font face="monospace" class="">Error using fseek. Invalid file identifier. Use fopen to generate a valid file identifier. </font></div>
<div class=""><font face="monospace" class="">Error in fiff_read_tag (line 83)</font><br class="">
</div>
<div class=""><font face="monospace" class="">fseek(fid,pos,'bof');<br class="">
Error in fiff_read_raw_segment (line 152)<br class="">
tag = fiff_read_tag(raw.fid,this.ent.pos);</font><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I also get this same error with other MEG "fif" files. Would you have any ideas as to what might be the issue?</div>
<div class=""><br class="">
</div>
<div class="">Thanks!</div>
Alexandria<br clear="all" class="">
<div class="">
<div dir="ltr" class="gmail_signature">
<div dir="ltr" class="">Physics PhD Student | I-LABS | University of Washington
<div class="">B.S. Engineering Physics | Colorado School of Mines</div>
</div>
</div>
</div>
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="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" originalsrc="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" shash="e5gHw0ICoG9q/BaGkshSC8/7jyJM8+QmNFEidpnlhJEtbUxDio8VwLn4r+284ZhgQGChLSC7XCUeasoPJ5G2bdHjIGsfvVwVyLZpu7oC0r3a0M/TmHPj2UQbnFIL2/8WfM6lRLQobvLdr5WPQVGjp3RU4aB0/zQHQIq3xnNr2EY=" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
https://doi.org/10.1371/journal.pcbi.1002202<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>