Skip to content

Commit

Permalink
Update everything.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo committed Oct 9, 2023
1 parent 9c11f8b commit 97bcc09
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
19 changes: 17 additions & 2 deletions docs/workflows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,16 @@ Denoising
=========
:class:`~xcp_d.interfaces.nilearn.DenoiseNifti`, :class:`~xcp_d.interfaces.nilearn.DenoiseCifti`

Temporal censoring
------------------
Temporal censoring [OPTIONAL]
-----------------------------

Prior to confound regression, high-motion volumes will be removed from the BOLD data.
These volumes will also be removed from the nuisance regressors.
Please refer to :footcite:t:`power2012spurious` for more information.

.. tip::
Censoring can be disabled by setting ``--fd-thresh 0``.


Confound regression
-------------------
Expand Down Expand Up @@ -339,6 +342,18 @@ Interpolation

An interpolated version of the ``denoised BOLD`` is then created by filling in the high-motion
outlier volumes with cubic spline interpolated data, as implemented in ``Nilearn``.

.. 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.

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


Expand Down
3 changes: 2 additions & 1 deletion xcp_d/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,9 @@ def test_pnc_cifti(data_dir, output_dir, working_dir):
"sub-1648798153_ses-PNC1_task-rest_acq-singleband_desc-confounds_timeseries.tsv",
)
motion_df = pd.read_table(motion_file)
motion_df.loc[-5:, "trans_x"] = 100
motion_df.loc[-10:, "trans_x"] = 100
motion_df.to_csv(motion_file, sep="\t", index=False)
print("Overwrote confounds file.")

parameters = [
dataset_dir,
Expand Down
9 changes: 3 additions & 6 deletions xcp_d/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,18 +474,15 @@ def denoise_with_nilearn(
first_outliers = consecutive_outliers_idx[0]
last_outliers = consecutive_outliers_idx[-1]

LOGGER.warning(consecutive_outliers_idx)
LOGGER.warning(n_volumes)

# 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], :] = interpolated_unfiltered_bold[
first_outliers[1] + 1, :
]
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:
Expand Down

0 comments on commit 97bcc09

Please sign in to comment.