From 23fa8029c0de57540e95f3d849b8efe39f5379fd Mon Sep 17 00:00:00 2001 From: Mathias Goncalves Date: Tue, 20 Aug 2024 13:02:41 -0400 Subject: [PATCH 1/9] CI: Update with new GIN derivatives --- .circleci/config.yml | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9123f921..67857e24 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,7 +10,7 @@ _machine_defaults: &machine_defaults _python_defaults: &python_defaults docker: - - image: cimg/python:3.12.1 + - image: cimg/python:3.12.5 auth: username: $DOCKER_USER password: $DOCKER_PAT @@ -160,17 +160,16 @@ jobs: get_data: - docker: - - image: cimg/python:3.12.1 + <<: *python_defaults working_directory: /home/circleci/data steps: - restore_cache: keys: - - data-v0-{{ .Branch }}-{{ .Revision }} - - data-v0--{{ .Revision }} - - data-v0-{{ .Branch }}- - - data-v0-master- - - data-v0- + - data-v1-{{ .Branch }}-{{ .Revision }} + - data-v1--{{ .Revision }} + - data-v1-{{ .Branch }}- + - data-v1-master- + - data-v1- - run: name: Install datalad + git-annex command: | @@ -180,7 +179,7 @@ jobs: git config --global filter.annex.process "git-annex filter-process" git config --global user.name "Nipreps CI" git config --global user.email "nipreps@gmail.com" - pip install "datalad<0.18" + pip install datalad fi - run: name: Get bcp test data @@ -334,7 +333,7 @@ jobs: --output-spaces MNIInfant:cohort-1 func \ --sloppy --write-graph --mem-mb 14000 \ --nthreads 4 -vv --age-months 2 --sloppy \ - --derivatives /tmp/data/${DATASET}/derivatives/precomputed \ + --derivatives precomputed=/tmp/data/${DATASET}/derivatives/bibsnet \ --output-layout bids --anat-only - run: name: Checking outputs of anatomical nibabies run @@ -362,7 +361,7 @@ jobs: --output-spaces MNIInfant:cohort-1 func \ --sloppy --write-graph --mem-mb 14000 \ --nthreads 4 -vv --age-months 2 --sloppy \ - --derivatives /tmp/data/${DATASET}/derivatives/precomputed \ + --derivatives precomputed=/tmp/data/${DATASET}/derivatives/bibsnet \ --output-layout bids - run: name: Checking outputs of full nibabies run @@ -390,12 +389,7 @@ jobs: rm -f /tmp/data/${DATASET}-t2only/sub-01/ses-1mo/anat/*_T1w.* tree /tmp/data/${DATASET}-t2only mkdir -p /tmp/data/${DATASET}-t2only/derivatives - cp -r /tmp/data/${DATASET}/derivatives/precomputed /tmp/data/${DATASET}-t2only/derivatives - # rename the derivatives for now - this is only possible since they share the same space - sudo apt install rename - rename 's/space-T1w/space-T2w/' /tmp/data/${DATASET}-t2only/derivatives/precomputed/sub-01/ses-1mo/anat/* - sed -i 's/_T1w./_T2w./g' /tmp/data/${DATASET}-t2only/derivatives/precomputed/sub-01/ses-1mo/anat/*json - tree /tmp/data/${DATASET}-t2only/derivatives/precomputed + cp -r /tmp/data/${DATASET}/derivatives/bibsnet /tmp/data/${DATASET}-t2only/derivatives - run: name: Run nibabies single anatomical workflow @@ -412,7 +406,7 @@ jobs: --output-spaces MNIInfant:cohort-1 func \ --sloppy --write-graph --mem-mb 14000 \ --nthreads 4 -vv --age-months 2 --sloppy \ - --derivatives /tmp/data/${DATASET}-t2only/derivatives/precomputed \ + --derivatives precomputed=/tmp/data/${DATASET}-t2only/derivatives/bibsnet \ --output-layout bids --anat-only - run: name: Checking outputs of T2-only nibabies anat From ea53af0ddc51cb85e105b902b0333d8dd4eb7d62 Mon Sep 17 00:00:00 2001 From: Mathias Goncalves Date: Tue, 20 Aug 2024 13:04:52 -0400 Subject: [PATCH 2/9] CI: Set run to use infantfs --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 67857e24..3bb05d18 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -333,6 +333,7 @@ jobs: --output-spaces MNIInfant:cohort-1 func \ --sloppy --write-graph --mem-mb 14000 \ --nthreads 4 -vv --age-months 2 --sloppy \ + --surface-recon-method infantfs \ --derivatives precomputed=/tmp/data/${DATASET}/derivatives/bibsnet \ --output-layout bids --anat-only - run: @@ -361,6 +362,7 @@ jobs: --output-spaces MNIInfant:cohort-1 func \ --sloppy --write-graph --mem-mb 14000 \ --nthreads 4 -vv --age-months 2 --sloppy \ + --surface-recon-method infantfs \ --derivatives precomputed=/tmp/data/${DATASET}/derivatives/bibsnet \ --output-layout bids - run: @@ -406,6 +408,7 @@ jobs: --output-spaces MNIInfant:cohort-1 func \ --sloppy --write-graph --mem-mb 14000 \ --nthreads 4 -vv --age-months 2 --sloppy \ + --surface-recon-method infantfs \ --derivatives precomputed=/tmp/data/${DATASET}-t2only/derivatives/bibsnet \ --output-layout bids --anat-only - run: From 01ca0c9737d8aa57158b20c03c85bda0ef021a9f Mon Sep 17 00:00:00 2001 From: Mathias Goncalves Date: Wed, 21 Aug 2024 07:51:16 -0400 Subject: [PATCH 3/9] maint: use patched segmentation select pr --- pyproject.toml | 3 ++- requirements.txt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 39b9e2bf..31486ae5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,8 @@ dependencies = [ "pybids >= 0.15.0", "requests", "sdcflows >= 2.10.0", - "smriprep >= 0.16.0", +# "smriprep >= 0.16.0", + "smriprep @ git+https://github.com/nipreps/smriprep.git@fix/aparc-select", "tedana >= 23.0.2", "templateflow >= 24.2.0", "toml", diff --git a/requirements.txt b/requirements.txt index 7ea468ae..90282c7b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -389,7 +389,7 @@ six==1.16.0 # osfclient # pybtex # python-dateutil -smriprep==0.16.0 +smriprep @ git+https://github.com/nipreps/smriprep.git@fix/aparc-select # via nibabies (pyproject.toml) sqlalchemy==2.0.31 # via pybids From 156e9ac9bd0a327a97d612f7b8fc6116950529ae Mon Sep 17 00:00:00 2001 From: Mathias Goncalves Date: Wed, 21 Aug 2024 10:33:17 -0400 Subject: [PATCH 4/9] ci: update anatomical outputs --- .circleci/bcp_anat_outputs.txt | 27 ++++++++++++++------------- .circleci/bcp_anat_t2only_outputs.txt | 27 ++++++++++++++------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/.circleci/bcp_anat_outputs.txt b/.circleci/bcp_anat_outputs.txt index b32939d3..059ca258 100644 --- a/.circleci/bcp_anat_outputs.txt +++ b/.circleci/bcp_anat_outputs.txt @@ -10,39 +10,34 @@ logs/CITATION.tex sub-01 sub-01/ses-1mo sub-01/ses-1mo/anat -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-aparcaseg_dseg.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-aseg_dseg.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-brain_mask.json -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-brain_mask.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-preproc_T1w.json sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-preproc_T1w.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-ribbon_mask.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_dseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-preproc_T2w.json +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-preproc_T2w.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_from-MNIInfant+1_to-T1w_mode-image_xfm.h5 sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_from-T1w_to-MNIInfant+1_mode-image_xfm.h5 sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_from-T1w_to-fsnative_mode-image_xfm.txt sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_from-fsnative_to-T1w_mode-image_xfm.txt sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_curv.shape.gii -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_desc-reg_sphere.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_inflated.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_midthickness.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_pial.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_space-fsLR_desc-reg_sphere.surf.gii +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_space-fsaverage_desc-reg_sphere.surf.gii +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_sphere.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_sulc.shape.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_thickness.shape.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_white.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_curv.shape.gii -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_desc-reg_sphere.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_inflated.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_midthickness.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_pial.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_space-fsLR_desc-reg_sphere.surf.gii +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_space-fsaverage_desc-reg_sphere.surf.gii +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_sphere.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_sulc.shape.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_thickness.shape.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_white.surf.gii -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_label-CSF_probseg.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_label-GM_probseg.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_label-WM_probseg.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-brain_mask.json sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-brain_mask.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-preproc_T1w.json @@ -51,6 +46,12 @@ sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_dseg.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_label-CSF_probseg.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_label-GM_probseg.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_label-WM_probseg.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_desc-preproc_T2w.json -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_desc-preproc_T2w.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_desc-aparcaseg_dseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_desc-aseg_dseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_desc-ribbon_mask.json +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_desc-ribbon_mask.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_dseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_label-CSF_probseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_label-GM_probseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_label-WM_probseg.nii.gz sub-01_ses-1mo.html diff --git a/.circleci/bcp_anat_t2only_outputs.txt b/.circleci/bcp_anat_t2only_outputs.txt index 21824e2b..382c9354 100644 --- a/.circleci/bcp_anat_t2only_outputs.txt +++ b/.circleci/bcp_anat_t2only_outputs.txt @@ -10,45 +10,46 @@ logs/CITATION.tex sub-01 sub-01/ses-1mo sub-01/ses-1mo/anat -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-aparcaseg_dseg.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-aseg_dseg.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-brain_mask.json -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-brain_mask.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-preproc_T2w.json sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-preproc_T2w.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-ribbon_mask.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_dseg.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_from-MNIInfant+1_to-T2w_mode-image_xfm.h5 sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_from-T2w_to-MNIInfant+1_mode-image_xfm.h5 sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_from-T2w_to-fsnative_mode-image_xfm.txt sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_from-fsnative_to-T2w_mode-image_xfm.txt sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_curv.shape.gii -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_desc-reg_sphere.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_inflated.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_midthickness.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_pial.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_space-fsLR_desc-reg_sphere.surf.gii +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_space-fsaverage_desc-reg_sphere.surf.gii +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_sphere.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_sulc.shape.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_thickness.shape.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_white.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_curv.shape.gii -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_desc-reg_sphere.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_inflated.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_midthickness.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_pial.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_space-fsLR_desc-reg_sphere.surf.gii +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_space-fsaverage_desc-reg_sphere.surf.gii +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_sphere.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_sulc.shape.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_thickness.shape.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_white.surf.gii -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_label-CSF_probseg.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_label-GM_probseg.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_label-WM_probseg.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-brain_mask.json sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-brain_mask.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-preproc_T2w.json -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-preproc_T2w.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-preproc_T1w.json +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-preproc_T1w.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_dseg.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_label-CSF_probseg.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_label-GM_probseg.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_label-WM_probseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T2w_desc-aparcaseg_dseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T2w_desc-aseg_dseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T2w_desc-ribbon_mask.json +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T2w_desc-ribbon_mask.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T2w_dseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T2w_label-CSF_probseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T2w_label-GM_probseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T2w_label-WM_probseg.nii.gz sub-01_ses-1mo.html From d088c89258b8e604feaf0bebb9e0dfc7eec0258e Mon Sep 17 00:00:00 2001 From: Mathias Goncalves Date: Wed, 21 Aug 2024 11:02:36 -0400 Subject: [PATCH 5/9] maint: use developmental smriprep --- pyproject.toml | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 31486ae5..ad631baa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ dependencies = [ "requests", "sdcflows >= 2.10.0", # "smriprep >= 0.16.0", - "smriprep @ git+https://github.com/nipreps/smriprep.git@fix/aparc-select", + "smriprep @ git+https://github.com/nipreps/smriprep.git@master", "tedana >= 23.0.2", "templateflow >= 24.2.0", "toml", diff --git a/requirements.txt b/requirements.txt index 90282c7b..fe232852 100644 --- a/requirements.txt +++ b/requirements.txt @@ -389,7 +389,7 @@ six==1.16.0 # osfclient # pybtex # python-dateutil -smriprep @ git+https://github.com/nipreps/smriprep.git@fix/aparc-select +smriprep @ git+https://github.com/nipreps/smriprep.git@master # via nibabies (pyproject.toml) sqlalchemy==2.0.31 # via pybids From d2ae2271978bac1ba0f7d5a1622ff2e095347528 Mon Sep 17 00:00:00 2001 From: Mathias Goncalves Date: Wed, 21 Aug 2024 12:30:05 -0400 Subject: [PATCH 6/9] FIX: Use last volume as reference for shorter BOLD series --- nibabies/workflows/bold/reference.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/nibabies/workflows/bold/reference.py b/nibabies/workflows/bold/reference.py index 2c5c609f..6066e765 100644 --- a/nibabies/workflows/bold/reference.py +++ b/nibabies/workflows/bold/reference.py @@ -160,24 +160,25 @@ def init_raw_boldref_wf( def _select_frames( in_file: str, ref_frame_start: int, dummy_scans: int | None ) -> tuple[int, list]: + import warnings + import nibabel as nb import numpy as np img = nb.load(in_file) img_len = img.shape[3] - if dummy_scans: - # Ensure start index is the largest of the two - # Will usually be `ref_frame_start` - start_frame = max(ref_frame_start, dummy_scans) - else: - start_frame = ref_frame_start + # Ensure start index is the largest of the two + # Will usually be `ref_frame_start` + start_frame = max(ref_frame_start, dummy_scans) if dummy_scans else ref_frame_start if start_frame >= img_len: - raise KeyError( - f'Caculating the BOLD reference starting on frame: {start_frame} but not enough BOLD ' - f'volumes in {in_file}.' + warnings.warn( + f'Caculating the BOLD reference starting on frame {start_frame} but only {img_len} ' + 'volumes in BOLD file, so using last volume.', + stacklevel=1, ) + start_frame = img_len - 1 t_mask = np.array([False] * img_len, dtype=bool) t_mask[start_frame:] = True From edd75f2e4b79fa220bfed25d6a759f9ecad44c92 Mon Sep 17 00:00:00 2001 From: Mathias Goncalves Date: Wed, 21 Aug 2024 13:09:26 -0400 Subject: [PATCH 7/9] ci: update bold smoke test outputs --- .circleci/bcp_full_outputs.txt | 44 +++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/.circleci/bcp_full_outputs.txt b/.circleci/bcp_full_outputs.txt index fff15bb7..e68ca575 100644 --- a/.circleci/bcp_full_outputs.txt +++ b/.circleci/bcp_full_outputs.txt @@ -10,39 +10,34 @@ logs/CITATION.tex sub-01 sub-01/ses-1mo sub-01/ses-1mo/anat -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-aparcaseg_dseg.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-aseg_dseg.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-brain_mask.json -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-brain_mask.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-preproc_T1w.json sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-preproc_T1w.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-ribbon_mask.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_dseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-preproc_T2w.json +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_desc-preproc_T2w.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_from-MNIInfant+1_to-T1w_mode-image_xfm.h5 sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_from-T1w_to-MNIInfant+1_mode-image_xfm.h5 sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_from-T1w_to-fsnative_mode-image_xfm.txt sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_from-fsnative_to-T1w_mode-image_xfm.txt sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_curv.shape.gii -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_desc-reg_sphere.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_inflated.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_midthickness.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_pial.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_space-fsLR_desc-reg_sphere.surf.gii +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_space-fsaverage_desc-reg_sphere.surf.gii +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_sphere.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_sulc.shape.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_thickness.shape.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-L_white.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_curv.shape.gii -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_desc-reg_sphere.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_inflated.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_midthickness.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_pial.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_space-fsLR_desc-reg_sphere.surf.gii +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_space-fsaverage_desc-reg_sphere.surf.gii +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_sphere.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_sulc.shape.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_thickness.shape.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_white.surf.gii -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_label-CSF_probseg.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_label-GM_probseg.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_label-WM_probseg.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-brain_mask.json sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-brain_mask.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-preproc_T1w.json @@ -51,27 +46,38 @@ sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_dseg.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_label-CSF_probseg.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_label-GM_probseg.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_label-WM_probseg.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_desc-preproc_T2w.json -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_desc-preproc_T2w.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_desc-aparcaseg_dseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_desc-aseg_dseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_desc-ribbon_mask.json +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_desc-ribbon_mask.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_dseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_label-CSF_probseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_label-GM_probseg.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_label-WM_probseg.nii.gz sub-01/ses-1mo/fmap sub-01/ses-1mo/fmap/sub-01_ses-1mo_run-001_fmapid-auto00000_desc-coeff_fieldmap.nii.gz sub-01/ses-1mo/fmap/sub-01_ses-1mo_run-001_fmapid-auto00000_desc-epi_fieldmap.nii.gz sub-01/ses-1mo/fmap/sub-01_ses-1mo_run-001_fmapid-auto00000_desc-preproc_fieldmap.json sub-01/ses-1mo/fmap/sub-01_ses-1mo_run-001_fmapid-auto00000_desc-preproc_fieldmap.nii.gz sub-01/ses-1mo/func -sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_boldref.nii.gz sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_desc-brain_mask.json sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_desc-brain_mask.nii.gz sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_desc-confounds_timeseries.json sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_desc-confounds_timeseries.tsv +sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_desc-coreg_boldref.json +sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_desc-coreg_boldref.nii.gz +sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_desc-hmc_boldref.json +sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_desc-hmc_boldref.nii.gz sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_desc-preproc_bold.json sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_desc-preproc_bold.nii.gz -sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_from-scanner_to-T1w_mode-image_xfm.txt -sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_from-scanner_to-boldref_mode-image_xfm.txt -sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_from-T1w_to-scanner_mode-image_xfm.txt +sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_from-boldref_to-T1w_mode-image_desc-coreg_xfm.json +sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_from-boldref_to-T1w_mode-image_desc-coreg_xfm.txt +sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_from-boldref_to-auto00000_mode-image_xfm.json +sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_from-boldref_to-auto00000_mode-image_xfm.txt +sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_from-orig_to-boldref_mode-image_desc-hmc_xfm.json +sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_from-orig_to-boldref_mode-image_desc-hmc_xfm.txt +sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_space-MNIInfant_cohort-1_boldref.json sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_space-MNIInfant_cohort-1_boldref.nii.gz -sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_space-MNIInfant_cohort-1_desc-aparcaseg_dseg.nii.gz -sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_space-MNIInfant_cohort-1_desc-aseg_dseg.nii.gz sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_space-MNIInfant_cohort-1_desc-brain_mask.json sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_space-MNIInfant_cohort-1_desc-brain_mask.nii.gz sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_space-MNIInfant_cohort-1_desc-preproc_bold.json From 3d5b3e883a41663c7978c4204b470c6a9d2c5565 Mon Sep 17 00:00:00 2001 From: Mathias Goncalves Date: Wed, 21 Aug 2024 16:37:20 -0400 Subject: [PATCH 8/9] CI: Clean up output check script --- scripts/check_outputs.py | 42 ++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/scripts/check_outputs.py b/scripts/check_outputs.py index 0f73d470..5aa22e1b 100644 --- a/scripts/check_outputs.py +++ b/scripts/check_outputs.py @@ -12,6 +12,8 @@ DEFAULT_OUTPUT_SPACES = {"MNIInfant",} +CHECKMARK = u' \u2713' + def get_parser(): @@ -88,8 +90,10 @@ def test_functionals(func_dir): outtype = None if 'desc-brain_mask' in fl.name: outtype = 'masks' - elif 'desc-preproc_bold' in fl.name or '_boldref.' in fl.name: + elif 'desc-preproc_bold' in fl.name: outtype = 'preprocs' + elif '_boldref.' in fl.name: + outtype = 'boldrefs' elif 'desc-aseg_dseg' in fl.name or '_probseg.' in fl.name: outtype = 'segs' elif '_xfm.' in fl.name: @@ -103,6 +107,7 @@ def test_functionals(func_dir): outputs[outtype].append(fl) _check_bold_preprocs(outputs['preprocs']) + _check_boldrefs(outputs['boldrefs']) _check_masks(outputs['masks']) _check_segs(outputs['segs']) _check_xfms(outputs['xfms']) @@ -121,7 +126,7 @@ def _check_masks(masks): img = nb.load(mask) assert img.dataobj.dtype == np.uint8 assert np.all(np.unique(img.dataobj) == [0, 1]) - print(u' \u2713') + print(CHECKMARK) def _check_segs(segs): @@ -148,7 +153,7 @@ def _check_segs(segs): assert img.dataobj.dtype == np.float32 assert np.max(img.dataobj) == 1 assert np.min(img.dataobj) == 0 - print(u' \u2713') + print(CHECKMARK) def _check_xfms(xfms): @@ -158,9 +163,12 @@ def _check_xfms(xfms): assert nt.linear.load(xfm, fmt='itk') elif xfm.name.endswith('.h5'): assert nt.manip.load(xfm) + elif xfm.name.endswith('.json'): + meta = json.loads(xfm.read_text()) + assert 'Sources' in meta else: raise NotImplementedError - print(u' \u2713') + print(CHECKMARK) def _check_surfs(surfs): @@ -172,7 +180,7 @@ def _check_surfs(surfs): da0, da1 = img.darrays assert da0.intent == 1008 # NIFTI_INTENT_POINTSET assert da1.intent == 1009 # NIFTI_INTENT_TRIANGLE - print(u' \u2713') + print(CHECKMARK) def _check_t1w_preprocs(preprocs): @@ -184,7 +192,7 @@ def _check_t1w_preprocs(preprocs): else: img = nb.load(preproc) assert len(img.shape) == 3 - print(u' \u2713') + print(CHECKMARK) def _check_bold_preprocs(preprocs): @@ -195,11 +203,21 @@ def _check_bold_preprocs(preprocs): assert metadata['SkullStripped'] is False else: img = nb.load(preproc) - if '_boldref.' in preproc.name: - assert len(img.shape) == 3 - elif 'desc-preproc_bold' in preproc.name: - assert len(img.shape) == 4 - print(u' \u2713') + assert len(img.shape) == 4 + print(CHECKMARK) + + +def _check_boldrefs(boldrefs): + for boldref in boldrefs: + print(str(boldref), end='') + if '.json' in boldref.name: + metadata = json.loads(boldref.read_text()) + assert 'Sources' in metadata + else: + bimg = nb.load(boldref) + if len(bimg.shape) > 3: + assert len(bimg.shape) == 4 and bimg.shape[3] == 1 + print(CHECKMARK) def _check_ciftis(ciftis): @@ -217,7 +235,7 @@ def _check_ciftis(ciftis): bm_map = matrix.get_index_map(1) assert series_map.indices_map_to_data_type == 'CIFTI_INDEX_TYPE_SERIES' assert bm_map.indices_map_to_data_type == 'CIFTI_INDEX_TYPE_BRAIN_MODELS' - print(u' \u2713') + print(CHECKMARK) if __name__ == "__main__": From 6785fe068db7af990d03baa9db33230c980c6f56 Mon Sep 17 00:00:00 2001 From: Mathias Goncalves Date: Wed, 21 Aug 2024 18:44:16 -0400 Subject: [PATCH 9/9] ci: fix t2-only outputs --- .circleci/bcp_anat_t2only_outputs.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/bcp_anat_t2only_outputs.txt b/.circleci/bcp_anat_t2only_outputs.txt index 382c9354..d16fc222 100644 --- a/.circleci/bcp_anat_t2only_outputs.txt +++ b/.circleci/bcp_anat_t2only_outputs.txt @@ -38,8 +38,8 @@ sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_thickness.shape.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_hemi-R_white.surf.gii sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-brain_mask.json sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-brain_mask.nii.gz -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-preproc_T1w.json -sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-preproc_T1w.nii.gz +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-preproc_T2w.json +sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_desc-preproc_T2w.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_dseg.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_label-CSF_probseg.nii.gz sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_label-GM_probseg.nii.gz