Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGensollen committed Nov 7, 2024
1 parent 8afcddf commit d6625d0
Showing 1 changed file with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -77,26 +73,25 @@ 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",
interface=nutil.IdentityInterface(
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
Expand All @@ -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:
Expand Down

0 comments on commit d6625d0

Please sign in to comment.