diff --git a/clinica/pipelines/t1_volume_dartel2mni/t1_volume_dartel2mni_pipeline.py b/clinica/pipelines/t1_volume_dartel2mni/t1_volume_dartel2mni_pipeline.py index f01b1ac16..cff447e95 100644 --- a/clinica/pipelines/t1_volume_dartel2mni/t1_volume_dartel2mni_pipeline.py +++ b/clinica/pipelines/t1_volume_dartel2mni/t1_volume_dartel2mni_pipeline.py @@ -52,11 +52,7 @@ 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_deformation_to_template, - t1_volume_final_group_template, - t1_volume_native_tpm, - ) + from clinica.utils.input_files import QueryPatternName, query_pattern_factory from clinica.utils.inputs import ( clinica_file_reader, clinica_group_reader, @@ -77,7 +73,6 @@ def _build_input_node(self): f"Group {self.parameters['group_label']} does not exist. " "Did you run t1-volume or t1-volume-create-dartel pipeline?" ) - all_errors = [] read_input_node = npe.Node( name="LoadingCLIArguments", @@ -85,18 +80,18 @@ def _build_input_node(self): fields=self.get_input_fields(), mandatory_inputs=True ), ) - # Segmented Tissues # ================= + patterns = [ + query_pattern_factory(QueryPatternName.T1_VOLUME_NATIVE_TPM)(tissue_number) + for tissue_number in self.parameters["tissues"] + ] try: tissues_input = clinica_list_of_files_reader( self.subjects, self.sessions, self.caps_directory, - [ - t1_volume_native_tpm(tissue_number) - for tissue_number in self.parameters["tissues"] - ], + patterns, ) # Tissues_input has a length of len(self.parameters['mask_tissues']). Each of these elements has a size of # len(self.subjects). We want the opposite : a list of size len(self.subjects) whose elements have a size of @@ -110,25 +105,29 @@ def _build_input_node(self): # Flow Fields # =========== + pattern = query_pattern_factory( + QueryPatternName.T1_VOLUME_DEFORMATION_TO_TEMPLATE + )(self.parameters["group_label"]) read_input_node.inputs.flowfield_files, flowfield_errors = clinica_file_reader( self.subjects, self.sessions, self.caps_directory, - t1_volume_deformation_to_template(self.parameters["group_label"]), + pattern, ) if flowfield_errors: all_errors.append(format_clinica_file_reader_errors(flowfield_errors)) # Dartel Template # ================ + pattern = query_pattern_factory(QueryPatternName.T1_VOLUME_GROUP_TEMPLATE)( + self.parameters["group_label"] + ) try: read_input_node.inputs.template_file = clinica_group_reader( - self.caps_directory, - t1_volume_final_group_template(self.parameters["group_label"]), + self.caps_directory, pattern ) 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: