If you have a question or issue with MNE-Python, please include the following info:
MNE version: e.g. 1.3.1
operating system: e.g. macOS 13
I’m modifying the annotations on my data using mne.Annotations and set_annotations but this doesn’t save the modifications I’m making to the raw file so I have to reset them every time I reopen the file. Is there a way I can save the modifications to the raw data file itself so it’s just good to go? Thanks!
The file is 2710.045 s long which I know is a very long file. When I use the raw_intensity.save(fname) command to save, it will only let me save the file as a .fif file instead of a .snirf file. Then when I go to load the participant file again, it will only load the original .snirf file and not the modified .fif file as the participant’s data.
I never work with fNIRS data, but I think we found the issue.
When you save a Raw object with MNE, it is indeed saved as a .fif file. This format support all of the MNE data structures, including annotations. Thus, when you will open this saved .fif file, your annotations will be present.
Saving to another format is called exporting, you can find here the function to export Raw object, currently supporting BrainVision, EEGLAB and EDF formats.
Based on your text, it seems like you are:
loading the .snirf file in a Raw object
do some stuff one the Raw object, e.g. adding annotation
saving? as you can not export to .snirf, I’m guessing you are saving to .fif anyway
loading the original .snirf again, without the modification done in step 2, instead of loading the modified .fif
Thank you so much! This worked perfectly! I have one last question, if you don’t mind—I was able to run my individual subject analyses no problem by just loading the individual file with read_raw_fif but I don’t know how to load the .fif files as a directory so I can run a group GLM. The BIDSPath instructions included in the group GLM tutorial don’t seem to work and the importing data page linked doesn’t include instructions for .fif file. How would I create a group directory object with my .fif files if my files are organized like this (example linked)?
Thank you so much for all your help! I cannot tell you how much I appreciate it.
Isabel
Thank you so much! How would I indicate a root directory though? Bc specifying a folder and then iterating through it doesn’t seem to work i.e.,
fnirs_data_folder = ‘/Users/in65/Desktop/GroupGLM’;
raws = list()
for file in fnirs_data_folder:
raw = read_raw_fif(file, preload=True)
raws.append(raw)
Also read_raw_fif doesn’t load directories correct? So all of my .fif participant files would have to be in the same folder instead of individual subj folders?
from pathlib import Path
fnirs_data_folder = Path(‘/Users/in65/Desktop/GroupGLM’)
print(fnirs_data_folder.exists()) # double check that you specified the path correctly
files = fnirs_data_folder.glob("*.fif")
# use line below to see if glob caught the files you want:
print(list(files)) # should print a list containing the files you want to load
then you should be able to use the loop suggested before.
Thank you all so much! The Path code you posted does create a list of the files I am trying to load but for whatever reason, when I try to run the actual for file in fnirs_data_folder loop, it stalls out and refuses to load. Do you have any reason why that might be? I’m not running any code not posted in this thread.