Fixes behavior of stc.save() as mentioned in issue #13158
Fixes #13158 .
Doing stc.save("test.h5") saves a single test.h5 file, and doing stc.save("test.stc") saves to the two files test-lh.stc and test-rh.stc.
Please let me know if any more changes required in the current iteration.
@drammock I have changed ftype from None to auto coz it was fairly easy. I also put it to test by saving a sample of both .stc as well as .h5 filetypes. You can see them in the screenshot, that they're being saved in the directory, named as it was suggested by @larsoner in the issue. (will be deleting these files before commit)
But, while running tests, it shows the following error:
which says: FAILED test_source_estimate.py::test_io_stc - OSError: SourceEstimate File(s) not found for: PosixPath('/tmp/pytest-of-shresth/pytest-1/test_io_stc0/tmp.stc')
I'm not aware about how to fix this error. Please help.
Hey, @drammock, I implemented your suggestions, and ran pytest with --pdb flag. The issue seems to be coming from "read_source_estimate" in source_estimate.py, which looks like this in the terminal:
test_source_estimate.py:484: in test_io_stc
stc2 = read_source_estimate(tmp_path / "tmp.stc")
..\source_estimate.py:330: in read_source_estimate
raise OSError(f"SourceEstimate File(s) not found for: {fname_arg!r}")
E OSError: SourceEstimate File(s) not found for: WindowsPath('C:/Users/kesha/AppData/Local/Temp/pytest-of-kesha/pytest-3/test_io_stc0/tmp.stc')
Now that I look at test_source_estimate.py, in the function definition of test_io_stc, the stc file is saved first, using stc.save() function. Later, the same file is being read using read _source_estimate. Since we changed the naming of the files being saved, I believe that's what causes the issue. Will try fixing that and will get back to you with a solution soon.
have attached screenshots as well, please have a look:
I was able to successfully run " pytest test_source_estimate.py" with no fails, locally. I feel the issue has been solved and desired "intuitive naming" of stc files while saving them has been achieved. Please review the pull request once.
Hello, @drammock and @larsoner I believe that most of the changes have passed checks, but after numerous pytests, I can't pinpoint where does the issue lie that is stopping the remaining checks from passing.
Please guide me ahead..
I merged main into your branch to see if it fixes the CIs