Skip to content

Commit 1abda36

Browse files
authored
Merge branch 'develop' into art/DRY-convert_pedir
2 parents c30589c + 2ff531a commit 1abda36

File tree

8 files changed

+579
-377
lines changed

8 files changed

+579
-377
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626
### Fixed
2727
- Fixed [bug](https://github.com/FCP-INDI/C-PAC/issues/1638) in which working connectivity matrix filepaths were generated incorrectly, preventing generating matrices depending on container bindings
2828
- Fixed broken links in README
29+
- Fixed [bug](https://github.com/FCP-INDI/C-PAC/issues/1575) in which anatomical-only configurations required functional data directories
2930

3031
## [1.8.2] - 2021-12-02
3132

CPAC/nuisance/nuisance.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,7 +1758,7 @@ def ICA_AROMA_FSLreg(wf, cfg, strat_pool, pipe_num, opt=None):
17581758
"inputs": [["desc-preproc_bold", "bold"],
17591759
"from-bold_to-T1w_mode-image_desc-linear_xfm",
17601760
"from-T1w_to-template_mode-image_xfm"],
1761-
"outputs": ["desc-preproc_bold",
1761+
"outputs": ["desc-preproc_bold",
17621762
"desc-cleaned_bold"]}
17631763
'''
17641764

@@ -1908,8 +1908,8 @@ def ICA_AROMA_FSLEPIreg(wf, cfg, strat_pool, pipe_num, opt=None):
19081908
}
19091909

19101910
return (wf, outputs)
1911-
1912-
1911+
1912+
19131913
def ICA_AROMA_ANTsEPIreg(wf, cfg, strat_pool, pipe_num, opt=None):
19141914
'''
19151915
Node Block:
@@ -1935,7 +1935,7 @@ def ICA_AROMA_ANTsEPIreg(wf, cfg, strat_pool, pipe_num, opt=None):
19351935

19361936
if reg_tool != 'ants':
19371937
return (wf, None)
1938-
1938+
19391939
num_cpus = cfg.pipeline_setup['system_config'][
19401940
'max_cores_per_participant']
19411941

@@ -1972,7 +1972,7 @@ def ICA_AROMA_ANTsEPIreg(wf, cfg, strat_pool, pipe_num, opt=None):
19721972

19731973
node, out = strat_pool.get_data('from-EPItemplate_to-bold_mode-image_xfm')
19741974
wf.connect(node, out, apply_xfm, 'inputspec.transform')
1975-
1975+
19761976
outputs = {
19771977
'desc-preproc_bold': (apply_xfm, 'outputspec.output_image'),
19781978
'desc-cleaned_bold': (apply_xfm, 'outputspec.output_image')
@@ -2006,7 +2006,7 @@ def erode_mask_T1w(wf, cfg, strat_pool, pipe_num, opt=None):
20062006

20072007
node, out = strat_pool.get_data('space-T1w_desc-brain_mask')
20082008
wf.connect(node, out, erode, 'inputspec.brain_mask')
2009-
2009+
20102010
node, out = strat_pool.get_data(['label-CSF_desc-preproc_mask',
20112011
'label-CSF_mask'])
20122012
wf.connect(node, out, erode, 'inputspec.mask')
@@ -2121,15 +2121,15 @@ def erode_mask_WM(wf, cfg, strat_pool, pipe_num, opt=None):
21212121
erode.inputs.inputspec.erode_prop = cfg.nuisance_corrections[
21222122
'2-nuisance_regression']['regressor_masks']['erode_wm'][
21232123
'wm_erosion_prop']
2124-
2124+
21252125
erode.inputs.inputspec.mask_erode_mm = cfg.nuisance_corrections[
21262126
'2-nuisance_regression']['regressor_masks']['erode_wm'][
21272127
'wm_mask_erosion_mm']
21282128

21292129
node, out = strat_pool.get_data(['label-WM_desc-preproc_mask',
21302130
'label-WM_mask'])
21312131
wf.connect(node, out, erode, 'inputspec.mask')
2132-
2132+
21332133
node, out = strat_pool.get_data('space-T1w_desc-brain_mask')
21342134
wf.connect(node, out, erode, 'inputspec.brain_mask')
21352135

@@ -2138,8 +2138,8 @@ def erode_mask_WM(wf, cfg, strat_pool, pipe_num, opt=None):
21382138
}
21392139

21402140
return (wf, outputs)
2141-
2142-
2141+
2142+
21432143
def nuisance_regressors_generation(wf, cfg, strat_pool, pipe_num, opt=None):
21442144
'''
21452145
Node Block:
@@ -2174,7 +2174,7 @@ def nuisance_regressors_generation(wf, cfg, strat_pool, pipe_num, opt=None):
21742174
'from-template_to-T1w_mode-image_desc-linear_xfm')
21752175
reg_tool = check_prov_for_regtool(xfm_prov)
21762176
use_ants = reg_tool == 'ants'
2177-
2177+
21782178
ventricle = strat_pool.check_rpool('lateral-ventricles-mask')
21792179

21802180
regressors = create_regressor_workflow(opt, use_ants,
@@ -2203,7 +2203,7 @@ def nuisance_regressors_generation(wf, cfg, strat_pool, pipe_num, opt=None):
22032203
"label-CSF_desc-preproc_mask",
22042204
"label-CSF_mask"]):
22052205
node, out = strat_pool.get_data(["label-CSF_desc-eroded_mask",
2206-
"label-CSF_desc-preproc_mask",
2206+
"label-CSF_desc-preproc_mask",
22072207
"label-CSF_mask"])
22082208
wf.connect(node, out, regressors, 'inputspec.csf_mask_file_path')
22092209

@@ -2216,10 +2216,10 @@ def nuisance_regressors_generation(wf, cfg, strat_pool, pipe_num, opt=None):
22162216
wf.connect(node, out, regressors, 'inputspec.wm_mask_file_path')
22172217

22182218
if strat_pool.check_rpool(["label-GM_desc-eroded_mask",
2219-
"label-GM_desc-preproc_mask",
2219+
"label-GM_desc-preproc_mask",
22202220
"label-GM_mask"]):
22212221
node, out = strat_pool.get_data(["label-GM_desc-eroded_mask",
2222-
"label-GM_desc-preproc_mask",
2222+
"label-GM_desc-preproc_mask",
22232223
"label-GM_mask"])
22242224
wf.connect(node, out, regressors, 'inputspec.gm_mask_file_path')
22252225

@@ -2359,7 +2359,7 @@ def nuisance_regression(wf, cfg, strat_pool, pipe_num, opt=None):
23592359

23602360
elif cfg.nuisance_corrections['2-nuisance_regression'][
23612361
'bandpass_filtering_order'] == 'Before':
2362-
2362+
23632363
node, out = strat_pool.get_data("desc-preproc_bold")
23642364
wf.connect(node, out, filt, 'inputspec.functional_file_path')
23652365

@@ -2409,7 +2409,7 @@ def erode_mask_bold(wf, cfg, strat_pool, pipe_num, opt=None):
24092409

24102410
node, out = strat_pool.get_data('space-bold_desc-brain_mask')
24112411
wf.connect(node, out, erode, 'inputspec.brain_mask')
2412-
2412+
24132413
node, out = strat_pool.get_data(['space-bold_label-CSF_desc-preproc_mask',
24142414
'space-bold_label-CSF_mask'])
24152415
wf.connect(node, out, erode, 'inputspec.mask')
@@ -2419,8 +2419,8 @@ def erode_mask_bold(wf, cfg, strat_pool, pipe_num, opt=None):
24192419
}
24202420

24212421
return (wf, outputs)
2422-
2423-
2422+
2423+
24242424
def erode_mask_boldCSF(wf, cfg, strat_pool, pipe_num, opt=None):
24252425
'''
24262426
{"name": "erode_mask_boldCSF",
@@ -2524,15 +2524,15 @@ def erode_mask_boldWM(wf, cfg, strat_pool, pipe_num, opt=None):
25242524
erode.inputs.inputspec.erode_prop = cfg.nuisance_corrections[
25252525
'2-nuisance_regression']['regressor_masks']['erode_wm'][
25262526
'wm_erosion_prop']
2527-
2527+
25282528
erode.inputs.inputspec.mask_erode_mm = cfg.nuisance_corrections[
25292529
'2-nuisance_regression']['regressor_masks']['erode_wm'][
25302530
'wm_mask_erosion_mm']
25312531

25322532
node, out = strat_pool.get_data(['space-bold_label-WM_desc-preproc_mask',
25332533
'space-bold_label-WM_mask'])
25342534
wf.connect(node, out, erode, 'inputspec.mask')
2535-
2535+
25362536
node, out = strat_pool.get_data('space-bold_desc-brain_mask')
25372537
wf.connect(node, out, erode, 'inputspec.brain_mask')
25382538

@@ -2559,7 +2559,7 @@ def nuisance_regressors_generation_EPItemplate(wf, cfg, strat_pool, pipe_num, op
25592559
"framewise-displacement-power",
25602560
"dvars",
25612561
["space-bold_desc-eroded_mask", "space-bold_desc-brain_mask"],
2562-
["space-bold_label-CSF_desc-eroded_mask", "space-bold_label-CSF_desc-preproc_mask",
2562+
["space-bold_label-CSF_desc-eroded_mask", "space-bold_label-CSF_desc-preproc_mask",
25632563
"space-bold_label-CSF_mask"],
25642564
["space-bold_label-WM_desc-eroded_mask", "space-bold_label-WM_desc-preproc_mask",
25652565
"space-bold_label-WM_mask"],
@@ -2627,29 +2627,29 @@ def nuisance_regressors_generation_EPItemplate(wf, cfg, strat_pool, pipe_num, op
26272627
wf.connect(node, out,
26282628
regressors, 'inputspec.lat_ventricles_mask_file_path')
26292629

2630-
if strat_pool.check_rpool('from-EPItemplate_to-bold_mode-image_desc-linear_xfm'):
2630+
if strat_pool.check_rpool('from-EPItemplate_to-bold_mode-image_desc-linear_xfm'):
26312631
node, out = strat_pool.get_data('from-EPItemplate_to-bold_mode-image_desc-linear_xfm')
26322632
wf.connect(node, out, regressors, 'inputspec.mni_to_anat_linear_xfm_file_path')
26332633
wf.connect(node, out, regressors, 'inputspec.anat_to_func_linear_xfm_file_path')
26342634

2635-
if strat_pool.check_rpool('from-bold_to-EPItemplate_mode-image_desc-linear_xfm'):
2635+
if strat_pool.check_rpool('from-bold_to-EPItemplate_mode-image_desc-linear_xfm'):
26362636
node, out = strat_pool.get_data('from-bold_to-EPItemplate_mode-image_desc-linear_xfm')
26372637
wf.connect(node, out, regressors, 'inputspec.anat_to_mni_linear_xfm_file_path')
26382638
wf.connect(node, out, regressors, 'inputspec.func_to_anat_linear_xfm_file_path')
26392639

2640-
if strat_pool.check_rpool('movement-parameters'):
2640+
if strat_pool.check_rpool('movement-parameters'):
26412641
node, out = strat_pool.get_data('movement-parameters')
26422642
wf.connect(node, out, regressors, 'inputspec.motion_parameters_file_path')
26432643

2644-
if strat_pool.check_rpool('framewise-displacement-jenkinson'):
2644+
if strat_pool.check_rpool('framewise-displacement-jenkinson'):
26452645
node, out = strat_pool.get_data('framewise-displacement-jenkinson')
26462646
wf.connect(node, out, regressors, 'inputspec.fd_j_file_path')
26472647

2648-
if strat_pool.check_rpool('framewise-displacement-power'):
2648+
if strat_pool.check_rpool('framewise-displacement-power'):
26492649
node, out = strat_pool.get_data('framewise-displacement-power')
26502650
wf.connect(node, out, regressors, 'inputspec.fd_p_file_path')
26512651

2652-
if strat_pool.check_rpool('dvars'):
2652+
if strat_pool.check_rpool('dvars'):
26532653
node, out = strat_pool.get_data('dvars')
26542654
wf.connect(node, out, regressors, 'inputspec.dvars_file_path')
26552655

CPAC/pipeline/cpac_pipeline.py

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@
9292
warp_deriv_mask_to_EPItemplate,
9393
warp_timeseries_to_T1template_abcd,
9494
single_step_resample_timeseries_to_T1template,
95+
warp_timeseries_to_T1template_dcan_nhp,
96+
warp_Tissuemask_to_T1template,
97+
warp_Tissuemask_to_EPItemplate,
9598
warp_timeseries_to_T1template_dcan_nhp
99+
96100
)
97101

98102
from CPAC.seg_preproc.seg_preproc import (
@@ -838,7 +842,7 @@ def build_anat_preproc_stack(rpool, cfg, pipeline_blocks=None):
838842
]
839843

840844
anat_preproc_blocks = [
841-
(non_local_means, ('T1w', ['desc-preproc_T1w',
845+
(non_local_means, ('T1w', ['desc-preproc_T1w',
842846
'desc-reorient_T1w',
843847
'T1w'])),
844848
n4_bias_correction
@@ -849,7 +853,7 @@ def build_anat_preproc_stack(rpool, cfg, pipeline_blocks=None):
849853
anat_blocks = anat_preproc_blocks + acpc_blocks
850854

851855
pipeline_blocks += anat_blocks
852-
856+
853857
if not rpool.check_rpool('freesurfer-subject-dir'):
854858
pipeline_blocks += [freesurfer_abcd_preproc]
855859

@@ -868,14 +872,14 @@ def build_anat_preproc_stack(rpool, cfg, pipeline_blocks=None):
868872
pipeline_blocks += anat_brain_mask_blocks
869873

870874
# T2w Anatomical Preprocessing
871-
if rpool.check_rpool('T2w'):
875+
if rpool.check_rpool('T2w'):
872876
if not rpool.check_rpool('desc-reorient_T2w'):
873877
anat_init_blocks_T2 = [
874-
anatomical_init_T2
878+
anatomical_init_T2
875879
]
876880
pipeline_blocks += anat_init_blocks_T2
877-
878-
# TODO: T2 freesurfer_preproc?
881+
882+
# TODO: T2 freesurfer_preproc?
879883
# pipeline_blocks += [freesurfer_preproc]
880884

881885
if not rpool.check_rpool('desc-preproc_T2w'):
@@ -908,7 +912,7 @@ def build_anat_preproc_stack(rpool, cfg, pipeline_blocks=None):
908912
]
909913

910914
anat_preproc_blocks_T2 = [
911-
registration_T2w_to_T1w,
915+
registration_T2w_to_T1w,
912916
non_local_means_T2,
913917
n4_bias_correction_T2,
914918
t1t2_bias_correction
@@ -919,7 +923,7 @@ def build_anat_preproc_stack(rpool, cfg, pipeline_blocks=None):
919923
anat_blocks_T2 = anat_preproc_blocks_T2 + acpc_blocks_T2
920924

921925
pipeline_blocks += anat_blocks_T2
922-
926+
923927
# Anatomical T1 brain extraction
924928
if not rpool.check_rpool('desc-brain_T1w'):
925929
anat_brain_blocks = [
@@ -952,9 +956,11 @@ def build_T1w_registration_stack(rpool, cfg, pipeline_blocks=None):
952956
if not rpool.check_rpool('from-T1w_to-template_mode-image_xfm'):
953957
reg_blocks = [
954958
[register_ANTs_anat_to_template, register_FSL_anat_to_template],
955-
overwrite_transform_anat_to_template
959+
overwrite_transform_anat_to_template,
960+
956961
]
957-
962+
963+
958964
if not rpool.check_rpool('desc-restore-brain_T1w'):
959965
reg_blocks.append(correct_restore_brain_intensity_abcd)
960966

@@ -984,9 +990,14 @@ def build_segmentation_stack(rpool, cfg, pipeline_blocks=None):
984990
if 'EPI_Template' in cfg.segmentation['tissue_segmentation'][
985991
'Template_Based']['template_for_segmentation']:
986992
seg_blocks.append(tissue_seg_EPI_template_based)
987-
993+
988994
pipeline_blocks += seg_blocks
989995

996+
if cfg.registration_workflows['anatomical_registration']['run'] and 'T1_Template' in cfg.segmentation[
997+
'tissue_segmentation']['Template_Based']['template_for_segmentation']:
998+
pipeline_blocks.append(warp_Tissuemask_to_T1template)
999+
1000+
9901001
return pipeline_blocks
9911002

9921003

@@ -1096,18 +1107,18 @@ def build_workflow(subject_id, sub_dict, cfg, pipeline_name=None,
10961107
func_slice_time,
10971108
func_reorient
10981109
]
1099-
1110+
11001111
if not rpool.check_rpool('desc-mean_bold'):
11011112
func_preproc_blocks.append(func_mean)
1102-
1113+
11031114
func_mask_blocks = []
11041115
if not rpool.check_rpool('space-bold_desc-brain_mask'):
11051116
func_mask_blocks = [
11061117
[bold_mask_afni, bold_mask_fsl, bold_mask_fsl_afni,
11071118
bold_mask_anatomical_refined, bold_mask_anatomical_based,
11081119
bold_mask_anatomical_resampled, bold_mask_ccs],
11091120
bold_masking]
1110-
1121+
11111122
func_prep_blocks = [
11121123
calc_motion_stats,
11131124
func_normalize
@@ -1119,7 +1130,7 @@ def build_workflow(subject_id, sub_dict, cfg, pipeline_name=None,
11191130
distcor_blocks.append(distcor_phasediff_fsl_fugue)
11201131

11211132
if rpool.check_rpool('epi_1'):
1122-
distcor_blocks.append(distcor_blip_afni_qwarp)
1133+
distcor_blocks.append(distcor_blip_afni_qwarp)
11231134
distcor_blocks.append(distcor_blip_fsl_topup)
11241135

11251136
if distcor_blocks:
@@ -1175,6 +1186,12 @@ def build_workflow(subject_id, sub_dict, cfg, pipeline_name=None,
11751186
]
11761187
pipeline_blocks += EPI_reg_blocks
11771188

1189+
if cfg.registration_workflows['functional_registration']['EPI_registration']['run'
1190+
] and 'EPI_Template' in cfg.segmentation['tissue_segmentation']['Template_Based']['template_for_segmentation']:
1191+
pipeline_blocks.append(warp_Tissuemask_to_EPItemplate)
1192+
1193+
1194+
11781195
# Generate the composite transform for BOLD-to-template for the T1
11791196
# anatomical template (the BOLD-to- EPI template is already created above)
11801197
if cfg.registration_workflows['functional_registration'][
@@ -1255,7 +1272,7 @@ def build_workflow(subject_id, sub_dict, cfg, pipeline_name=None,
12551272
if apply_func_warp:
12561273
pipeline_blocks += [warp_timeseries_to_EPItemplate,
12571274
warp_bold_mean_to_EPItemplate]
1258-
1275+
12591276
if not rpool.check_rpool('space-EPItemplate_desc-bold_mask'):
12601277
pipeline_blocks += [warp_bold_mask_to_EPItemplate,
12611278
warp_deriv_mask_to_EPItemplate]
@@ -1323,7 +1340,21 @@ def build_workflow(subject_id, sub_dict, cfg, pipeline_name=None,
13231340
pipeline_blocks += qc_stack
13241341

13251342
# Connect the entire pipeline!
1326-
wf = connect_pipeline(wf, cfg, rpool, pipeline_blocks)
1343+
try:
1344+
wf = connect_pipeline(wf, cfg, rpool, pipeline_blocks)
1345+
except LookupError as lookup_error:
1346+
errorstrings = lookup_error.args[0].split('\n')
1347+
missing_key = errorstrings[
1348+
errorstrings.index('[!] C-PAC says: The listed resource is not '
1349+
'in the resource pool:') + 1]
1350+
if missing_key.endswith('_bold') and 'func' not in sub_dict:
1351+
raise FileNotFoundError(
1352+
'The provided pipeline configuration requires functional '
1353+
'data but no functional data were found for ' +
1354+
'/'.join([sub_dict[key] for key in ['site', 'subject_id',
1355+
'unique_id'] if key in sub_dict]) + '. Please check '
1356+
'your data and pipeline configurations.') from lookup_error
1357+
raise lookup_error
13271358

13281359
# Write out the data
13291360
# TODO enforce value with schema validation

0 commit comments

Comments
 (0)