mne-tools / mne-tools/mne-python

import persyst module cross platform paths

Open
#10,353 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.5k
Forks
1.6k
Avg merge
1d 6h
Merged PRs (30d)
100

Description

Dear MNE team:

In the persyst.py module there is an issue where the script is not platform agnostic in the way that it handles paths. Persyst lay files are only able to generate in windows platforms. So when those files are saved the lay files file section contains a windows path with the location where the file was created. If you try to process these files for analysis in a different computer MacOS or Linux. when you use persyt.py line 112

if key == 'file':
    dat_fname = op.basename(val)

if this is processed in a UNIX based machine it will output the windows path and it wont be able to get the correct basename of the file to extract the DAT file.

The only two ways I can envision this can be corrected is that you can continue to use the os module. But you then have to check if the system being use to process is a UNIX or windows base system by importing the platform python module and checking the type of system. If it is a linux system then you need to do:


import ntpath

dat_fname = ntpath.basename (val)

This indeed will correct the issue; but I am not sure the behavior in a windows machine as I am using linux.

Alternatively, you can dish the OS module all together and use pathlib, this library will handle the paths correctly in a system agnostic manner; but it will mean that you need to change everything where os module is used and make sure users install that library as part of the installation. Not sure what you think.

Andres

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in persyst.py at line 112 and inspect how the file value from a Persyst .lay file is converted to a DAT basename. Reproduce processing a Windows-style path on a Unix-based system, then verify that the correct DAT file is selected without breaking Windows behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.