Skip to content

SAFIR list-mode: find relative filenames next to the parameter file - #1799

Open
frostyhand wants to merge 2 commits into
UCL:masterfrom
frostyhand:fix/safir-relative-filenames
Open

frostyhand wants to merge 2 commits into
UCL:masterfrom
frostyhand:fix/safir-relative-filenames

Conversation

@frostyhand

Copy link
Copy Markdown

Changes in this pull request

Relative filenames in a SAFIR list-mode parameter file (listmode data filename, template projection data filename, crystal map filename) are now relative to the directory of the parameter file, as for Interfile headers. Absolute filenames are unchanged.

Previously, post_processing() checked that the list-mode and template files exist before any directory handling. Run from another directory, both checks failed, which gave the two "Error post processing keyword values" warnings and "no file format found" in #1680.

actual_do_parsing() now stores the directory of the parameter file (get_directory_name()), and post_processing() prepends it to each relative filename with FilePath::prepend_directory_name() before the existence checks. No C-string functions are used.

One behaviour change to be aware of: a parameter file in another directory whose filenames were written relative to the current directory (not to the parameter file) no longer works. That matches the Interfile convention you described in the issue.

Testing performed

  • New test_SAFIRCListmodeInputFileFormat writes a SAFIRDualRingPrototype template, a minimal SAFIR list-mode file and a parameter file into a subdirectory, then reads the list-mode data via read_from_file<ListModeData> from the parent directory, with relative and with absolute filenames. On master the relative case fails with "no file format found"; with this change both pass.
  • list_lm_info test_SAFIR_listmode_dir/listmode.par: aborts on master with the error from SAFIR list-mode reading files fails from different directory #1680, succeeds with this change. Running it from the directory of the parameter file still works.
  • Full ctest on macOS (arm64, conda clang 21, Release, without ITK/HDF5/ROOT/parallelproj): 68 of 71 tests pass under ctest -j8. The other three are Interfile image IO tests; they pass when rerun one at a time and do not involve SAFIR.
  • I did not test a relative crystal map filename, as I have no SAFIR crystal map file.

Related issues

Fixes #1680

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have added docstrings/doxygen in line with the guidance in the developer guide
  • I have implemented unit tests that cover any new or modified functionality (if applicable)
  • The code builds and runs on my machine
  • documentation/release_6.6.htm has been updated with any functionality change (if applicable)

Contribution Notes

Please tick the following:

  • The content of this Pull Request (the Contribution) is intentionally submitted for inclusion in STIR (the Work) under the terms and conditions of the Apache-2.0 License.
  • I (or my institution) have signed the STIR Contribution License Agreement (not required for small changes).

The list-mode, template projection data and crystal map filenames in a
SAFIR parameter file were opened relative to the current directory, so
reading failed unless STIR was run from the directory of the parameter
file. They are now relative to the directory of the parameter file, as
for Interfile headers. Absolute filenames are unchanged.

Adds test_SAFIRCListmodeInputFileFormat.

Fixes UCL#1680
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 6 complexity · 0 duplication

Metric Results
Complexity 6
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@KrisThielemans KrisThielemans self-assigned this Dec 3, 2026
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.

SAFIR list-mode reading files fails from different directory

2 participants