Skip to content

Commit

Permalink
WIP 2
Browse files Browse the repository at this point in the history
  • Loading branch information
AliceJoubert committed Sep 27, 2024
1 parent 246f1b5 commit 3273a8b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 31 deletions.
10 changes: 8 additions & 2 deletions clinica/pipelines/anatomical/freesurfer/atlas/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,16 @@ def get_to_process_with_atlases(
- set(t1_freesurfer_longitudinal_output_atlas)
)
t1_freesurfer_output, _ = clinica_file_reader(
subjects, sessions, caps_directory, T1_FS_DESTRIEUX, False
subjects,
sessions,
caps_directory,
T1_FS_DESTRIEUX,
)
t1_freesurfer_files, _ = clinica_file_reader(
subjects, sessions, caps_directory, atlas_info, False
subjects,
sessions,
caps_directory,
atlas_info,
)
image_ids = extract_image_ids(t1_freesurfer_files)
image_ids_2 = extract_image_ids(t1_freesurfer_output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ def get_processed_images(
image_ids: List[str] = []
if caps_directory.is_dir():
t1_freesurfer_files, _ = clinica_file_reader(
list_participant_id,
list_long_id,
caps_directory,
T1_FS_T_DESTRIEUX,
False,
list_participant_id, list_long_id, caps_directory, T1_FS_T_DESTRIEUX
)
image_ids = [
re.search(r"(sub-[a-zA-Z0-9]+)_(long-[a-zA-Z0-9]+)", file).group()
Expand Down Expand Up @@ -95,7 +91,7 @@ def _build_input_node(self):
from clinica.utils.exceptions import ClinicaCAPSError, ClinicaException
from clinica.utils.filemanip import extract_subjects_sessions_from_filename
from clinica.utils.input_files import T1_FS_DESTRIEUX
from clinica.utils.inputs import clinica_file_reader
from clinica.utils.inputs import clinica_file_filter
from clinica.utils.longitudinal import (
get_long_id,
get_participants_long_id,
Expand Down Expand Up @@ -153,16 +149,10 @@ def _build_input_node(self):
self.subjects, self.sessions = extract_subjects_sessions_from_filename(
to_process_ids
)
try:
clinica_file_reader(
self.subjects, self.sessions, self.caps_directory, T1_FS_DESTRIEUX
)
except ClinicaException as e:
err_msg = (
"Clinica faced error(s) while trying to read files in your CAPS directory.\n"
+ str(e)
)
raise ClinicaCAPSError(err_msg)

_, self.subjects, self.sessions = clinica_file_filter(
self.subjects, self.sessions, self.caps_directory, T1_FS_DESTRIEUX
)

long_ids = get_participants_long_id(self.subjects, self.sessions)
save_part_sess_long_ids_to_tsv(
Expand Down
15 changes: 4 additions & 11 deletions clinica/pipelines/anatomical/freesurfer/t1/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_processed_images(
image_ids: List[str] = []
if caps_directory.is_dir():
t1_freesurfer_files, _ = clinica_file_reader(
subjects, sessions, caps_directory, T1_FS_DESTRIEUX, False
subjects, sessions, caps_directory, T1_FS_DESTRIEUX
)
image_ids = extract_image_ids(t1_freesurfer_files)
return image_ids
Expand Down Expand Up @@ -97,7 +97,7 @@ def _build_input_node(self):
save_participants_sessions,
)
from clinica.utils.input_files import T1W_NII
from clinica.utils.inputs import clinica_file_reader
from clinica.utils.inputs import clinica_file_filter
from clinica.utils.stream import cprint
from clinica.utils.ux import print_images_to_process

Expand Down Expand Up @@ -130,17 +130,10 @@ def _build_input_node(self):
to_process_ids
)

t1w_files, error_message = clinica_file_reader(
self.subjects,
self.sessions,
self.bids_directory,
T1W_NII,
raise_exception=False,
t1w_files, self.subjects, self.sessions = clinica_file_filter(
self.subjects, self.sessions, self.bids_directory, T1W_NII
)

if error_message:
cprint(error_message, lvl="warning")

if not t1w_files:
raise ClinicaException("Empty dataset or already processed")

Expand Down
2 changes: 1 addition & 1 deletion clinica/pipelines/dwi/preprocessing/fmap/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_processed_images(
image_ids: List[str] = []
if caps_directory.is_dir():
preproc_files, _ = clinica_file_reader(
subjects, sessions, caps_directory, DWI_PREPROC_NII, False
subjects, sessions, caps_directory, DWI_PREPROC_NII
)
image_ids = extract_image_ids(preproc_files)
return image_ids
Expand Down
2 changes: 1 addition & 1 deletion clinica/pipelines/dwi/preprocessing/t1/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_processed_images(
image_ids: List[str] = []
if caps_directory.is_dir():
preproc_files, _ = clinica_file_reader(
subjects, sessions, caps_directory, DWI_PREPROC_NII, False
subjects, sessions, caps_directory, DWI_PREPROC_NII
)
image_ids = extract_image_ids(preproc_files)
return image_ids
Expand Down
2 changes: 2 additions & 0 deletions clinica/utils/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ def _remove_sub_ses_from_list(
return list_subjects, list_sessions


# todo : generalize
def clinica_file_reader(
subjects: List[str],
sessions: List[str],
Expand Down Expand Up @@ -825,6 +826,7 @@ def _read_files_sequential(
return results, errors_encountered


# todo : generalize
def clinica_list_of_files_reader(
participant_ids: List[str],
session_ids: List[str],
Expand Down

0 comments on commit 3273a8b

Please sign in to comment.