Using mne-bids to convert CTF data to bids format

This function is triggering the error: https://github.com/mne-tools/mne-bids/blob/ace2a7d55ba943bb3cc0437ded1ac850c71ae278/mne_bids/copyfiles.py#L137-L166

specifically, the os.rename part of it.

Now let’s look at os.rename: os — Miscellaneous operating system interfaces — Python 3.12.0 documentation

it says:

On Windows, if dst exists a FileExistsError is always raised.

Interestingly it doesn’t say so for unix systems (linux, macos) – so this might be why I cannot reproduce your problem.

I think the solution might be that if write_raw_bids is called with overwrite=True (so the files already exist), then we should first completely remove the existing files before writing them again … because apparently the overwriting via os.rename doesn’t work on Windows.

Or we could look into using os.replace instead, see: If you want cross-platform overwriting of the destination, use replace(). (also from the os.rename docs)

2 Likes