Skip to content

Commit

Permalink
forcing posix paths
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperVanDenBosch committed Jul 9, 2024
1 parent 9fe66c3 commit 282029c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/rsatoolbox/io/spm.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ def relocate_file(self, fpath: str) -> str:
str: SPM-style file path
"""
norm_fpath = fpath.replace('\\', os.sep)
base_path = dirname(self.path).replace('\\', os.sep)
c = norm_fpath.find('func')
return join(dirname(self.path), norm_fpath[c:])
return base_path + '/' + norm_fpath[c:]

def get_betas(self, mask: Nifti1Image | NDArray | str) -> Tuple[NDArray, NDArray, Dict]:
"""
Expand Down
8 changes: 4 additions & 4 deletions tests/test_io_spm.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ def test_adapt_spm_paths(self, loadmat):

def test_relocate_file(self):
from rsatoolbox.io.spm import SpmGlm
spm = SpmGlm(join('path', 'leaf'), self.nitools)
spm = SpmGlm(join('/path', 'leaf'), self.nitools)
self.assertEqual(
spm.relocate_file('/bla/dip/func/abc.nii,1 '),
join('path', 'func', 'abc.nii,1 ')
'/path/func/abc.nii,1 '
)
self.assertEqual(
spm.relocate_file('\\bla\\dip\\func\\abc.nii,2 '),
join('path', 'func', 'abc.nii,2 ')
spm.relocate_file('c:\\bla\\dip\\func\\abc.nii,2 '),
'/path/func/abc.nii,2 '
)

0 comments on commit 282029c

Please sign in to comment.