bids-standard / pybids

Python tools for querying and manipulating BIDS datasets.
https://bids-standard.github.io/pybids/
MIT License
219 stars 121 forks source link

Sampling correctly in the case of slice-timing-corrected datasets #770

Open effigies opened 3 years ago

effigies commented 3 years ago

In most tools, slice-timing correction resamples values to the middle of the volume acquisition (TR / 2 for typical sequences).

If I understand the code correctly, we:

1) Create an HRF regressor at the collection sampling rate (default: 10Hz) https://github.com/bids-standard/pybids/blob/73bfdcac6c6f57a87146d88c9ff2f665a36fc19d/bids/modeling/transformations/compute.py#L53-L58 2) Resample to TR; since this is down-sampling, we apply a Butterworth filter: https://github.com/bids-standard/pybids/blob/28b068c2ebecd2bc0e613b02d30694f6f34d2785/bids/variables/variables.py#L556-L562 And then resample around the start of the volume times: https://github.com/bids-standard/pybids/blob/28b068c2ebecd2bc0e613b02d30694f6f34d2785/bids/variables/variables.py#L566-L570

So we need to reconsider how best to handle these. I think it's good that we're oversampling by default, but when we resample to 'TR', we need to ensure that the sampling point corresponds to the correct point in the time series. nilearn.glm uses frame_times to change the sampling. We could do that in step (1) above, but I think the more correct approach is to set the frame times at the resample stage.

effigies commented 3 years ago

This is related to https://github.com/nipreps/fmriprep/issues/2477. See also https://github.com/poldrack/SliceTimingCorrection for an exploration of the problem.

effigies commented 2 years ago

Starting to think making DenseRunVariables into wrappers for xarray.DataArrays might be cleanest.

effigies commented 2 years ago

To quickly note the decisions in last night's call:

1) Move to xarray, defining time axis ticks as we can. 2) Get metadata from fMRIPrep indicating the temporal shift. 3) Future: Add transform for performing boxcar windowing, allowing for averaging over TA