From 899c4a6e8b407bc777836b9d6d1fe198c4e1a44f Mon Sep 17 00:00:00 2001 From: NicolasGensollen Date: Thu, 7 Nov 2024 14:55:03 +0100 Subject: [PATCH] fix again --- .../t1_volume_register_dartel_pipeline.py | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/clinica/pipelines/t1_volume_register_dartel/t1_volume_register_dartel_pipeline.py b/clinica/pipelines/t1_volume_register_dartel/t1_volume_register_dartel_pipeline.py index 6e8c17687..ad173bea7 100644 --- a/clinica/pipelines/t1_volume_register_dartel/t1_volume_register_dartel_pipeline.py +++ b/clinica/pipelines/t1_volume_register_dartel/t1_volume_register_dartel_pipeline.py @@ -49,12 +49,8 @@ def _build_input_node(self): import nipype.pipeline.engine as npe from clinica.utils.exceptions import ClinicaCAPSError, ClinicaException - from clinica.utils.input_files import ( - t1_volume_dartel_input_tissue, - t1_volume_i_th_iteration_group_template, - ) + from clinica.utils.input_files import QueryPatternName, query_pattern_factory from clinica.utils.inputs import ( - clinica_file_reader, clinica_group_reader, clinica_list_of_files_reader, ) @@ -66,20 +62,21 @@ def _build_input_node(self): fields=self.get_input_fields(), mandatory_inputs=True ), ) - all_errors = [] - # Dartel Input Tissues # ==================== + patterns = [ + query_pattern_factory(QueryPatternName.T1_VOLUME_DARTEL_INPUT_TISSUE)( + tissue_number + ) + for tissue_number in self.parameters["tissues"] + ] try: d_input = clinica_list_of_files_reader( self.subjects, self.sessions, self.caps_directory, - [ - t1_volume_dartel_input_tissue(tissue_number) - for tissue_number in self.parameters["tissues"] - ], + patterns, ) read_input_node.inputs.dartel_input_images = d_input except ClinicaException as e: @@ -87,20 +84,20 @@ def _build_input_node(self): # Dartel Templates # ================ + patterns = [ + query_pattern_factory(QueryPatternName.T1_VOLUME_ITERATION_GROUP_TEMPLATE)( + self.parameters["group_label"], i + ) + for i in range(1, 7) + ] dartel_iter_templates = [] - for i in range(1, 7): + for pattern in patterns: try: - current_iter = clinica_group_reader( - self.caps_directory, - t1_volume_i_th_iteration_group_template( - self.parameters["group_label"], i - ), + dartel_iter_templates.append( + clinica_group_reader(self.caps_directory, pattern) ) - - dartel_iter_templates.append(current_iter) except ClinicaException as e: all_errors.append(e) - if any(all_errors): error_message = "Clinica faced error(s) while trying to read files in your CAPS/BIDS directories.\n" for msg in all_errors: