Skip to content

Commit

Permalink
Address merge issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo committed Oct 11, 2023
1 parent 4769639 commit 8b03a8a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
11 changes: 0 additions & 11 deletions docs/workflows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -356,17 +356,6 @@ outlier volumes with cubic spline interpolated data, as implemented in ``Nilearn

The resulting ``interpolated, denoised BOLD`` is primarily used for bandpass filtering.

.. warning::
In versions 0.4.0rc2 - 0.5.0, XCP-D used cubic spline interpolation,
followed by bandpass filtering.

However, cubic spline interpolation can introduce large spikes and drops in the signal
when the censored volumes are at the beginning or end of the run,
which are then propagated to the filtered data.

To address this, XCP-D now replaces interpolated volumes at the edges of the run with the
closest non-outlier volume's data, as of 0.5.1.


Bandpass filtering [OPTIONAL]
-----------------------------
Expand Down
31 changes: 0 additions & 31 deletions xcp_d/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,37 +494,6 @@ def denoise_with_nilearn(
last_outliers[0] - 1, :
]

# Replace any high-motion volumes at the beginning or end of the run with the closest
# low-motion volume's data.
outlier_idx = list(np.where(~sample_mask)[0])
if outlier_idx:
# Use https://stackoverflow.com/a/48106843/2589328 to group consecutive blocks of outliers.
gaps = [[s, e] for s, e in zip(outlier_idx, outlier_idx[1:]) if s + 1 < e]
edges = iter(outlier_idx[:1] + sum(gaps, []) + outlier_idx[-1:])
consecutive_outliers_idx = list(zip(edges, edges))
first_outliers = consecutive_outliers_idx[0]
last_outliers = consecutive_outliers_idx[-1]

# Replace outliers at beginning of run
if first_outliers[0] == 0:
LOGGER.warning(
f"Outlier volumes at beginning of run ({first_outliers[0]}-{first_outliers[1]}) "
"will be replaced with first non-outlier volume's values."
)
interpolated_unfiltered_bold[
: first_outliers[1] + 1, :
] = interpolated_unfiltered_bold[first_outliers[1] + 1, :]

# Replace outliers at end of run
if last_outliers[1] == n_volumes - 1:
LOGGER.warning(
f"Outlier volumes at end of run ({last_outliers[0]}-{last_outliers[1]}) "
"will be replaced with last non-outlier volume's values."
)
interpolated_unfiltered_bold[last_outliers[0] :, :] = interpolated_unfiltered_bold[
last_outliers[0] - 1, :
]

# Now apply the bandpass filter to the interpolated, denoised data
if low_pass is not None and high_pass is not None:
# TODO: Replace with nilearn.signal.butterworth once 0.10.1 is released.
Expand Down

0 comments on commit 8b03a8a

Please sign in to comment.