Add an API #2

Closed
mslw wants to merge 0 commits from api into main
Owner

This introduces input arguments, discovery of required inputs, and workflow flexibility regarding slice timing / field maps, eliminating hard-coded paths.

TODO:

  • Remove remaining hard-coded paths
  • Find a solution for the header override (depends on dataset)
  • Improve output file naming
  • Add the capability to report the list of required file inputs

Two caveats limit the flexibility in terms of applying the script as-is to different datasets, but can be easily addressed on a per-dataset basis:

The header override solution still contains hardcoded elements, which would need to be provided per space/resolution combination, but the part is reasonably flexible and can be converted into an input in the future.

The --dry-run option will print out paths of file dependencies sans the raw bold metadata (because of BIDS inheritance, we use PyBIDS to read the metadata and it does not report the path(s)).

Note: the PR has been force-pushed, so for an up-to-date list of commits look at the commits tab (not conversation tab below).

This introduces input arguments, discovery of required inputs, and workflow flexibility regarding slice timing / field maps, eliminating hard-coded paths. TODO: - [x] Remove remaining hard-coded paths - [x] Find a solution for the header override (depends on dataset) - [x] Improve output file naming - [x] Add the capability to report the list of required file inputs Two caveats limit the flexibility in terms of applying the script as-is to different datasets, but can be easily addressed on a per-dataset basis: The header override solution still contains hardcoded elements, which would need to be provided per space/resolution combination, but the part is reasonably flexible and can be converted into an input in the future. The `--dry-run` option will print out paths of file dependencies *sans the raw bold metadata* (because of BIDS inheritance, we use PyBIDS to read the metadata and it does not report the path(s)). Note: the PR has been force-pushed, so for an up-to-date list of commits look at the commits tab (not conversation tab below).
This change brings an API - raw and derived paths are taken as inputs,
and all required paths are discovered from that, either by reading sidecars
and doing simple path substitutions, or by using BIDSLayout. The workflow is
made more flexible, accounting for presence or absence of slice timing and field
map corrections; this info is obtained or inferred from the target file sidecar.

Initializing BIDSLayout (even with validate=False) can take a while, especially
for larger datasets. We do this for the raw dataset, because location of json
sidecar with raw BOLD metadata is not defined upfront (inheritance). For the
fMRIPrep derivative, fMRIPrep appears to always create literal sidecars, and
we use the projected BOLD sidecar to discover all that we need: raw BOLD file,
required xforms, and fieldmap ID, if present. Having these we can also build
paths to the mask and boldref files by substituting filename endings.

There is some more involvement with field maps: the derived BOLD metadata only
encodes the fieldmap ID in the path of one of the xform files used. We take this
ID glob the derived field map directory for a matching json file, and take the
fieldmap reference and coefficients from there.

The input paths are converted to absolute paths; this is required to use the
BIDS Layout (which by default uses absolute paths) without having to manipulate
the paths further, and to use (at least some of) the nipype interfaces without
errors.
mslw changed title from WIP: Add an API to Add an API 2024-10-31 20:15:02 +00:00
Author
Owner

Rebased and pushed manually.

Rebased and pushed manually.
mslw closed this pull request 2024-11-03 19:41:32 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mslw/fmriprep-resampling!2
No description provided.