1- """ Copyright (C) 2022 C-PAC Developers
1+ # Copyright (C) 2012-2023 C-PAC Developers
22
3- This file is part of C-PAC.
3+ # This file is part of C-PAC.
44
5- C-PAC is free software: you can redistribute it and/or modify it under
6- the terms of the GNU Lesser General Public License as published by the
7- Free Software Foundation, either version 3 of the License, or (at your
8- option) any later version.
5+ # C-PAC is free software: you can redistribute it and/or modify it under
6+ # the terms of the GNU Lesser General Public License as published by the
7+ # Free Software Foundation, either version 3 of the License, or (at your
8+ # option) any later version.
99
10- C-PAC is distributed in the hope that it will be useful, but WITHOUT
11- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13- License for more details.
10+ # C-PAC is distributed in the hope that it will be useful, but WITHOUT
11+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13+ # License for more details.
1414
15- You should have received a copy of the GNU Lesser General Public
16- License along with C-PAC. If not, see <https://www.gnu.org/licenses/>."""
15+ # You should have received a copy of the GNU Lesser General Public
16+ # License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
1717import os
1818import sys
1919import time
4242from CPAC .pipeline .engine import NodeBlock , initiate_rpool
4343from CPAC .anat_preproc .anat_preproc import (
4444 freesurfer_reconall ,
45- freesurfer_postproc ,
4645 freesurfer_abcd_preproc ,
4746 anatomical_init ,
4847 acpc_align_head ,
8281 brain_mask_T2 ,
8382 brain_mask_acpc_T2 ,
8483 brain_extraction_temp_T2 ,
85- brain_extraction_T2
84+ brain_extraction_T2 ,
8685)
8786
8887from CPAC .registration .registration import (
@@ -867,40 +866,28 @@ def build_anat_preproc_stack(rpool, cfg, pipeline_blocks=None):
867866 ]
868867 pipeline_blocks += anat_init_blocks
869868
870- if rpool .check_rpool ('freesurfer-subject-dir' ):
871- pipeline_blocks += [freesurfer_postproc ]
872- else :
869+ if not rpool .check_rpool ('freesurfer-subject-dir' ):
873870 pipeline_blocks += [freesurfer_reconall ] # includes postproc
874871
875872 if not rpool .check_rpool ('desc-preproc_T1w' ):
876873
877874 # brain masking for ACPC alignment
878875 if cfg .anatomical_preproc ['acpc_alignment' ]['acpc_target' ] == 'brain' :
879- if rpool .check_rpool ('space-T1w_desc-brain_mask' ) or \
880- cfg .surface_analysis ['freesurfer' ]['run_reconall' ]:
881- acpc_blocks = [
882- brain_extraction_temp ,
883- acpc_align_brain_with_mask
884- # outputs space-T1w_desc-brain_mask for later - keep the mask (the user provided)
885- ]
886- acpc_blocks .append (
887- [brain_mask_acpc_freesurfer_fsl_tight ,
888- brain_mask_acpc_freesurfer_fsl_loose ]
889- )
890- else :
891876 acpc_blocks = [
892877 [brain_mask_acpc_afni ,
893878 brain_mask_acpc_fsl ,
894879 brain_mask_acpc_niworkflows_ants ,
895880 brain_mask_acpc_unet ,
896- brain_mask_acpc_freesurfer_abcd ],
897- # brain_mask_acpc_freesurfer
898- # we don't want these masks to be used later
881+ brain_mask_acpc_freesurfer_abcd ,
882+ brain_mask_acpc ,
883+ brain_mask_acpc_freesurfer ,
884+ brain_mask_acpc_freesurfer_fsl_tight ,
885+ brain_mask_acpc_freesurfer_fsl_loose ],
886+ acpc_align_brain_with_mask ,
899887 brain_extraction_temp ,
900888 acpc_align_brain
901889 ]
902- elif cfg .anatomical_preproc ['acpc_alignment' ][
903- 'acpc_target' ] == 'whole-head' :
890+ elif cfg .anatomical_preproc ['acpc_alignment' ]['acpc_target' ] == 'whole-head' :
904891 if (rpool .check_rpool ('space-T1w_desc-brain_mask' ) and \
905892 cfg .anatomical_preproc ['acpc_alignment' ]['align_brain_mask' ]) or \
906893 cfg .surface_analysis ['freesurfer' ]['run_reconall' ]:
@@ -912,6 +899,7 @@ def build_anat_preproc_stack(rpool, cfg, pipeline_blocks=None):
912899 acpc_blocks = [
913900 acpc_align_head # does not output nor generate a mask
914901 ]
902+
915903
916904 anat_preproc_blocks = [
917905 (non_local_means , ('T1w' , ['desc-preproc_T1w' ,
@@ -929,18 +917,18 @@ def build_anat_preproc_stack(rpool, cfg, pipeline_blocks=None):
929917 pipeline_blocks += [freesurfer_abcd_preproc ]
930918
931919 # Anatomical T1 brain masking
932- if not rpool . check_rpool ( 'space-T1w_desc-brain_mask' ) or \
933- cfg . surface_analysis [ 'freesurfer' ][ 'run_reconall' ]:
934- anat_brain_mask_blocks = [
935- [ brain_mask_afni ,
936- brain_mask_fsl ,
937- brain_mask_niworkflows_ants ,
938- brain_mask_unet ,
939- brain_mask_freesurfer_abcd ,
940- brain_mask_freesurfer_fsl_tight ,
941- brain_mask_freesurfer_fsl_loose ]
942- ]
943- pipeline_blocks += anat_brain_mask_blocks
920+
921+ anat_brain_mask_blocks = [
922+ [ brain_mask_afni ,
923+ brain_mask_fsl ,
924+ brain_mask_niworkflows_ants ,
925+ brain_mask_unet ,
926+ brain_mask_freesurfer_abcd ,
927+ brain_mask_freesurfer ,
928+ brain_mask_freesurfer_fsl_tight ,
929+ brain_mask_freesurfer_fsl_loose ]
930+ ]
931+ pipeline_blocks += anat_brain_mask_blocks
944932
945933 # T2w Anatomical Preprocessing
946934 if rpool .check_rpool ('T2w' ):
@@ -1032,7 +1020,6 @@ def build_T1w_registration_stack(rpool, cfg, pipeline_blocks=None):
10321020 warp_T1mask_to_template
10331021 ]
10341022
1035-
10361023 if not rpool .check_rpool ('desc-restore-brain_T1w' ):
10371024 reg_blocks .append (correct_restore_brain_intensity_abcd )
10381025
@@ -1363,6 +1350,7 @@ def build_workflow(subject_id, sub_dict, cfg, pipeline_name=None,
13631350 apply_func_warp ['EPI' ] = (_r_w_f_r ['coregistration' ]['run' ] and _r_w_f_r ['func_registration_to_template' ]['run_EPI' ])
13641351 else :
13651352 apply_func_warp ['EPI' ] = (_r_w_f_r ['func_registration_to_template' ]['run_EPI' ])
1353+
13661354 del _r_w_f_r
13671355
13681356 template_funcs = [
@@ -1394,6 +1382,7 @@ def build_workflow(subject_id, sub_dict, cfg, pipeline_name=None,
13941382
13951383 # PostFreeSurfer and fMRISurface
13961384 if not rpool .check_rpool ('space-fsLR_den-32k_bold.dtseries' ):
1385+
13971386 pipeline_blocks += [surface_postproc ]
13981387
13991388 # Extractions and Derivatives
0 commit comments