Repository navigation
FIX: Infer file format and avoid duplicate extensions in stc.save (#13158) - #14491
Conversation
cc8cc30 to
b835096
Compare
CarinaFo
left a comment
There was a problem hiding this comment.
Hi Ishaaaan17,
thanks for taking on this bug.
I think it would make sense to update the other filetypes as well if they suffer from the same double extension issue (which I think they do, particularly "w").
| vertices=self.rh_vertno, | ||
| data=rh_data, | ||
| ) | ||
| elif ftype == "w": |
There was a problem hiding this comment.
I think we should also update the code for saving with "w"
There was a problem hiding this comment.
good catch! updated save() and read_source_estimate() to handle both "stc" and "w" files with the same logic, and added test coverage for "w" in test_io_w.
| fname_r = str(_check_fname(fname + "-rh.w", overwrite=overwrite)) | ||
| _write_w(fname_l, vertices=self.lh_vertno, data=lh_data[:, 0]) | ||
| _write_w(fname_r, vertices=self.rh_vertno, data=rh_data[:, 0]) | ||
| elif ftype == "h5": |
There was a problem hiding this comment.
haven't looked into h5 file types, but might be the same issue
There was a problem hiding this comment.
looked into h5 files, _BaseSourceEstimate.save() already handles this safely via fname.suffix != ".h5" (it only appends -stc.h5 if .h5 is not already present), so saving test.h5 or test-stc.h5 does not suffer from double extensions.
b835096 to
f7545b8
Compare
…e-tools#13158) - Support ftype='auto' as default to infer format from file extension. - Avoid duplicate extensions when fname already ends with hemisphere or format tags. - Support reading both new and legacy formatted files in read_source_estimate. Co-authored-by: Shresth Keshari <[email protected]>
f7545b8 to
5507306
Compare
CarinaFo
left a comment
There was a problem hiding this comment.
Looks good to me. Thanks again.
|
Just pushed a tiny commit to extend the behavior properly to volume source estimates, marking for merge-when-green, thanks in advance @ishaaaan17 ! |
reference issue (if any)
Closes #13158
Supersedes #13165
what does this implement/fix?
ftype='auto'as the default inSourceEstimate.save()andVolSourceEstimate.save()to infer file format from file extension.fnamealready ends with tags like-lh.stcor.stc(e.g. preventingtest-lh.stc-lh.stc).read_source_estimate()to gracefully resolve both clean filenames and legacy filenames.test_source_estimate.pyto coverautoinference and deduplicated extensions.Co-authored-by: Shresth Keshari [email protected]
additional information
ai assistance disclosure: i used google antigravity to help locate the abandoned pr history, identify the edge cases in
read_source_estimate, and write the test cases intest_source_estimate.py.