Skip to content

Commit

Permalink
feat: Output fsLR meshes on subject surfaces (#3411)
Browse files Browse the repository at this point in the history
Integration of nipreps/smriprep#460.
  • Loading branch information
effigies authored Dec 17, 2024
2 parents cf360a3 + ebf0f3d commit 46edd50
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .circleci/ds005_partial_fasttrack_outputs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ sub-01/anat/sub-01_desc-ribbon_mask.json
sub-01/anat/sub-01_desc-ribbon_mask.nii.gz
sub-01/anat/sub-01_hemi-L_desc-preproc_sphere.surf.gii
sub-01/anat/sub-01_hemi-L_desc-preproc_white.surf.gii
sub-01/anat/sub-01_hemi-L_space-fsLR_den-32k_desc-preproc_midthickness.surf.gii
sub-01/anat/sub-01_hemi-L_space-fsLR_den-32k_desc-preproc_pial.surf.gii
sub-01/anat/sub-01_hemi-L_space-fsLR_den-32k_desc-preproc_white.surf.gii
sub-01/anat/sub-01_hemi-L_space-fsLR_desc-msmsulc_sphere.surf.gii
sub-01/anat/sub-01_hemi-L_space-fsLR_desc-reg_sphere.surf.gii
sub-01/anat/sub-01_hemi-L_space-fsaverage_desc-reg_sphere.surf.gii
sub-01/anat/sub-01_hemi-R_desc-preproc_sphere.surf.gii
sub-01/anat/sub-01_hemi-R_desc-preproc_white.surf.gii
sub-01/anat/sub-01_hemi-R_space-fsLR_den-32k_desc-preproc_midthickness.surf.gii
sub-01/anat/sub-01_hemi-R_space-fsLR_den-32k_desc-preproc_pial.surf.gii
sub-01/anat/sub-01_hemi-R_space-fsLR_den-32k_desc-preproc_white.surf.gii
sub-01/anat/sub-01_hemi-R_space-fsLR_desc-msmsulc_sphere.surf.gii
sub-01/anat/sub-01_hemi-R_space-fsLR_desc-reg_sphere.surf.gii
sub-01/anat/sub-01_hemi-R_space-fsaverage_desc-reg_sphere.surf.gii
Expand Down
6 changes: 6 additions & 0 deletions .circleci/ds005_partial_outputs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ sub-01/anat/sub-01_from-T1w_to-MNI152NLin2009cAsym_mode-image_xfm.h5
sub-01/anat/sub-01_from-T1w_to-MNI152NLin6Asym_mode-image_xfm.h5
sub-01/anat/sub-01_hemi-L_midthickness.surf.gii
sub-01/anat/sub-01_hemi-L_pial.surf.gii
sub-01/anat/sub-01_hemi-L_space-fsLR_den-32k_midthickness.surf.gii
sub-01/anat/sub-01_hemi-L_space-fsLR_den-32k_pial.surf.gii
sub-01/anat/sub-01_hemi-L_space-fsLR_den-32k_white.surf.gii
sub-01/anat/sub-01_hemi-L_space-fsLR_desc-msmsulc_sphere.surf.gii
sub-01/anat/sub-01_hemi-L_space-fsLR_desc-reg_sphere.surf.gii
sub-01/anat/sub-01_hemi-L_space-fsaverage_desc-reg_sphere.surf.gii
Expand All @@ -34,6 +37,9 @@ sub-01/anat/sub-01_hemi-L_thickness.shape.gii
sub-01/anat/sub-01_hemi-L_white.surf.gii
sub-01/anat/sub-01_hemi-R_midthickness.surf.gii
sub-01/anat/sub-01_hemi-R_pial.surf.gii
sub-01/anat/sub-01_hemi-R_space-fsLR_den-32k_midthickness.surf.gii
sub-01/anat/sub-01_hemi-R_space-fsLR_den-32k_pial.surf.gii
sub-01/anat/sub-01_hemi-R_space-fsLR_den-32k_white.surf.gii
sub-01/anat/sub-01_hemi-R_space-fsLR_desc-msmsulc_sphere.surf.gii
sub-01/anat/sub-01_hemi-R_space-fsLR_desc-reg_sphere.surf.gii
sub-01/anat/sub-01_hemi-R_space-fsaverage_desc-reg_sphere.surf.gii
Expand Down
31 changes: 26 additions & 5 deletions fmriprep/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,14 @@ def init_single_subject_wf(subject_id: str):
from smriprep.workflows.outputs import (
init_ds_anat_volumes_wf,
init_ds_grayord_metrics_wf,
init_ds_surfaces_wf,
init_template_iterator_wf,
)
from smriprep.workflows.surfaces import (
init_gifti_morphometrics_wf,
init_hcp_morphometrics_wf,
init_morph_grayords_wf,
init_resample_midthickness_wf,
init_resample_surfaces_wf,
)

from fmriprep.workflows.bold.base import init_bold_wf
Expand Down Expand Up @@ -449,7 +450,8 @@ def init_single_subject_wf(subject_id: str):
grayord_density=config.workflow.cifti_output,
omp_nthreads=omp_nthreads,
)
resample_midthickness_wf = init_resample_midthickness_wf(
resample_surfaces_wf = init_resample_surfaces_wf(
surfaces=['white', 'pial', 'midthickness'],
grayord_density=config.workflow.cifti_output,
)
ds_grayord_metrics_wf = init_ds_grayord_metrics_wf(
Expand All @@ -458,6 +460,15 @@ def init_single_subject_wf(subject_id: str):
metrics=['curv', 'thickness', 'sulc'],
cifti_output=config.workflow.cifti_output,
)
ds_fsLR_surfaces_wf = init_ds_surfaces_wf(
output_dir=fmriprep_dir,
surfaces=['white', 'pial', 'midthickness'],
entities={
'space': 'fsLR',
'density': '32k' if config.workflow.cifti_output == '91k' else '59k',
},
name='ds_fsLR_surfaces_wf',
)

workflow.connect([
(anat_fit_wf, curv_wf, [
Expand All @@ -473,7 +484,9 @@ def init_single_subject_wf(subject_id: str):
(curv_wf, hcp_morphometrics_wf, [
('outputnode.curv', 'inputnode.curv'),
]),
(anat_fit_wf, resample_midthickness_wf, [
(anat_fit_wf, resample_surfaces_wf, [
('outputnode.white', 'inputnode.white'),
('outputnode.pial', 'inputnode.pial'),
('outputnode.midthickness', 'inputnode.midthickness'),
(
f"outputnode.sphere_reg_{'msm' if msm_sulc else 'fsLR'}",
Expand All @@ -493,12 +506,15 @@ def init_single_subject_wf(subject_id: str):
('outputnode.sulc', 'inputnode.sulc'),
('outputnode.roi', 'inputnode.roi'),
]),
(resample_midthickness_wf, morph_grayords_wf, [
(resample_surfaces_wf, morph_grayords_wf, [
('outputnode.midthickness_fsLR', 'inputnode.midthickness_fsLR'),
]),
(anat_fit_wf, ds_grayord_metrics_wf, [
('outputnode.t1w_valid_list', 'inputnode.source_files'),
]),
(anat_fit_wf, ds_fsLR_surfaces_wf, [
('outputnode.t1w_valid_list', 'inputnode.source_files'),
]),
(morph_grayords_wf, ds_grayord_metrics_wf, [
('outputnode.curv_fsLR', 'inputnode.curv'),
('outputnode.curv_metadata', 'inputnode.curv_metadata'),
Expand All @@ -507,6 +523,11 @@ def init_single_subject_wf(subject_id: str):
('outputnode.sulc_fsLR', 'inputnode.sulc'),
('outputnode.sulc_metadata', 'inputnode.sulc_metadata'),
]),
(resample_surfaces_wf, ds_fsLR_surfaces_wf, [
('outputnode.white_fsLR', 'inputnode.white'),
('outputnode.pial_fsLR', 'inputnode.pial'),
('outputnode.midthickness_fsLR', 'inputnode.midthickness'),
]),
]) # fmt:skip

if config.workflow.anat_only:
Expand Down Expand Up @@ -740,7 +761,7 @@ def init_single_subject_wf(subject_id: str):
(hcp_morphometrics_wf, bold_wf, [
('outputnode.roi', 'inputnode.cortex_mask'),
]),
(resample_midthickness_wf, bold_wf, [
(resample_surfaces_wf, bold_wf, [
('outputnode.midthickness_fsLR', 'inputnode.midthickness_fsLR'),
]),
]) # fmt:skip
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies = [
"pybids >= 0.16",
"requests >= 2.27",
"sdcflows >= 2.10.0",
"smriprep >= 0.16.0",
"smriprep @ git+https://github.com/nipreps/smriprep.git",
"tedana >= 23.0.2",
"templateflow >= 24.2.2",
"transforms3d >= 0.4",
Expand Down
4 changes: 3 additions & 1 deletion scripts/fetch_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def fetch_MNI2009():
Expected templates:
tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_T1w.nii.gz
tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_T2w.nii.gz
tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_T1w.nii.gz
tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_T2w.nii.gz
tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_desc-brain_mask.nii.gz
tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-brain_mask.nii.gz
tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_desc-carpet_dseg.nii.gz
Expand All @@ -25,7 +27,7 @@ def fetch_MNI2009():
"""
template = 'MNI152NLin2009cAsym'

tf.get(template, resolution=(1, 2), desc=None, suffix='T1w')
tf.get(template, resolution=(1, 2), desc=None, suffix=['T1w', 'T2w'])
tf.get(template, resolution=(1, 2), desc='brain', suffix='mask')
tf.get(template, resolution=1, atlas=None, desc='carpet', suffix='dseg')
tf.get(template, resolution=2, desc='fMRIPrep', suffix='boldref')
Expand Down

0 comments on commit 46edd50

Please sign in to comment.