Skip to content

Commit

Permalink
Add options for UK Biobank data (#1022)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo authored Jan 11, 2024
1 parent 9fbc46c commit 36e0370
Show file tree
Hide file tree
Showing 27 changed files with 1,073 additions and 608 deletions.
52 changes: 39 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ orbs:
.dockersetup:
&dockersetup
docker:
- image: pennlinc/xcp_d_build:0.0.10
- image: pennlinc/xcp_d_build:0.0.11
working_directory: /src/xcp_d

runinstall:
Expand Down Expand Up @@ -73,6 +73,25 @@ jobs:
# The resource_class feature allows configuring CPU and RAM resources for each job. Different resource classes are available for different executors. https://circleci.com/docs/2.0/configuration-reference/#resourceclass
resource_class: large

download_data_ukbiobank:
<<: *dockersetup
steps:
- checkout
- restore_cache:
key: ukbiobank-08
- run: *runinstall
- run:
name: Download ukbiobank test data
command: |
cd /src/xcp_d/.circleci
python get_data.py $PWD/data ukbiobank
- save_cache:
key: ukbiobank-08
paths:
- /src/xcp_d/.circleci/data/ukbiobank
# The resource_class feature allows configuring CPU and RAM resources for each job. Different resource classes are available for different executors. https://circleci.com/docs/2.0/configuration-reference/#resourceclass
resource_class: large

download_data_fmriprepwithoutfreesurfer:
<<: *dockersetup
steps:
Expand Down Expand Up @@ -200,36 +219,36 @@ jobs:
- store_artifacts:
path: /src/xcp_d/.circleci/out/test_ds001419_cifti/xcp_d/

pnc_nifti:
ukbiobank:
<<: *dockersetup
steps:
- checkout
- run:
name: Check whether build should be skipped
command: |
cd /src/xcp_d
if [[ "$( git log --format=oneline -n 1 $CIRCLE_SHA1 | grep -i -E '\[skip[ _]?pnc_nifti\]' )" != "" ]]; then
echo "Skipping pnc_nifti build"
if [[ "$( git log --format=oneline -n 1 $CIRCLE_SHA1 | grep -i -E '\[skip[ _]?ukbiobank\]' )" != "" ]]; then
echo "Skipping ukbiobank build"
circleci step halt
fi
- restore_cache:
key: pnc-02
key: ukbiobank-08
- run: *runinstall
- run:
name: Run full xcp_d on nifti with freesurfer
no_output_timeout: 1h
command: |
pytest -rP -o log_cli=true -m "pnc_nifti" --cov-append --cov-report term-missing --cov=xcp_d --data_dir=/src/xcp_d/.circleci/data --output_dir=/src/xcp_d/.circleci/out --working_dir=/src/xcp_d/.circleci/work xcp_d
pytest -rP -o log_cli=true -m "ukbiobank" --cov-append --cov-report term-missing --cov=xcp_d --data_dir=/src/xcp_d/.circleci/data --output_dir=/src/xcp_d/.circleci/out --working_dir=/src/xcp_d/.circleci/work xcp_d
mkdir /src/coverage
mv /src/xcp_d/.coverage /src/coverage/.coverage.pnc_nifti
mv /src/xcp_d/.coverage /src/coverage/.coverage.ukbiobank
# remove nifti files before uploading artifacts
find /src/xcp_d/.circleci/out/ -name "*.nii.gz" -type f -delete
- persist_to_workspace:
root: /src/coverage/
paths:
- .coverage.pnc_nifti
- .coverage.ukbiobank
- store_artifacts:
path: /src/xcp_d/.circleci/out/test_pnc_nifti/xcp_d/
path: /src/xcp_d/.circleci/out/test_ukbiobank/xcp_d/

nibabies:
<<: *dockersetup
Expand Down Expand Up @@ -450,6 +469,13 @@ workflows:
tags:
only: /.*/

- download_data_ukbiobank:
requires:
- build
filters:
tags:
only: /.*/

- download_data_fmriprepwithoutfreesurfer:
requires:
- build
Expand Down Expand Up @@ -486,9 +512,9 @@ workflows:
tags:
only: /.*/

- pnc_nifti:
- ukbiobank:
requires:
- download_data_pnc
- download_data_ukbiobank
filters:
branches:
ignore:
Expand Down Expand Up @@ -561,7 +587,7 @@ workflows:
- pnc_cifti_t2wonly
- ds001419_nifti
- ds001419_cifti
- pnc_nifti
- ukbiobank
- nibabies
- nifti_without_freesurfer
- pytests
Expand All @@ -577,7 +603,7 @@ workflows:
requires:
- ds001419_nifti
- ds001419_cifti
- pnc_nifti
- ukbiobank
- nifti_without_freesurfer
- nibabies
- pnc_cifti
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM pennlinc/xcp_d_build:0.0.10
FROM pennlinc/xcp_d_build:0.0.11

# Install xcp_d
COPY . /src/xcp_d
Expand Down
22 changes: 20 additions & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ xcp_d-combineqc
xcp_d.utils.bids
xcp_d.utils.concatenation
xcp_d.utils.confounds
xcp_d.utils.dcan2fmriprep
xcp_d.utils.hcp2fmriprep
xcp_d.utils.doc
xcp_d.utils.execsummary
xcp_d.utils.filemanip
Expand All @@ -100,3 +98,23 @@ xcp_d-combineqc
xcp_d.utils.sentry
xcp_d.utils.utils
xcp_d.utils.write_save


***********************************************************************
:mod:`xcp_d.ingression`: Functions to Ingress Preprocessing Derivatives
***********************************************************************

.. automodule:: xcp_d.ingression
:no-members:
:no-inherited-members:

.. currentmodule:: xcp_d

.. autosummary::
:toctree: generated/
:template: module.rst

xcp_d.ingression.abcdbids
xcp_d.ingression.hcpya
xcp_d.ingression.ukbiobank
xcp_d.ingression.utils
82 changes: 82 additions & 0 deletions docs/workflows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,88 @@ For more information about confound regressor selection, please refer to :footci
options.


.. list-table:: Preprocessing Pipeline Support

* - Nuisance Strategy
- 24P
- 27P
- 36P
- acompcor
- acompcor_gsr
- aroma
- aroma_gsr
- gsr_only
- none
* - fMRIPrep (>=23.1.0)
- X
- X
- X
- X
- X
-
-
- X
- X
* - fMRIPrep (<23.1.0)
- X
- X
- X
- X
- X
- X
- X
- X
- X
* - Nibabies
- X
- X
- X
- X
- X
-
-
- X
- X
* - ABCD-BIDS (DCAN)
- X
- X
- X
-
-
-
-
- X
- X
* - HCP-YA
- X
- X
- X
-
-
-
-
- X
- X
* - UK Biobank
- X
-
-
-
-
-
-
- X
- X

.. important::
fMRIPrep removed AROMA support in 23.1.0.
In the future, there will be an fMRIPost-AROMA BIDS App that runs AROMA on fMRIPrep outputs.

.. warning::
The strategy ``gsr_only`` is only appropriate for UK Biobank data,
as those data have already been denoised with FSL FIX.


Dummy scan removal [OPTIONAL]
=============================
:func:`~xcp_d.workflows.postprocessing.init_prepare_confounds_wf`,
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ per-file-ignores = [
]

[tool.pytest.ini_options]
addopts = '-m "not ds001419_nifti and not ds001419_cifti and not pnc_nifti and not pnc_cifti and not pnc_cifti_t2wonly and not fmriprep_without_freesurfer and not nibabies"'
addopts = '-m "not ds001419_nifti and not ds001419_cifti and not ukbiobank and not pnc_cifti and not pnc_cifti_t2wonly and not fmriprep_without_freesurfer and not nibabies"'
markers = [
"ds001419_nifti: mark NIfTI integration test for fMRIPrep derivatives from ds001419",
"ds001419_cifti: mark CIFTI integration test for fMRIPrep derivatives from ds001419",
"pnc_nifti: mark integration test for fMRIPrep derivatives with NIFTI settings",
"ukbiobank: mark integration test for UK Biobank derivatives with NIfTI settings",
"pnc_cifti: mark integration test for fMRIPrep derivatives with CIFTI settings",
"pnc_cifti_t2wonly: mark integration test for fMRIPrep derivatives with CIFTI settings and a simulated T2w file",
"fmriprep_without_freesurfer: mark integration test for fMRIPrep derivatives without FreeSurfer",
Expand Down
29 changes: 24 additions & 5 deletions xcp_d/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ def get_parser():
"--input_type",
required=False,
default="fmriprep",
choices=["fmriprep", "dcan", "hcp", "nibabies"],
choices=["fmriprep", "dcan", "hcp", "nibabies", "ukb"],
help=(
"The pipeline used to generate the preprocessed derivatives. "
"The default pipeline is 'fmriprep'. "
"The 'dcan', 'hcp', and 'nibabies' pipelines are also supported. "
"The 'dcan', 'hcp', 'nibabies', and 'ukb' pipelines are also supported. "
"'nibabies' assumes the same structure as 'fmriprep'."
),
)
Expand Down Expand Up @@ -218,6 +218,8 @@ def get_parser():
"aroma_gsr",
"custom",
"none",
# GSR-only for UKB
"gsr_only",
],
default="36P",
type=str,
Expand Down Expand Up @@ -797,6 +799,21 @@ def _validate_parameters(opts, build_log):
)
opts.process_surfaces = True

elif opts.input_type == "ukb":
if opts.cifti:
build_log.warning(
f"With input_type {opts.input_type}, cifti processing (--cifti) will be "
"disabled automatically."
)
opts.cifti = False

if opts.process_surfaces:
build_log.warning(
f"With input_type {opts.input_type}, surface normalization "
"(--warp-surfaces-native2std) will be disabled automatically."
)
opts.process_surfaces = False

# process_surfaces and nifti processing are incompatible.
if opts.process_surfaces and not opts.cifti:
build_log.error(
Expand Down Expand Up @@ -852,11 +869,13 @@ def build_workflow(opts, retval):
retval["work_dir"] = str(opts.work_dir)

# First check that fmriprep_dir looks like a BIDS folder
if opts.input_type in ("dcan", "hcp"):
if opts.input_type in ("dcan", "hcp", "ukb"):
if opts.input_type == "dcan":
from xcp_d.utils.dcan2fmriprep import convert_dcan2bids as convert_to_bids
from xcp_d.ingression.abcdbids import convert_dcan2bids as convert_to_bids
elif opts.input_type == "hcp":
from xcp_d.utils.hcp2fmriprep import convert_hcp2bids as convert_to_bids
from xcp_d.ingression.hcpya import convert_hcp2bids as convert_to_bids
elif opts.input_type == "ukb":
from xcp_d.ingression.ukbiobank import convert_ukb2bids as convert_to_bids

NIWORKFLOWS_LOG.info(f"Converting {opts.input_type} to fmriprep format")
converted_fmri_dir = os.path.join(
Expand Down
Binary file added xcp_d/data/MNI152_T1_2mm.nii.gz
Binary file not shown.
8 changes: 8 additions & 0 deletions xcp_d/data/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
MNI152_T1_2mm.nii.gz comes from the FSL standard templates folder.
I copied it here to use in the UK Biobank ingression step,
instead of TemplateFlow's tpl-MNI152NLin6Asym_res-2 template,
because FSL's version is in LAS+, while TemplateFlow's version is in RAS+.

FSL apparently can't handle differently-oriented files,
and really only works with LAS+ files (yay),
so it just seems easier to have an LAS+ copy of the template on hand.
11 changes: 11 additions & 0 deletions xcp_d/data/boilerplate.bib
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,17 @@ @article{najdenovska2018vivo
doi={10.1038/sdata.2018.270}
}

@article{miller2016multimodal,
title={Multimodal population brain imaging in the UK Biobank prospective epidemiological study},
author={Miller, Karla L and Alfaro-Almagro, Fidel and Bangerter, Neal K and Thomas, David L and Yacoub, Essa and Xu, Junqian and Bartsch, Andreas J and Jbabdi, Saad and Sotiropoulos, Stamatios N and Andersson, Jesper LR and others},
journal={Nature neuroscience},
volume={19},
number={11},
pages={1523--1536},
year={2016},
publisher={Nature Publishing Group US New York}
}

@article{taylorlomb,
title={Lomb-Scargle your way to RSFC parameter estimation in AFNI-FATCAT},
author={Taylor, Paul A and Chen, Gang and Glen, Daniel R and Reynolds, Richard C and Cox, Robert W},
Expand Down
3 changes: 3 additions & 0 deletions xcp_d/data/reports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ sections:
- bids: {datatype: figures, suffix: design}
caption: The "design matrix" represents the confounds that are used to denoise the BOLD data.
subtitle: Design Matrix for Confound Regression
style:
height: 100px
width: auto
- bids: {datatype: figures, desc: postprocessing, suffix: bold}
caption: FD and DVARS are two measures of in-scanner motion.
This plot shows standardized FD, DVARS, and then a carpet plot for the
Expand Down
2 changes: 1 addition & 1 deletion xcp_d/data/transform/itkIdentityTransform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#Transform 0
Transform: MatrixOffsetTransformBase_double_3_3
Parameters: 1 0 0 0 1 0 0 0 1 0 0 0
FixedParameters: 0 0 0
FixedParameters: 0 0 0
9 changes: 9 additions & 0 deletions xcp_d/ingression/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Tools for converting derivatives from various pipelines to an fMRIPrep-like format."""
from xcp_d.ingression import abcdbids, hcpya, ukbiobank, utils

__all__ = [
"abcdbids",
"hcpya",
"ukbiobank",
"utils",
]
Loading

0 comments on commit 36e0370

Please sign in to comment.