Skip to content

BUG: Bugs with stc.save behavior #13158

Description

@larsoner

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.

Activity

  1. added this to the 1.10 milestone on Mar 13, 2025
  2. drammock commented on Mar 13, 2025

    @drammock
    Member

    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 [...]

    ouch, that is not good. +1 to add ftype="auto" that infers from extension and falls back to stc.

    Change the behavior for ftype="stc" to only add the -lh.stc to the filename if it's not already there.

    To me it feels slightly weird to specify fname="foo-lh.stc" and have it write two files (lh and rh) but I think what you propose is still better than the status quo EDIT: and changing it to only write one file would be a big backcompat break, so +1 on that part too.

  3. shresth-keshari commented on Mar 18, 2025

    @shresth-keshari
    Contributor

    Hey @larsoner , I've fixed this by making changes in the save function in source_estimate.py, and tested this as well
    I'm opening a pull request, please let me know if there are some special tests required for successfully merging.

  4. modified the milestones: 1.10, 1.11 on Jun 26, 2025
  5. removed this from the 1.11 milestone on Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions