methlabUZH / automagic

Automagic
GNU General Public License v3.0
89 stars 32 forks source link

use of regex can break paths #59

Closed dominikwelke closed 2 years ago

dominikwelke commented 2 years ago

hi there,

I found out that the use of regular expressions to derive pathnames as it is currently implemented can break the system, as it is not confined to the actual filename, but looks at the full path including all folders.

I encountered this with the following function:

function reducedAddress = extractReducedAddress(resultAddress, dsRate)

somewhere upstream in my path/to/file I have a foldername including crop, and the op is matched by the regexp and exchanged by reducedX.

here my error:

(...)
Saving results...

ans =

    'Cannot create 'reduced2_sub-001_task-xxxx_eeg.mat' because '/(...)/dataset/eeg_crreduced2_test/sub-001/eeg' does not exist.'

Warning: Error in file: /(...)/matlab_toolboxes/automagic/src/Block.m (Line: 1340)

i'll create a pull request to fix this.

please comment there, if there are other potentially relevant spots, or if i destroyed an intended functionality.

cheers, Dominik

ksgfan commented 2 years ago

Looks good, thank you for contributing to automagic!