Commit aa927ba
Add fix_rbc_release_tr.py for the C-PAC TR bandpass bug (#343)
* Add fix_rbc_release_tr.py script for TR bandpass bug
Lets users of an RBC data release re-derive a correctly-bandpassed
cleaned BOLD and all downstream metrics, by patching the template-space
`desc-head_bold.nii.gz` header (TR=0.0 on disk) with the TR read from
the native-space `desc-preproc_bold.nii.gz` before regression.
Outputs land under a parallel `--output-dir` tree using the published
release's filename conventions:
* cleaned BOLD + bandpass-filtered regressors
* ALFF / fALFF / ReHo at `desc-sm6`, `desc-smZstd`, `desc-zstd`
* Atlas-based mean timeseries (`.1D`, `(n_timepoints, n_rois)`)
* Pearson + nilearn partial-correlation matrices, per atlas
Metrics compose `rbc.workflows.metrics.single_session_metrics` and
`rbc.core.metrics.standardization.compute_zscore`. Atlas resolution
goes through `rbc_resources.ATLAS_REGISTRY` so the release-name -> file
mapping survives filename changes inside `rbc_resources`.
The script ships with PEP 723 inline metadata so it can be invoked
standalone via `uv run --script` without a clone. `--skip-metrics`
falls back to BOLD-only behavior. `--verify` scans every discoverable
run (header-only reads) and reports buggy / clean / inconclusive
counts. `RBC_WORK_DIR` is scoped to the script's tempdir for the
duration of the run so all niwrap exec folders get cleaned up.
The TR-restore helper is inlined in the script (mirrors
`rbc.core.functional.resampling._restore_tr`) so standalone PEP 723
runs against an unmodified `main` don't trip an ImportError on a
symbol that isn't yet public.
* add --work-dir option
* Switch shutil.copy2 to shutil.copyfile
Existing file permissions were copied alongside the file itself, causing issues with
overwrriting existing files even when in an temporary directory if user executing
script did not have the appropriate permissions.
This switches the `copy2` method used to `copyfile` which does not have this issue
---------
Co-authored-by: Jason Kai <21226986+kaitj@users.noreply.github.com>1 parent bd762df commit aa927ba
4 files changed
Lines changed: 1280 additions & 0 deletions
File tree
- scripts
- tests
- data
- unit/scripts
0 commit comments