phys2bids icon indicating copy to clipboard operation
phys2bids copied to clipboard

Add multi-run workflow synchronized with BIDS dataset

Open tsalo opened this issue 3 years ago • 2 comments

Closes #217 and supersedes #219.

This is a reduced version of #219, with all extraneous changes removed. Here are the general steps for the proposed workflow:

  1. Load relevant (currently just BOLD) scans from BIDS dataset and determine acquisition time, duration, and generalized name for each.
  2. Extract trigger onsets from BlueprintInput object.
  3. Attempt to match physio trigger onsets to scan onsets.
  4. Interpolate any missing physio trigger periods from available scans.
  5. Identify onsets and offsets for physio trigger periods for each frequency in the physio object.
  6. Slice the physio object into acquisition-specific BlueprintOutputs.
  7. Save BlueprintOutput objects to BIDS files.
  8. Generate a figure showing timing of scans and physio trigger periods before and after synchronization, for QC purposes.

Proposed Changes

  • Add a new module, phys2bids.synchronization, with a function named workflow() meant to perform unsupervised separation of multi-run physio files using onset-time and duration information from a converted BIDS dataset.
  • Add a new function, phys2bids.bids.update_bids_name(), which adds entities to a BIDS-format filename.
  • Add phys2bids.slice4phys.slice_phys(), a function that slices a physio object into individual runs. This is based off of phys2bids.slice4phys.slice4phys(), but is not linked to the existing multi-run workflow.
  • Update package requirements to include scipy, pybids, and pandas.

Change Type

  • [ ] bugfix (+0.0.1)
  • [X] minor (+0.1.0)
  • [ ] major (+1.0.0)
  • [ ] refactoring (no version update)
  • [ ] test (no version update)
  • [ ] infrastructure (no version update)
  • [ ] documentation (no version update)
  • [ ] other

Checklist before review

  • [ ] I added everything I wanted to add to this PR.
  • [X] [Code or tests only] I wrote/updated the necessary docstrings.
  • [ ] [Code or tests only] I ran and passed tests locally.
  • [ ] [Documentation only] I built the docs locally.
  • [ ] My contribution is harmonious with the rest of the code: I'm not introducing repetitions.
  • [X] My code respects the adopted style, especially linting conventions.
  • [X] The title of this PR is explanatory on its own, enough to be understood as part of a changelog.
  • [X] I added or indicated the right labels.
  • [ ] I added information regarding the timeline of completion for this PR.
  • [X] Please, comment on my PR while it's a draft and give me feedback on the development!

tsalo avatar Jan 02 '21 00:01 tsalo

Codecov Report

Merging #374 (cab25c7) into master (f587559) will decrease coverage by 17.78%. The diff coverage is 15.63%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #374       +/-   ##
===========================================
- Coverage   94.61%   76.83%   -17.79%     
===========================================
  Files           8        9        +1     
  Lines         836     1079      +243     
===========================================
+ Hits          791      829       +38     
- Misses         45      250      +205     
Impacted Files Coverage Δ
phys2bids/synchronization.py 0.00% <0.00%> (ø)
phys2bids/slice4phys.py 40.00% <3.63%> (-57.15%) :arrow_down:
phys2bids/bids.py 95.80% <90.00%> (-2.26%) :arrow_down:

codecov[bot] avatar Jan 02 '21 00:01 codecov[bot]

@smoia I've realized over time that, not only is FIU's current physio setup suboptimal, but it's also pretty rare. I don't think that many folks would actually find this workflow useful, and I only ended up using it for one project (FIU's now in the process of updating their physio setup). Do you mind if I close this PR?

tsalo avatar Aug 12 '22 21:08 tsalo