mne-tools / mne-tools/mne-python

BUG: Bugs with stc.save behavior

Open
#13,158 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

Currently if you do stc.save("test.h5") and it's a surface source estimate, it will save test.h5-lh.stc and test.h5-rh.stc files because the default is ftype="stc", and these must be saved in two separate files. If you instead stc.save("test-lh.stc"), it will end up writing test-lh.stc-lh.stc and test-lh.stc-rh.stc files. This is documented behavior but I think we could improve it by:

  1. Changing the ftype="stc" default to be ftype="auto", which would mean: infer from the extension if possible, otherwise assume "stc"
  2. Change the behavior for ftype="stc" to only add the -lh.stc to the filename if it's not already there.

This would have led to the much more intuitive behaviors that doing stc.save("test.h5") would have saved a single test.h5 file, and doing stc.save("test-lh.stc") would have saved to the two files test-lh.stc and test-rh.stc. It makes for much nicer saving and checking at the user end because you can have a single path like test-lh.stc, check for its existence, and if missing then save -- all without needing to compensate for magic stuff in the paths you pass around.

This will create a small backward compat break for people who were relying on the double-naming -lh.stc-lh.stc at the end of a filename, but I think hopefully those cases are rare enough to be worth the tradeoff of what I think is much clearer, intuitive behavior.

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 by locating the stc.save entry point and the existing handling of the ftype argument and surface-source filenames. Check how extensions are inferred and how left/right STC paths are generated; done means the proposed test.h5 and test-lh.stc cases produce the stated paths without the double suffix, with existing save behavior covered.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.