Skip to content

Fix: symlink may point to absolute path#799

Merged
m-reuter merged 2 commits intoDeep-MI:devfrom
dkuegler:fix/asegdkt-statsfile-symlink
Mar 18, 2026
Merged

Fix: symlink may point to absolute path#799
m-reuter merged 2 commits intoDeep-MI:devfrom
dkuegler:fix/asegdkt-statsfile-symlink

Conversation

@dkuegler
Copy link
Member

This PR fixes an error in run_fastsurfer.sh, where $subject_dir/stats/aseg+DKT.stats was not pointing to the correct file. aseg+DKT.stats is usually a symlink to aseg+DKT.VINN.stats, but the target was previously an absolute path, which would create invalid paths if created inside a docker or singularity image that mounted $subject_dir somewhere else. Another failure "opportunity" was when files were moved.

Furthermore, the copy option of softlink_or_copy would fail, if a relative path was used, but the current working directory was not the directory of the link.

@dkuegler
Copy link
Member Author

The doc build error is a problem inherited from pyrr, and this PR does not have any changes to the doc. (can be ignored)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes symlink/copy behavior so generated stats symlinks remain valid when $subject_dir is mounted at different paths (e.g., Docker/Singularity), and makes softlink_or_copy’s copy fallback handle relative link targets correctly.

Changes:

  • Convert an absolute $asegdkt_vinn_statsfile symlink target into a relative path before linking aseg+DKT.stats.
  • Update softlink_or_copy to resolve relative link targets correctly when falling back from symlink to copy.
  • Add/adjust inline documentation around softlink_or_copy behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
run_fastsurfer.sh Computes a relative target path before creating the legacy aseg+DKT.stats link.
recon_surf/functions.sh Improves softlink_or_copy copy fallback for relative symlink targets and updates comments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dkuegler dkuegler force-pushed the fix/asegdkt-statsfile-symlink branch from 823c46c to f8a27ee Compare March 17, 2026 11:10
…tats/aseg+DKT.stats was not pointing to the correct file. aseg+DKT.stats is usually a symlink to aseg+DKT.VINN.stats, but the target was previously an absolute path, which would create invalid paths if created inside a docker or singularity image that mounted $subject_dir somewhere else. Another failure "opportunity" was when files were moved.

Furthermore, the copy option of softlink_or_copy would fail, if a relative path was used, but the current working directory was not the directory of the link.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses portability issues around stats-file symlinks/copies when running inside containers or after subject directory moves, by ensuring the legacy aseg+DKT.stats link points correctly and by improving softlink_or_copy handling of relative link targets.

Changes:

  • Convert the aseg+DKT.VINN.stats path to a relative path (when possible) before creating the legacy aseg+DKT.stats link in run_fastsurfer.sh.
  • Update softlink_or_copy to better document semantics and attempt to correctly resolve relative link targets when falling back to copying.
  • Add a relative_to() helper (Python-based) to compute a relative path from a link location to its target.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
run_fastsurfer.sh Computes a relative path for aseg+DKT.VINN.stats before linking to avoid absolute symlinks in containers.
recon_surf/functions.sh Refactors softlink_or_copy and introduces relative_to() to support relative symlink targets and copy fallback.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@m-reuter m-reuter merged commit fc6fae2 into Deep-MI:dev Mar 18, 2026
2 checks passed
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.

3 participants