how to differentiate csv and .mff folder that system can find the path specified?

42 Views Asked by At

I am analyzing sensory evoked potential using MNE Python. I have .mff raw EEG data in a folder format on my computer and the duration of stimulation in a CSV file. I need to get and load duration and .mff for preprocessing. however, I cannot locate both and receive the following error:

FileNotFoundError

Traceback (most recent call last)
Cell In[19], line 20
     11     report.add_code('01-seps.py', title='Code')
     13         # Load raw data
     14 #     raw = mne.io.read_raw_egi(eeg_file)
     15     
     16 #     behav = pd.read_csv(dur_file)
     17     
     18 #         # Get EEG data and durations
     19     eeg_file = opj(basepath, p, 'sub',
---> 20                    [f for f in os.listdir(opj(basepath, p, 'sub')) if '.mff' in f][0])
     22     dur_file = opj(basepath, p, 'sub',
     23                    [f for f in os.listdir(opj(basepath, p, 'sub')) if 'durations' in f][0])

FileNotFoundError: [WinError 3] The system cannot find the path specified: 'D:\\test\\data\\sub-041_20240129_114214.mff\\sub'

here is my code, I would appreciate it if anybody could help

#path
basepath = 'D:\\test\\data'
derivpath = 'D:\\test\\derivpath'
if not os.path.exists(derivpath):
    os.mkdir(derivpath)

#get the participants 
parts = [s for s in 
        os.listdir(basepath) if 'sub-' in s]
parts.sort() 

visual_inspect = False

#SEP task 
all_evoked = [] 
for p in parts:
    if not os.path.exists(opj(derivpath, p)):
        os.mkdir(opj(derivpath, p))
    
# Initialize report
    report = Report(verbose=False, subject=p,
                    title='SEP report for part ' + p)

    report.add_code('01-seps.py', title='Code')

# Get EEG data and durations
    eeg_file = opj(basepath, p, 'sep',
                   [f for f in os.listdir(opj(basepath, p, 'sep')) if '.mff' in f][0])

    dur_file = opj(basepath, p, 'sep', 
                   [f for f in os.listdir(opj(basepath, p, 'sep')) if 'durations' in f][0])
0

There are 0 best solutions below