As a part of our workflow, .fif files were produced by a matlab code. Now I need to upload them in Python script.
However, I am getting an error that my .fif files are not the objects with the right attributes.
What is the best way to transfer the .fif files into the right object type?
Code:
"`raw = mne.io.read_raw_fif(fif_input_path, preload = True, verbose = False)`"
Error: `/tmp/ipykernel_4013990/1776892309.py:1: RuntimeWarning: Invalid tag with only 0/16 bytes at position 0 in file /gpfs/gibbs/project/pushkarskaya/hp245/Spaceship/Cache/Subject19/S19A_raw-1.fif
raw = mne.io.read_raw_fif(fif_input_path, preload = True, verbose = False)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[6], line 1
----> 1 raw = mne.io.read_raw_fif(fif_input_path, preload = True, verbose = False)
File ~/.conda/envs/mne/lib/python3.12/site-packages/mne/io/fiff/raw.py:532, in read_raw_fif(fname, allow_maxshield, preload, on_split_missing, verbose)
491 @fill_doc
492 def read_raw_fif(
493 fname, allow_maxshield=False, preload=False, on_split_missing="raise", verbose=None
494 ) -> Raw:
495 """Reader function for Raw FIF data.
496
497 Parameters
(...)
530 are updated accordingly.
531 """
--> 532 return Raw(
533 fname=fname,
534 allow_maxshield=allow_maxshield,
535 preload=preload,
536 verbose=verbose,
537 on_split_missing=on_split_missing,
538 )
File <decorator-gen-203>:10, in __init__(self, fname, allow_maxshield, preload, on_split_missing, verbose)
File ~/.conda/envs/mne/lib/python3.12/site-packages/mne/io/fiff/raw.py:100, in Raw.__init__(self, fname, allow_maxshield, preload, on_split_missing, verbose)
98 next_fname = fname
99 while next_fname is not None:
--> 100 raw, next_fname, buffer_size_sec = self._read_raw_file(
101 next_fname, allow_maxshield, preload, do_check_ext
102 )
103 do_check_ext = False
104 raws.append(raw)
File <decorator-gen-204>:12, in _read_raw_file(self, fname, allow_maxshield, preload, do_check_ext, verbose)
File ~/.conda/envs/mne/lib/python3.12/site-packages/mne/io/fiff/raw.py:192, in Raw._read_raw_file(self, fname, allow_maxshield, preload, do_check_ext, verbose)
190 whole_file = True
191 fname_rep = _get_fname_rep(fname)
--> 192 ff, tree, _ = fiff_open(fname, preload=whole_file)
193 with ff as fid:
194 # Read the measurement info
196 info, meas = read_meas_info(fid, tree, clean_bads=True)
File <decorator-gen-11>:12, in fiff_open(fname, preload, verbose)
File ~/.conda/envs/mne/lib/python3.12/site-packages/mne/_fiff/open.py:133, in fiff_open(fname, preload, verbose)
131 fid = _fiff_get_fid(fname)
132 try:
--> 133 return _fiff_open(fname, fid, preload)
134 except Exception:
135 fid.close()
File ~/.conda/envs/mne/lib/python3.12/site-packages/mne/_fiff/open.py:151, in _fiff_open(fname, fid, preload)
149 # Check that this looks like a fif file
150 prefix = f"file {repr(fname)} does not"
--> 151 if tag.kind != FIFF.FIFF_FILE_ID:
152 raise ValueError(f"{prefix} start with a file id tag")
154 if tag.type != FIFF.FIFFT_ID_STRUCT:
AttributeError: 'NoneType' object has no attribute 'kind'`