Repository navigation
fix(path): change only the file name when deriving a related file path - #210
Merged
Merged
Conversation
Several places derived a file path with strrep(filePath, '.mat', ...), which replaces the text anywhere in the path. A folder name containing it was rewritten too, as with ~/.matlab on Linux. The new nansen.util.path.appendToFilename adds a suffix before the extension, and paths that change extension use changeFilenameExtension. Removing the extension for a one-file-per-item catalog folder uses fileparts. strrep also left a path without the expected extension unchanged, so the classifier apps could write a cleaned file over the original. appendToFilename always changes the name. MotionCorrection keeps converting only .mat to .tif, so it checks the extension before calling the helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
…pace The mclassifier package does not depend on the nansen namespace, so manualClassifier now has its own local appendToFilename. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Several places derive one file path from another with
strrep(filePath, '.mat', ...).strrepreplaces the text anywhere in the path, so a folder name containing it is rewritten as well. On Linux the MATLAB preference folder is~/.matlab, which contains.mat.For the sites that add a suffix there is a second problem. If the path does not contain the expected extension,
strrepreturns it unchanged. InmanualClassifierandroiclassifier.App, the cleaned results would then be saved over the file they came from.What changes
nansen.util.path.appendToFilenameadds text between the file name and its extension. It is used byroiclassifier.App,TaskProcessorandMotionCorrectionwhen saving RGB projections. Themclassifierpackage does not depend on thenansennamespace, somanualClassifierhas a local copy of the function.Sites that change an extension use the existing
changeFilenameExtension:ProjectManager,FileAdapter,SciScanRawandsaveIcon.MotionCorrection.openTargetStackconverts only.matto.tifand leaves other extensions alone, so it checks the extension before calling the helper.StorableCatalog.saveToFolderandloadFromFolderremove the extension through a small private method based onfileparts.Notes for review
The same pattern in
LocalRootPathManageris fixed in #209 and is left out here.🤖 Generated with Claude Code