Skip to content

fix(path): change only the file name when deriving a related file path - #210

Merged
ehennestad merged 2 commits into
devfrom
edit-file-names-without-touching-folders
Nov 9, 2026
Merged

ehennestad merged 2 commits into
devfrom
edit-file-names-without-touching-folders

Conversation

@ehennestad

@ehennestad ehennestad commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Several places derive one file path from another with strrep(filePath, '.mat', ...). strrep replaces 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, strrep returns it unchanged. In manualClassifier and roiclassifier.App, the cleaned results would then be saved over the file they came from.

What changes

nansen.util.path.appendToFilename adds text between the file name and its extension. It is used by roiclassifier.App, TaskProcessor and MotionCorrection when saving RGB projections. The mclassifier package does not depend on the nansen namespace, so manualClassifier has a local copy of the function.

Sites that change an extension use the existing changeFilenameExtension: ProjectManager, FileAdapter, SciScanRaw and saveIcon.

MotionCorrection.openTargetStack converts only .mat to .tif and leaves other extensions alone, so it checks the extension before calling the helper.

StorableCatalog.saveToFolder and loadFromFolder remove the extension through a small private method based on fileparts.

Notes for review

The same pattern in LocalRootPathManager is fixed in #209 and is left out here.

🤖 Generated with Claude Code

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>
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

689 tests  +19   689 ✅ +19   1m 29s ⏱️ +22s
 56 suites + 2     0 💤 ± 0 
  1 files   ± 0     0 ❌ ± 0 

Results for commit 4ddde74. ± Comparison against base commit f206931.

♻️ This comment has been updated with latest results.

…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>

@ehennestad ehennestad left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@ehennestad
ehennestad merged commit 06e41cb into dev Nov 9, 2026
5 checks passed
@ehennestad
ehennestad deleted the edit-file-names-without-touching-folders branch November 9, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant