diff --git a/docs/outputs.rst b/docs/outputs.rst index 35e0c0266..9baab309b 100644 --- a/docs/outputs.rst +++ b/docs/outputs.rst @@ -107,7 +107,7 @@ Atlases are written out to the ``atlases`` subfolder, following BEP038. Anatomical Outputs ****************** -Anatomical outputs consist of anatomical preprocessed T1w/T2w and segmentation images in MNI space. +Anatomical outputs consist of anatomical preprocessed T1w and/or T2w images in MNI space. .. code-block:: @@ -116,7 +116,6 @@ Anatomical outputs consist of anatomical preprocessed T1w/T2w and segmentation i anat/ _space-MNI152NLin6Asym_desc-preproc_T1w.nii.gz _space-MNI152NLin6Asym_desc-preproc_T2w.nii.gz - _space-MNI152NLin6Asym_dseg.nii.gz Surface mesh files diff --git a/docs/usage.rst b/docs/usage.rst index 3900cddd5..52cfd1bc0 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -169,9 +169,6 @@ We recommend NOT setting the datatype, suffix, or file extension in the filter f ``"t2w"`` selects a native T1w-space, preprocessed T2w file. If a T1w file is not available, this file will be in T2w space. -``"anat_dseg"`` selects a segmentation file in the same space as the BOLD data. -This file is not used for anything. - ``"anat_brainmask"`` selects an anatomically-derived brain mask in the same space as the BOLD data. This file is used (1) to estimate head radius for FD calculation and (2) to calculate coregistration quality metrics. diff --git a/docs/workflows.rst b/docs/workflows.rst index 7a0727042..6266865af 100644 --- a/docs/workflows.rst +++ b/docs/workflows.rst @@ -872,8 +872,7 @@ Second, XCP-D outputs processed BOLD data, including denoised unsmoothed and smo MNI152NLin2009cAsym and fsLR-32k spaces, parcellated time series, functional connectivity matrices, and ALFF and ReHo (smoothed and unsmoothed). -Third, the anatomical data (processed T1w processed and segmentation files) are copied from -fMRIPrep. +Third, the anatomical data (processed T1w and/or T2w files) are copied from fMRIPrep. If both images are not in MNI152NLin6Asym space, they are resampled to MNI space. The fMRIPrep surfaces (gifti files) in each subject are also resampled to standard space (fsLR-32K). diff --git a/xcp_d/data/io_spec.yaml b/xcp_d/data/io_spec.yaml index 63feb0917..94f46e24e 100644 --- a/xcp_d/data/io_spec.yaml +++ b/xcp_d/data/io_spec.yaml @@ -6,16 +6,6 @@ queries: desc: brain extension: .nii.gz suffix: mask - # native anatomical-space dseg file - anat_dseg: - datatype: anat - desc: null - extension: .nii.gz - space: - - T1w - - T2w - - null - suffix: dseg # transform from native anatomical (T1w or T2w) space to same standard space as BOLD # "to" entity will be set later anat_to_template_xfm: diff --git a/xcp_d/ingression/ukbiobank.py b/xcp_d/ingression/ukbiobank.py index ccf51fe22..7a6d58b41 100644 --- a/xcp_d/ingression/ukbiobank.py +++ b/xcp_d/ingression/ukbiobank.py @@ -238,13 +238,6 @@ def convert_ukb_to_bids_single_subject(in_dir, out_dir, sub_id, ses_id): f"{subses_ents}_space-{VOLSPACE}_desc-brain_mask.nii.gz", ) ) - # Use the brain mask as the "aparcaseg" dseg too. - copy_dictionary[warp_brainmask_to_std_results.outputs.out_file].append( - os.path.join( - anat_dir_bids, - f"{subses_ents}_space-{VOLSPACE}_desc-aparcaseg_dseg.nii.gz", - ) - ) # Warp the reference file to MNI space. warp_boldref_to_std = ApplyWarp( diff --git a/xcp_d/ingression/utils.py b/xcp_d/ingression/utils.py index 619806fcc..89d33eb39 100644 --- a/xcp_d/ingression/utils.py +++ b/xcp_d/ingression/utils.py @@ -21,7 +21,6 @@ def collect_anatomical_files(anat_dir_orig, anat_dir_bids, base_anatomical_ents) "T1w.nii.gz": "desc-preproc_T1w.nii.gz", "brainmask_fs.nii.gz": "desc-brain_mask.nii.gz", "ribbon.nii.gz": "desc-ribbon_T1w.nii.gz", - "aparc+aseg.nii.gz": "desc-aparcaseg_dseg.nii.gz", } copy_dictionary = {} diff --git a/xcp_d/interfaces/utils.py b/xcp_d/interfaces/utils.py index 796fdbe4c..2a1ce2b32 100644 --- a/xcp_d/interfaces/utils.py +++ b/xcp_d/interfaces/utils.py @@ -64,13 +64,6 @@ class _ConvertTo32InputSpec(BaseInterfaceInputSpec): mandatory=False, usedefault=True, ) - anat_dseg = traits.Either( - None, - File(exists=True), - desc="T1-space segmentation file", - mandatory=False, - usedefault=True, - ) class _ConvertTo32OutputSpec(TraitedSpec): @@ -104,12 +97,6 @@ class _ConvertTo32OutputSpec(TraitedSpec): desc="T2-weighted anatomical file", mandatory=False, ) - anat_dseg = traits.Either( - None, - File(exists=True), - desc="T1-space segmentation file", - mandatory=False, - ) class ConvertTo32(SimpleInterface): @@ -124,7 +111,6 @@ def _run_interface(self, runtime): self._results["bold_mask"] = downcast_to_32(self.inputs.bold_mask) self._results["t1w"] = downcast_to_32(self.inputs.t1w) self._results["t2w"] = downcast_to_32(self.inputs.t2w) - self._results["anat_dseg"] = downcast_to_32(self.inputs.anat_dseg) return runtime diff --git a/xcp_d/tests/conftest.py b/xcp_d/tests/conftest.py index d6d3f7922..f057900e3 100644 --- a/xcp_d/tests/conftest.py +++ b/xcp_d/tests/conftest.py @@ -122,7 +122,6 @@ def ds001419_data(datasets): anat_dir, "sub-01_space-MNI152NLin2009cAsym_res-2_desc-preproc_T1w.nii.gz", ) - files["anat_dseg"] = os.path.join(anat_dir, "sub-01_desc-aseg_dseg.nii.gz") return files @@ -182,10 +181,6 @@ def pnc_data(datasets): "res-2_desc-preproc_T1w.nii.gz" ), ) - files["anat_dseg"] = os.path.join( - anat_dir, - "sub-1648798153_ses-PNC1_acq-refaced_desc-aseg_dseg.nii.gz", - ) return files diff --git a/xcp_d/tests/data/test_ds001419_cifti_outputs.txt b/xcp_d/tests/data/test_ds001419_cifti_outputs.txt index ff850e2e4..5d4050a8d 100644 --- a/xcp_d/tests/data/test_ds001419_cifti_outputs.txt +++ b/xcp_d/tests/data/test_ds001419_cifti_outputs.txt @@ -27,7 +27,6 @@ sub-01 sub-01.html sub-01/anat sub-01/anat/sub-01_space-MNI152NLin2009cAsym_desc-preproc_T1w.nii.gz -sub-01/anat/sub-01_space-MNI152NLin2009cAsym_dseg.nii.gz sub-01/func sub-01/func/sub-01_task-imagery_desc-abcc_qc.hdf5 sub-01/func/sub-01_task-imagery_desc-filtered_motion.json diff --git a/xcp_d/tests/data/test_ds001419_nifti_outputs.txt b/xcp_d/tests/data/test_ds001419_nifti_outputs.txt index fb89411d9..733e115b3 100644 --- a/xcp_d/tests/data/test_ds001419_nifti_outputs.txt +++ b/xcp_d/tests/data/test_ds001419_nifti_outputs.txt @@ -9,7 +9,6 @@ sub-01 sub-01.html sub-01/anat sub-01/anat/sub-01_space-MNI152NLin2009cAsym_desc-preproc_T1w.nii.gz -sub-01/anat/sub-01_space-MNI152NLin2009cAsym_dseg.nii.gz sub-01/func sub-01/func/sub-01_task-imagery_desc-filtered_motion.json sub-01/func/sub-01_task-imagery_desc-filtered_motion.tsv diff --git a/xcp_d/tests/data/test_fmriprep_without_freesurfer_outputs.txt b/xcp_d/tests/data/test_fmriprep_without_freesurfer_outputs.txt index 6a5869b2b..f1c261373 100644 --- a/xcp_d/tests/data/test_fmriprep_without_freesurfer_outputs.txt +++ b/xcp_d/tests/data/test_fmriprep_without_freesurfer_outputs.txt @@ -67,7 +67,6 @@ sub-01 sub-01.html sub-01/anat sub-01/anat/sub-01_space-MNI152NLin2009cAsym_desc-preproc_T1w.nii.gz -sub-01/anat/sub-01_space-MNI152NLin2009cAsym_dseg.nii.gz sub-01/func sub-01/func/sub-01_task-mixedgamblestask_run-1_desc-abcc_qc.hdf5 sub-01/func/sub-01_task-mixedgamblestask_run-1_desc-preproc_design.json diff --git a/xcp_d/tests/data/test_nibabies_outputs.txt b/xcp_d/tests/data/test_nibabies_outputs.txt index 59b7a1143..72199ec3a 100644 --- a/xcp_d/tests/data/test_nibabies_outputs.txt +++ b/xcp_d/tests/data/test_nibabies_outputs.txt @@ -67,7 +67,6 @@ sub-01.html sub-01/ses-1mo sub-01/ses-1mo/anat 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/func sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_desc-abcc_qc.hdf5 sub-01/ses-1mo/func/sub-01_ses-1mo_task-rest_acq-PA_run-001_desc-preproc_design.json diff --git a/xcp_d/tests/data/test_pnc_cifti_outputs.txt b/xcp_d/tests/data/test_pnc_cifti_outputs.txt index fda07fa46..47e07289e 100644 --- a/xcp_d/tests/data/test_pnc_cifti_outputs.txt +++ b/xcp_d/tests/data/test_pnc_cifti_outputs.txt @@ -23,7 +23,6 @@ sub-1648798153.html sub-1648798153/ses-PNC1 sub-1648798153/ses-PNC1/anat sub-1648798153/ses-PNC1/anat/sub-1648798153_ses-PNC1_acq-refaced_space-MNI152NLin6Asym_desc-preproc_T1w.nii.gz -sub-1648798153/ses-PNC1/anat/sub-1648798153_ses-PNC1_acq-refaced_space-MNI152NLin6Asym_dseg.nii.gz sub-1648798153/ses-PNC1/anat/sub-1648798153_ses-PNC1_acq-refaced_space-fsLR_den-32k_hemi-L_desc-hcp_inflated.surf.gii sub-1648798153/ses-PNC1/anat/sub-1648798153_ses-PNC1_acq-refaced_space-fsLR_den-32k_hemi-L_desc-hcp_midthickness.surf.gii sub-1648798153/ses-PNC1/anat/sub-1648798153_ses-PNC1_acq-refaced_space-fsLR_den-32k_hemi-L_desc-hcp_vinflated.surf.gii diff --git a/xcp_d/tests/data/test_pnc_cifti_t2wonly_outputs.txt b/xcp_d/tests/data/test_pnc_cifti_t2wonly_outputs.txt index d343e5781..a93adf86e 100644 --- a/xcp_d/tests/data/test_pnc_cifti_t2wonly_outputs.txt +++ b/xcp_d/tests/data/test_pnc_cifti_t2wonly_outputs.txt @@ -19,7 +19,6 @@ sub-1648798153.html sub-1648798153/ses-PNC1 sub-1648798153/ses-PNC1/anat sub-1648798153/ses-PNC1/anat/sub-1648798153_ses-PNC1_acq-refaced_space-MNI152NLin6Asym_desc-preproc_T2w.nii.gz -sub-1648798153/ses-PNC1/anat/sub-1648798153_ses-PNC1_acq-refaced_space-MNI152NLin6Asym_dseg.nii.gz sub-1648798153/ses-PNC1/anat/sub-1648798153_ses-PNC1_acq-refaced_space-fsLR_den-32k_hemi-L_desc-hcp_inflated.surf.gii sub-1648798153/ses-PNC1/anat/sub-1648798153_ses-PNC1_acq-refaced_space-fsLR_den-32k_hemi-L_desc-hcp_midthickness.surf.gii sub-1648798153/ses-PNC1/anat/sub-1648798153_ses-PNC1_acq-refaced_space-fsLR_den-32k_hemi-L_desc-hcp_vinflated.surf.gii diff --git a/xcp_d/tests/data/test_ukbiobank_outputs.txt b/xcp_d/tests/data/test_ukbiobank_outputs.txt index dd1f54d13..a01e873fa 100644 --- a/xcp_d/tests/data/test_ukbiobank_outputs.txt +++ b/xcp_d/tests/data/test_ukbiobank_outputs.txt @@ -67,7 +67,6 @@ sub-0000001 sub-0000001.html sub-0000001/ses-01 sub-0000001/ses-01/anat -sub-0000001/ses-01/anat/sub-0000001_ses-01_space-MNI152NLin6Asym_desc-aparcaseg_dseg.nii.gz sub-0000001/ses-01/anat/sub-0000001_ses-01_space-MNI152NLin6Asym_desc-preproc_T1w.nii.gz sub-0000001/ses-01/func sub-0000001/ses-01/func/sub-0000001_ses-01_task-rest_desc-filtered_motion.json diff --git a/xcp_d/tests/test_workflows_anatomical.py b/xcp_d/tests/test_workflows_anatomical.py index 23eacc431..4ebd850c6 100644 --- a/xcp_d/tests/test_workflows_anatomical.py +++ b/xcp_d/tests/test_workflows_anatomical.py @@ -100,7 +100,6 @@ def test_postprocess_anat_wf(ds001419_data, tmp_path_factory): anat_to_template_xfm = ds001419_data["anat_to_template_xfm"] t1w = ds001419_data["t1w"] - anat_dseg = ds001419_data["anat_dseg"] t2w = os.path.join(tmpdir, "sub-01_desc-preproc_T2w.nii.gz") # pretend t1w is t2w shutil.copyfile(t1w, t2w) @@ -119,7 +118,6 @@ def test_postprocess_anat_wf(ds001419_data, tmp_path_factory): wf.inputs.inputnode.anat_to_template_xfm = anat_to_template_xfm wf.inputs.inputnode.t1w = t1w - wf.inputs.inputnode.anat_dseg = anat_dseg wf.inputs.inputnode.t2w = t2w wf.base_dir = tmpdir wf_res = wf.run() @@ -132,6 +130,3 @@ def test_postprocess_anat_wf(ds001419_data, tmp_path_factory): out_t2w = wf_nodes["postprocess_anat_wf.ds_t2w_std"].get_output("out_file") assert os.path.isfile(out_t2w), os.listdir(out_anat_dir) - - out_anat_dseg = wf_nodes["postprocess_anat_wf.ds_anat_dseg_std"].get_output("out_file") - assert os.path.isfile(out_anat_dseg), os.listdir(out_anat_dir) diff --git a/xcp_d/utils/bids.py b/xcp_d/utils/bids.py index 0d2537d5d..8b1151eab 100644 --- a/xcp_d/utils/bids.py +++ b/xcp_d/utils/bids.py @@ -173,8 +173,6 @@ def collect_data( # HCP/DCAN data have anats only in standard space queries["t1w"]["space"] = "MNI152NLin6Asym" queries["t2w"]["space"] = "MNI152NLin6Asym" - queries["anat_dseg"]["desc"] = "aparcaseg" - queries["anat_dseg"]["space"] = "MNI152NLin6Asym" queries["anat_brainmask"]["space"] = "MNI152NLin6Asym" queries["bold"]["extension"] = ".dtseries.nii" if (file_format == "cifti") else ".nii.gz" @@ -299,14 +297,10 @@ def collect_data( queries["t1w"]["space"] = ["T1w", None] queries["template_to_anat_xfm"]["to"] = "T1w" queries["anat_to_template_xfm"]["from"] = "T1w" - # Nibabies may include space-T1w for some derivatives - queries["anat_dseg"]["space"] = ["T1w", None] else: LOGGER.info("Performing T2w-only processing.") queries["template_to_anat_xfm"]["to"] = "T2w" queries["anat_to_template_xfm"]["from"] = "T2w" - # Nibabies may include space-T2w for some derivatives - queries["anat_dseg"]["space"] = ["T2w", None] else: LOGGER.warning("T2w-space T1w found. Processing anatomical images in T2w space.") else: @@ -317,8 +311,6 @@ def collect_data( LOGGER.warning("T2w found, but no T1w. Enabling T2w-only processing.") queries["template_to_anat_xfm"]["to"] = "T2w" queries["anat_to_template_xfm"]["from"] = "T2w" - # Nibabies may include space-T2w for some derivatives - queries["anat_dseg"]["space"] = ["T2w", None] # Search for the files. subj_data = { diff --git a/xcp_d/workflows/anatomical/volume.py b/xcp_d/workflows/anatomical/volume.py index e8d76572c..72aa0d31c 100644 --- a/xcp_d/workflows/anatomical/volume.py +++ b/xcp_d/workflows/anatomical/volume.py @@ -63,8 +63,6 @@ def init_postprocess_anat_wf( t2w : :obj:`str` or None Path to the preprocessed T2w file. This file may be in standard space or native T1w space. - anat_dseg : :obj:`str` - Path to the T1w segmentation file. %(anat_to_template_xfm)s We need to use MNI152NLin6Asym for the template. template : :obj:`str` @@ -87,7 +85,6 @@ def init_postprocess_anat_wf( fields=[ "t1w", "t2w", - "anat_dseg", "anat_to_template_xfm", "template", ], @@ -110,19 +107,6 @@ def init_postprocess_anat_wf( ) inputnode.inputs.template = template_file - ds_anat_dseg_std = pe.Node( - DerivativesDataSink( - base_directory=output_dir, - space=target_space, - cohort=cohort, - extension=".nii.gz", - ), - name="ds_anat_dseg_std", - run_without_submitting=False, - ) - - workflow.connect([(inputnode, ds_anat_dseg_std, [("anat_dseg", "source_file")])]) - if t1w_available: ds_t1w_std = pe.Node( DerivativesDataSink( @@ -156,12 +140,10 @@ def init_postprocess_anat_wf( ]) # fmt:skip if input_type in ("dcan", "hcp", "ukb"): - # Assume that the T1w, T1w segmentation, and T2w files are in standard space, + # Assume that the T1w and T2w files are in standard space, # but don't have the "space" entity, for the "dcan" and "hcp" derivatives. # This is a bug, and the converted filenames are inaccurate, so we have this # workaround in place. - workflow.connect([(inputnode, ds_anat_dseg_std, [("anat_dseg", "in_file")])]) - if t1w_available: workflow.connect([(inputnode, ds_t1w_std, [("t1w", "in_file")])]) @@ -169,32 +151,11 @@ def init_postprocess_anat_wf( workflow.connect([(inputnode, ds_t2w_std, [("t2w", "in_file")])]) else: - out = ( - ["T1w"] if t1w_available else [] + ["T2w"] if t2w_available else [] + ["segmentation"] - ) + out = ["T1w"] if t1w_available else [] + ["T2w"] if t2w_available else [] workflow.__desc__ = f"""\ Native-space {list_to_str(out)} images were transformed to {target_space} space at 1 mm3 resolution. """ - warp_anat_dseg_to_template = pe.Node( - ApplyTransforms( - num_threads=2, - interpolation="GenericLabel", - input_image_type=3, - dimension=3, - ), - name="warp_anat_dseg_to_template", - mem_gb=2, - n_procs=omp_nthreads, - ) - workflow.connect([ - (inputnode, warp_anat_dseg_to_template, [ - ("anat_dseg", "input_image"), - ("anat_to_template_xfm", "transforms"), - ("template", "reference_image"), - ]), - (warp_anat_dseg_to_template, ds_anat_dseg_std, [("output_image", "in_file")]), - ]) # fmt:skip if t1w_available: # Warp the native T1w-space T1w, T1w segmentation, and T2w files to standard space. diff --git a/xcp_d/workflows/base.py b/xcp_d/workflows/base.py index 5156a52da..602876f8f 100644 --- a/xcp_d/workflows/base.py +++ b/xcp_d/workflows/base.py @@ -157,7 +157,6 @@ def init_single_subject_wf(subject_id: str): "t1w", "t2w", # optional "anat_brainmask", # used to estimate head radius and for QC metrics - "anat_dseg", "template_to_anat_xfm", # not used by cifti workflow "anat_to_template_xfm", # mesh files @@ -181,7 +180,6 @@ def init_single_subject_wf(subject_id: str): inputnode.inputs.t1w = subj_data["t1w"] inputnode.inputs.t2w = subj_data["t2w"] inputnode.inputs.anat_brainmask = subj_data["anat_brainmask"] - inputnode.inputs.anat_dseg = subj_data["anat_dseg"] inputnode.inputs.template_to_anat_xfm = subj_data["template_to_anat_xfm"] inputnode.inputs.anat_to_template_xfm = subj_data["anat_to_template_xfm"] @@ -291,7 +289,6 @@ def init_single_subject_wf(subject_id: str): (inputnode, postprocess_anat_wf, [ ("t1w", "inputnode.t1w"), ("t2w", "inputnode.t2w"), - ("anat_dseg", "inputnode.anat_dseg"), ("anat_to_template_xfm", "inputnode.anat_to_template_xfm"), ]), ]) # fmt:skip @@ -467,7 +464,7 @@ def init_single_subject_wf(subject_id: str): t2w_available=t2w_available, n_runs=n_runs, exact_scans=exact_scans, - name=f"{config.workflow.file_format}_postprocess_{run_counter}_wf", + name=f"postprocess_{run_counter}_wf", ) run_counter += 1