How do I load multiple segments?

mne 1.2.2 on macosx.

I have two files:

s1="John_Doe_2022-10-09_15-22-31_Segment_0.edf"
s2="John_Doe_2022-10-09_15-22-31_Segment_1.edf"

what is the correct way to load a single Raw file from them?

Apparently, the following works:

a = mne.io.read_raw_edf(s1,preload=True)
b = mne.io.read_raw_edf(s2,preload=True)
a.append(b)

Is there a cleaner way?
E.g., I suspect that I will eventually encounter more than 2 segments - do I need to manually search for them?

Thank you.

Hello,

You can use mne.concatenate_raws — MNE 1.2.2 documentation
to concatenate multiple raws (provided in a list) into a single instance.

raws = list()
for file in files:
    raw = read_raw(file, preload=False)
    raws.append(raw)
raw = concatenate_raws(raws, preload=True)

Note the use of preload to load the dataset only once in memory.

Mathieu

2 Likes