Repository: aramis-lab/clinica

Issue:
[BUG] OASIS-to-BIDS informative logs are not relevant
Currently, the converter only indicates : 
- Clinical data conversion
- The difference between the result and clinical data (see issue #249) -> too much noise !
- Missing metadata for all subjects in **clinical data** -> too much noise too !

Discussion:
@github-actions: This issue is considered stale because it has not received further activity for the last 14 days. You may remove the `inactive` label or add a comment, otherwise it will be closed after the next 14 days.@NicolasGensollen: @Adam-Ismaili-92 The noisy message is built here:

https://github.com/aramis-lab/clinica/blob/f7a82994761bcd85f70cfd346cd5bfbce959d2b4/clinica/converters/_utils.py#L196-L203

And I believe this issue is that `participant_df` contains all participant ID from the clinical data instead of what has been asked by the user.

Solution patch:
diff --git a/clinica/converters/_utils.py b/clinica/converters/_utils.py
index 66d41961..dd0ada78 100644
--- a/clinica/converters/_utils.py
+++ b/clinica/converters/_utils.py
@@ -10,7 +10,7 @@ import pandas as pd
 
 from clinica.utils.filemanip import UserProvidedPath
 
-from .study_models import StudyName
+from .study_models import BIDSSubjectID, StudyName
 
 __all__ = [
     "create_participants_df",
@@ -23,6 +23,7 @@ __all__ = [
     "viscode_to_session",
     "load_clinical_csv",
     "get_subjects_list_from_file",
+    "comparing_expected_vs_obtained_bids_ids",
 ]
 
 
@@ -93,7 +94,6 @@ def create_participants_df(
     prev_location = ""
     prev_sheet = 0
     index_to_drop = []
-    subjects_to_drop = []
     study_name = StudyName(study_name)
     location_name = f"{study_name.value} location"
 
@@ -175,33 +175,27 @@ def create_participants_df(
         participant_df = participant_df.drop_duplicates(
             subset=["alternative_id_1"], keep="first"
         )
+
     elif study_name == StudyName.OASIS:
         # OASIS provides several MRI for the same session
         participant_df = participant_df[
             ~participant_df.alternative_id_1.str.endswith("_MR2")
         ]
+
     participant_df.reset_index(inplace=True, drop=True)
 
     # Adding participant_id column with BIDS ids
     for i in range(0, len(participant_df)):
-        value = bids_id_factory(study_name).from_original_study_id(
-            participant_df["alternative_id_1"][i]
-        )
-        bids_id = [s for s in bids_ids if value in s]
-        if len(bids_id) == 0:
-            index_to_drop.append(i)
-            subjects_to_drop.append(value)
+        bids_id_from_participant_df = bids_id_factory(
+            study_name
+        ).from_original_study_id(participant_df["alternative_id_1"][i])
+
+        if bids_id_from_participant_df in bids_ids:
+            participant_df.at[i, "participant_id"] = bids_id_from_participant_df
+
         else:
-            participant_df.at[i, "participant_id"] = bids_id[0]
+            index_to_drop.append(i)
 
-    if len(subjects_to_drop) > 0:
-        cprint(
-            msg=(
-                "The following subjects of dataset directory were not found in your BIDS folder :\n"
-                + ", ".join(subjects_to_drop)
-            ),
-            lvl="info",
-        )
     # Delete all the rows of the subjects that are not available in the BIDS dataset
     if delete_non_bids_info:
         participant_df = participant_df.drop(index_to_drop)
@@ -588,3 +582,24 @@ def get_subjects_list_from_file(subjects_list_path: Path) -> list[str]:
         List of subjects.
     """
     return subjects_list_path.read_text().splitlines()
+
+
+def comparing_expected_vs_obtained_bids_ids(
+    expected_subjects: list[BIDSSubjectID], obtained_subjects: list[BIDSSubjectID]
+) -> list[BIDSSubjectID]:
+    """Gets the BIDS ids that were expected but not found in the obtained subjects list.
+
+    Parameters
+    ----------
+    expected_subjects : list[BIDSSubjectID]
+        First bids ids list.
+
+    obtained_subjects : list[BIDSSubjectID]
+        Second bids ids list.
+
+    Returns
+    -------
+    list[BIDSSubjectID] :
+        Bids ids difference.
+    """
+    return list(set(expected_subjects) - set(obtained_subjects))
diff --git a/clinica/converters/adni_to_bids/_converter.py b/clinica/converters/adni_to_bids/_converter.py
index b2b4e32e..e69d8b63 100644
--- a/clinica/converters/adni_to_bids/_converter.py
+++ b/clinica/converters/adni_to_bids/_converter.py
@@ -224,7 +224,7 @@ class AdniToBids(Converter):
                     destination_dir=dest_dir,
                     conversion_dir=conversion_dir,
                     subjects=subjects,
-                    mod_to_update=force_new_extraction,
+                    force_new_extraction=force_new_extraction,
                     n_procs=n_procs,
                 )
 
diff --git a/clinica/converters/adni_to_bids/_utils.py b/clinica/converters/adni_to_bids/_utils.py
index 1175d11a..f0ca126b 100644
--- a/clinica/converters/adni_to_bids/_utils.py
+++ b/clinica/converters/adni_to_bids/_utils.py
@@ -645,7 +645,7 @@ def paths_to_bids(
     images: pd.DataFrame,
     bids_dir: Path,
     modality: ADNIModalityConverter,
-    mod_to_update: bool = False,
+    force_new_extraction: bool = False,
     n_procs: Optional[int] = 1,
 ) -> List[Path]:
     """Images in the list are converted and copied to directory in BIDS format.
@@ -661,7 +661,7 @@ def paths_to_bids(
     modality : str
         Imaging modality.
 
-    mod_to_update : bool
+    force_new_extraction : bool
         If True, pre-existing images in the BIDS directory will be erased
         and extracted again.
 
@@ -684,7 +684,7 @@ def paths_to_bids(
         _create_file,
         modality=modality,
         bids_dir=bids_dir,
-        mod_to_update=mod_to_update,
+        force_new_extraction=force_new_extraction,
     )
     # If n_procs==1 do not rely on a Process Pool to enable classical debugging
     if n_procs == 1:
@@ -710,7 +710,7 @@ def _get_images_with_suffix(
 def _remove_existing_images_if_necessary(
     folder: Path,
     suffixes: Iterable[str],
-    mod_to_update: bool = False,
+    force_new_extraction: bool = False,
 ) -> bool:
     """Returns whether it was possible to delete the existing images or not."""
     from clinica.utils.stream import cprint
@@ -718,14 +718,14 @@ def _remove_existing_images_if_necessary(
     images_to_remove = _get_images_with_suffix(folder, suffixes)
     if not images_to_remove:
         return True
-    elif mod_to_update:
+    elif force_new_extraction:
         cprint(f"Removing old images : {images_to_remove}", lvl="info")
         for path_to_unlink in images_to_remove:
             (path_to_unlink).unlink()
         return True
     cprint(
         f"There already exist images : {images_to_remove}. "
-        "The parameter 'mod_to_update' is set to False so that "
+        "The parameter 'force_new_extraction' is set to False so that "
         "they cannot be overwritten.",
         lvl="warning",
     )
@@ -753,7 +753,7 @@ def _create_file(
     image: pd.Series,
     modality: ADNIModalityConverter,
     bids_dir: Path,
-    mod_to_update: bool,
+    force_new_extraction: bool,
 ) -> Optional[Path]:
     """Creates an image file at the corresponding output folder.
 
@@ -771,7 +771,7 @@ def _create_file(
     bids_dir : Path
         The path to the output BIDS directory.
 
-    mod_to_update : bool
+    force_new_extraction : bool
         If True, pre-existing images in the BIDS directory will be
         erased and extracted again.
 
@@ -837,7 +837,7 @@ def _create_file(
     if not _remove_existing_images_if_necessary(
         output_path,
         (_get_output_filename(modality, image_tracer), "magnitude", "phase"),
-        mod_to_update,
+        force_new_extraction,
     ):
         return None
 
diff --git a/clinica/converters/adni_to_bids/modality_converters/_av45_fbb_pet.py b/clinica/converters/adni_to_bids/modality_converters/_av45_fbb_pet.py
index 59f9594f..c49f0cdc 100644
--- a/clinica/converters/adni_to_bids/modality_converters/_av45_fbb_pet.py
+++ b/clinica/converters/adni_to_bids/modality_converters/_av45_fbb_pet.py
@@ -14,7 +14,7 @@ def convert_av45_fbb_pet(
     destination_dir: Path,
     conversion_dir: Path,
     subjects: Iterable[str],
-    mod_to_update: bool = False,
+    force_new_extraction: bool = False,
     n_procs: int = 1,
 ):
     """Convert AV-45 and Florbetaben PET images of ADNI into BIDS format.
@@ -36,7 +36,7 @@ def convert_av45_fbb_pet(
     subjects : List of str, optional
         List of subjects.
 
-    mod_to_update : bool
+    force_new_extraction : bool
         If True, pre-existing images in the BIDS directory
         will be erased and extracted again.
 
@@ -60,7 +60,7 @@ def convert_av45_fbb_pet(
         images,
         destination_dir,
         ADNIModalityConverter.PET_AV45,
-        mod_to_update=mod_to_update,
+        force_new_extraction=force_new_extraction,
         n_procs=n_procs,
     )
     cprint(msg="AV45 and Florbetaben PET conversion done.", lvl="debug")
diff --git a/clinica/converters/adni_to_bids/modality_converters/_dwi.py b/clinica/converters/adni_to_bids/modality_converters/_dwi.py
index 072f0dea..e8985213 100644
--- a/clinica/converters/adni_to_bids/modality_converters/_dwi.py
+++ b/clinica/converters/adni_to_bids/modality_converters/_dwi.py
@@ -14,7 +14,7 @@ def convert_dwi(
     destination_dir: Path,
     conversion_dir: Path,
     subjects: Iterable[str],
-    mod_to_update: bool = False,
+    force_new_extraction: bool = False,
     n_procs: int = 1,
 ):
     """Convert DW images of ADNI into BIDS format.
@@ -36,7 +36,7 @@ def convert_dwi(
     subjects : List of str, optional
         List of subjects.
 
-    mod_to_update : bool
+    force_new_extraction : bool
         If True, pre-existing images in the BIDS directory
         will be erased and extracted again.
 
@@ -59,7 +59,7 @@ def convert_dwi(
         images,
         destination_dir,
         ADNIModalityConverter.DWI,
-        mod_to_update=mod_to_update,
+        force_new_extraction=force_new_extraction,
         n_procs=n_procs,
     )
     cprint(msg="DWI conversion done.", lvl="debug")
diff --git a/clinica/converters/adni_to_bids/modality_converters/_fdg_pet.py b/clinica/converters/adni_to_bids/modality_converters/_fdg_pet.py
index 71771875..06ab64ea 100644
--- a/clinica/converters/adni_to_bids/modality_converters/_fdg_pet.py
+++ b/clinica/converters/adni_to_bids/modality_converters/_fdg_pet.py
@@ -53,7 +53,7 @@ def _convert_fdg_pet(
     conversion_dir: Path,
     preprocessing_step: ADNIPreprocessingStep,
     subjects: Iterable[str],
-    mod_to_update: bool = False,
+    force_new_extraction: bool = False,
     n_procs: int = 1,
 ):
     """Convert FDG PET images of ADNI into BIDS format.
@@ -78,7 +78,7 @@ def _convert_fdg_pet(
     subjects : List of str, optional
         List of subjects.
 
-    mod_to_update : bool
+    force_new_extraction : bool
         If True, pre-existing images in the BIDS directory
         will be erased and extracted again.
 
@@ -102,7 +102,11 @@ def _convert_fdg_pet(
     cprint("Paths of FDG PET images found. Exporting images into BIDS ...")
     modality = _get_modality_from_adni_preprocessing_step(preprocessing_step)
     paths_to_bids(
-        images, destination_dir, modality, mod_to_update=mod_to_update, n_procs=n_procs
+        images,
+        destination_dir,
+        modality,
+        force_new_extraction=force_new_extraction,
+        n_procs=n_procs,
     )
     cprint(msg="FDG PET conversion done.", lvl="debug")
 
diff --git a/clinica/converters/adni_to_bids/modality_converters/_flair.py b/clinica/converters/adni_to_bids/modality_converters/_flair.py
index da135bc6..3ef36aae 100644
--- a/clinica/converters/adni_to_bids/modality_converters/_flair.py
+++ b/clinica/converters/adni_to_bids/modality_converters/_flair.py
@@ -14,7 +14,7 @@ def convert_flair(
     destination_dir: Path,
     conversion_dir: Path,
     subjects: Iterable[str],
-    mod_to_update: bool = False,
+    force_new_extraction: bool = False,
     n_procs: int = 1,
 ):
     """Convert FLAIR images of ADNI into BIDS format.
@@ -36,7 +36,7 @@ def convert_flair(
     subjects : List of str, optional
         List of subjects.
 
-    mod_to_update : bool
+    force_new_extraction : bool
         If True, pre-existing images in the BIDS directory
         will be erased and extracted again.
 
@@ -63,7 +63,7 @@ def convert_flair(
         images,
         destination_dir,
         ADNIModalityConverter.FLAIR,
-        mod_to_update=mod_to_update,
+        force_new_extraction=force_new_extraction,
         n_procs=n_procs,
     )
     cprint(msg="FLAIR conversion done.", lvl="debug")
diff --git a/clinica/converters/adni_to_bids/modality_converters/_fmap.py b/clinica/converters/adni_to_bids/modality_converters/_fmap.py
index f149663b..a3c4a10a 100644
--- a/clinica/converters/adni_to_bids/modality_converters/_fmap.py
+++ b/clinica/converters/adni_to_bids/modality_converters/_fmap.py
@@ -22,7 +22,7 @@ def convert_fmap(
     destination_dir: PathLike,
     conversion_dir: PathLike,
     subjects: Iterable[str],
-    mod_to_update: bool = False,
+    force_new_extraction: bool = False,
     n_procs: int = 1,
 ):
     """Convert field map images of ADNI into BIDS format.
@@ -44,7 +44,7 @@ def convert_fmap(
     subjects : List of str, optional
         List of subjects.
 
-    mod_to_update : bool
+    force_new_extraction : bool
         If True, pre-existing images in the BIDS directory
         will be erased and extracted again.
     """
@@ -66,7 +66,10 @@ def convert_fmap(
     cprint("Paths of field maps found. Exporting images into BIDS ...")
 
     paths_to_bids(
-        images, destination_dir, ADNIModalityConverter.FMAP, mod_to_update=mod_to_update
+        images,
+        destination_dir,
+        ADNIModalityConverter.FMAP,
+        force_new_extraction=force_new_extraction,
     )
     reorganize_fmaps(destination_dir)
 
diff --git a/clinica/converters/adni_to_bids/modality_converters/_fmri.py b/clinica/converters/adni_to_bids/modality_converters/_fmri.py
index 71c58a62..0848586c 100644
--- a/clinica/converters/adni_to_bids/modality_converters/_fmri.py
+++ b/clinica/converters/adni_to_bids/modality_converters/_fmri.py
@@ -14,7 +14,7 @@ def convert_fmri(
     destination_dir: Path,
     conversion_dir: Path,
     subjects: Iterable[str],
-    mod_to_update: bool = False,
+    force_new_extraction: bool = False,
     n_procs: int = 1,
     convert_multiband: bool = True,
 ):
@@ -37,7 +37,7 @@ def convert_fmri(
     subjects : List of str, optional
         List of subjects.
 
-    mod_to_update : bool
+    force_new_extraction : bool
         If True, pre-existing images in the BIDS directory
         will be erased and extracted again.
 
@@ -70,7 +70,7 @@ def convert_fmri(
         images,
         destination_dir,
         ADNIModalityConverter.FMRI,
-        mod_to_update=mod_to_update,
+        force_new_extraction=force_new_extraction,
         n_procs=n_procs,
     )
     cprint(msg=f"{ADNIModalityConverter.FMRI} conversion done.", lvl="debug")
diff --git a/clinica/converters/adni_to_bids/modality_converters/_pib_pet.py b/clinica/converters/adni_to_bids/modality_converters/_pib_pet.py
index 00fe0ffd..fcbdddcd 100644
--- a/clinica/converters/adni_to_bids/modality_converters/_pib_pet.py
+++ b/clinica/converters/adni_to_bids/modality_converters/_pib_pet.py
@@ -14,7 +14,7 @@ def convert_pib_pet(
     destination_dir: Path,
     conversion_dir: Path,
     subjects: Iterable[str],
-    mod_to_update: bool = False,
+    force_new_extraction: bool = False,
     n_procs: int = 1,
 ):
     """Convert PIB PET images of ADNI into BIDS format.
@@ -36,7 +36,7 @@ def convert_pib_pet(
     subjects : List of str, optional
         List of subjects.
 
-    mod_to_update : bool
+    force_new_extraction : bool
         If True, pre-existing images in the BIDS directory
         will be erased and extracted again.
 
@@ -65,7 +65,7 @@ def convert_pib_pet(
         images,
         destination_dir,
         ADNIModalityConverter.PET_PIB,
-        mod_to_update=mod_to_update,
+        force_new_extraction=force_new_extraction,
         n_procs=n_procs,
     )
     cprint(msg=f"{ADNIModalityConverter.PET_PIB.value} conversion done.", lvl="debug")
diff --git a/clinica/converters/adni_to_bids/modality_converters/_t1.py b/clinica/converters/adni_to_bids/modality_converters/_t1.py
index 2812d949..952c52e2 100644
--- a/clinica/converters/adni_to_bids/modality_converters/_t1.py
+++ b/clinica/converters/adni_to_bids/modality_converters/_t1.py
@@ -14,7 +14,7 @@ def convert_t1(
     destination_dir: Path,
     conversion_dir: Path,
     subjects: Iterable[str],
-    mod_to_update: bool = False,
+    force_new_extraction: bool = False,
     n_procs: int = 1,
 ):
     """Convert T1 MR images of ADNI into BIDS format.
@@ -36,7 +36,7 @@ def convert_t1(
     subjects : List of str, optional
         List of subjects.
 
-    mod_to_update : bool
+    force_new_extraction : bool
         If True, pre-existing images in the BIDS directory
         will be erased and extracted again.
 
@@ -65,7 +65,7 @@ def convert_t1(
         images,
         destination_dir,
         ADNIModalityConverter.T1,
-        mod_to_update=mod_to_update,
+        force_new_extraction=force_new_extraction,
         n_procs=n_procs,
     )
     cprint(msg=f"{ADNIModalityConverter.T1.value} conversion done.", lvl="debug")
diff --git a/clinica/converters/adni_to_bids/modality_converters/_tau_pet.py b/clinica/converters/adni_to_bids/modality_converters/_tau_pet.py
index e6c18f4f..1f1a1833 100644
--- a/clinica/converters/adni_to_bids/modality_converters/_tau_pet.py
+++ b/clinica/converters/adni_to_bids/modality_converters/_tau_pet.py
@@ -14,7 +14,7 @@ def convert_tau_pet(
     destination_dir: Path,
     conversion_dir: Path,
     subjects: Iterable[str],
-    mod_to_update: bool = False,
+    force_new_extraction: bool = False,
     n_procs: int = 1,
 ):
     """Convert Tau PET images of ADNI into BIDS format.
@@ -36,7 +36,7 @@ def convert_tau_pet(
     subjects : List of str, optional
         List of subjects.
 
-    mod_to_update : bool
+    force_new_extraction : bool
         If True, pre-existing images in the BIDS directory
         will be erased and extracted again.
 
@@ -65,7 +65,7 @@ def convert_tau_pet(
         images,
         destination_dir,
         ADNIModalityConverter.PET_TAU,
-        mod_to_update=mod_to_update,
+        force_new_extraction=force_new_extraction,
         n_procs=n_procs,
     )
     cprint(msg=f"{ADNIModalityConverter.PET_TAU.value} conversion done.", lvl="debug")
diff --git a/clinica/converters/genfi_to_bids/_converter.py b/clinica/converters/genfi_to_bids/_converter.py
index b4b9f14a..9f00f9f8 100644
--- a/clinica/converters/genfi_to_bids/_converter.py
+++ b/clinica/converters/genfi_to_bids/_converter.py
@@ -68,7 +68,8 @@ def convert(
 
     path_to_dataset = validate_input_path(path_to_dataset)
     bids_dir = validate_input_path(bids_dir, check_exist=False)
-    path_to_clinical = validate_input_path(path_to_clinical)
+    if path_to_clinical:
+        path_to_clinical = validate_input_path(path_to_clinical)
     if path_to_clinical_tsv:
         path_to_clinical_tsv = validate_input_path(path_to_clinical_tsv)
     check_software(ThirdPartySoftware.DCM2NIIX)
diff --git a/clinica/converters/oasis_to_bids/_converter.py b/clinica/converters/oasis_to_bids/_converter.py
index d1953fd0..81fc40d7 100644
--- a/clinica/converters/oasis_to_bids/_converter.py
+++ b/clinica/converters/oasis_to_bids/_converter.py
@@ -55,6 +55,56 @@ class OasisToBids(Converter):
             source_dir, destination_dir, subjects=subjects, n_procs=n_procs
         )
         self.convert_clinical_data(clinical_data_dir, destination_dir)
+        self.log_missing_data(source_dir, destination_dir, subjects=subjects)
+
+    def log_missing_data(
+        self, source_dir: Path, bids_dir: Path, subjects: Optional[Path] = None
+    ):
+        """Log missing subjects in BIDS folders.
+
+        Parameters
+        ----------
+        source_dir : Path
+            Path to the OASIS dataset.
+
+        bids_dir : Path
+            Path to the BIDS directory.
+
+        subjects : (Optional) Path
+            Path to the subjects list file.
+            Default=None.
+        """
+        from clinica.converters._utils import comparing_expected_vs_obtained_bids_ids
+        from clinica.converters.study_models import OASISBIDSSubjectID
+        from clinica.dataset.bids._queries import get_subjects_from_bids_dataset
+        from clinica.utils.stream import cprint
+
+        from ._utils import get_subjects_list
+
+        expected_ids = [
+            OASISBIDSSubjectID(OASISBIDSSubjectID.from_original_study_id(subject.name))
+            for subject in get_subjects_list(source_dir, subjs_list_path=subjects)
+        ]
+        obtained_ids = [
+            OASISBIDSSubjectID(subject)
+            for subject in get_subjects_from_bids_dataset(bids_dir)
+        ]
+
+        if ids_difference := comparing_expected_vs_obtained_bids_ids(
+            expected_ids, obtained_ids
+        ):
+            cprint(
+                msg=(
+                    "The following subjects were not converted to your BIDS folder :\n"
+                    + ", ".join(ids_difference)
+                ),
+                lvl="info",
+            )
+        else:
+            cprint(
+                msg=("All selected subjects were converted to your BIDS folder."),
+                lvl="info",
+            )
 
     def convert_clinical_data(self, clinical_data_dir: Path, bids_dir: Path):
         """Convert the clinical data defined inside the clinical_specifications.xlx into BIDS.
@@ -63,7 +113,8 @@ class OasisToBids(Converter):
             clinical_data_dir: path to the folder with the original clinical data
             bids_dir: path to the BIDS directory
         """
-        from clinica.dataset import get_subjects_from_bids_dataset
+        from clinica.converters.study_models import BIDSSubjectID
+        from clinica.dataset.bids._queries import get_subjects_from_bids_dataset
         from clinica.utils.stream import cprint
 
         cprint("Converting clinical data...", lvl="info")
diff --git a/clinica/converters/oasis_to_bids/_utils.py b/clinica/converters/oasis_to_bids/_utils.py
index 37f96f35..c05f13a2 100644
--- a/clinica/converters/oasis_to_bids/_utils.py
+++ b/clinica/converters/oasis_to_bids/_utils.py
@@ -5,7 +5,11 @@ import nibabel as nb
 import numpy as np
 import pandas as pd
 
-from clinica.converters.study_models import StudyName, bids_id_factory
+from clinica.converters.study_models import (
+    OASISBIDSSubjectID,
+    StudyName,
+    bids_id_factory,
+)
 
 __all__ = [
     "get_subjects_list",
@@ -18,37 +22,76 @@ __all__ = [
 ]
 
 
-def _get_subjects_list_from_data(source_dir: Path) -> list[str]:
+def _get_subjects_list_from_file(subjects_list_path: Path) -> list[OASISBIDSSubjectID]:
+    """Gets the list of subjects folders names from the subjects list file.
+
+    Parameters
+    ----------
+    subjects_list_path : Path
+        The path to the subjects list file.
+
+    Returns
+    -------
+    list[OASISBIDSSubjectID] :
+        List of subjects folders names.
+    """
+    return [
+        OASISBIDSSubjectID(OASISBIDSSubjectID.from_original_study_id(subject))
+        for subject in subjects_list_path.read_text().splitlines()
+    ]
+
+
+def _get_subjects_list_from_data(source_dir: Path) -> list[OASISBIDSSubjectID]:
+    """Gets the list of subjects folders names from the input dataset folder.
+
+    Parameters
+    ----------
+    source_dir : Path
+        The path to the input dataset folder.
+
+    Returns
+    -------
+    list[OASISBIDSSubjectID] :
+        List of subjects folders names.
+    """
     return [
-        folder.name
+        OASISBIDSSubjectID(OASISBIDSSubjectID.from_original_study_id(folder.name))
         for folder in source_dir.iterdir()
         if not folder.name.startswith(".")
     ]
 
 
-def _filter_oasis_subjects(source_dir: Path, subjects_list: list[str]) -> list[Path]:
-    import re
+def _filter_oasis_subjects(
+    source_dir: Path, subjects_list: list[OASISBIDSSubjectID]
+) -> list[Path]:
+    """Filters and builds the paths to the subjects folders.
+
+    Parameters
+    ----------
+    source_dir : Path
+        The path to the input dataset folder.
 
-    rgx = re.compile(r"OAS1_\d{4}_MR1")
+    subjects_list : list[OASISBIDSSubjectID]
+        The list of subjects folders names.
 
+    Returns
+    -------
+    list[Path] :
+        List of paths to the subjects folders.
+    """
     return list(
         filter(
             lambda path: path.is_dir(),
-            [
-                source_dir / subj
-                for subj in filter(
-                    rgx.fullmatch,
-                    subjects_list,
-                )
-            ],
+            [source_dir / subj.to_original_study_id() for subj in subjects_list],
         )
     )
 
 
 def get_subjects_list(
-    source_dir: Path, subjs_list_path: Optional[Path] = None
+    source_dir: Path,
+    subjs_list_path: Optional[Path] = None,
 ) -> list[Path]:
-    """Gets the list of paths to the subjects folders.
+    """Gets the list of paths to the subjects folders from the raw dataset.
 
     Parameters
     ----------
@@ -63,11 +106,10 @@ def get_subjects_list(
     list[Path] :
         List of paths to the subjects folders.
     """
-    from .._utils import get_subjects_list_from_file
 
     if subjs_list_path:
         return _filter_oasis_subjects(
-            source_dir, get_subjects_list_from_file(subjs_list_path)
+            source_dir, _get_subjects_list_from_file(subjs_list_path)
         )
 
     return _filter_oasis_subjects(source_dir, _get_subjects_list_from_data(source_dir))


Test patch:
diff --git a/test/nonregression/pipelines/dwi/test_pipelines.py b/test/nonregression/pipelines/dwi/test_pipelines.py
index d491acc8..f71aa16b 100644
--- a/test/nonregression/pipelines/dwi/test_pipelines.py
+++ b/test/nonregression/pipelines/dwi/test_pipelines.py
@@ -30,7 +30,7 @@ def test_dwi_connectome(cmdopt, tmp_path):
 def run_dwi_dti(
     input_dir: Path, output_dir: Path, ref_dir: Path, working_dir: Path
 ) -> None:
-    from clinica.bids import BIDSFileName
+    from clinica.dataset.bids import BIDSFileName
     from clinica.pipelines.dwi.dti.pipeline import DwiDti
     from clinica.utils.dwi import DTIBasedMeasure
 
@@ -72,7 +72,7 @@ def run_dwi_dti(
 def run_dwi_connectome(
     input_dir: Path, output_dir: Path, ref_dir: Path, working_dir: Path
 ) -> None:
-    from clinica.bids import BIDSFileName
+    from clinica.dataset.bids import BIDSFileName
     from clinica.pipelines.dwi.connectome.pipeline import DwiConnectome
 
     caps_dir = output_dir / "caps"
diff --git a/test/unittests/converters/test_converter_utils.py b/test/unittests/converters/test_converter_utils.py
index 1f866de3..203f8239 100644
--- a/test/unittests/converters/test_converter_utils.py
+++ b/test/unittests/converters/test_converter_utils.py
@@ -194,6 +194,33 @@ def test_create_participants_df(
     )
 
 
+@pytest.mark.parametrize(
+    "asked, obtained, expected",
+    [
+        (
+            ["sub-OASIS10001", "sub-OASIS10002"],
+            ["sub-OASIS10002", "sub-OASIS10001"],
+            set(),
+        ),
+        (["sub-OASIS10001"], ["sub-OASIS10002"], {"sub-OASIS10001"}),
+        (["sub-OASIS10001"], [], {"sub-OASIS10001"}),
+    ],
+)
+def test_comparing_expected_vs_obtained_bids_ids(asked, obtained, expected):
+    from clinica.converters._utils import comparing_expected_vs_obtained_bids_ids
+    from clinica.converters.study_models import OASISBIDSSubjectID
+
+    assert (
+        set(
+            comparing_expected_vs_obtained_bids_ids(
+                [OASISBIDSSubjectID(subject) for subject in asked],
+                [OASISBIDSSubjectID(subject) for subject in obtained],
+            )
+        )
+        == expected
+    )
+
+
 @pytest.mark.parametrize("compress", [True, False])
 @pytest.mark.parametrize("sidecar", [True, False])
 def test_build_dcm2niix_command(tmp_path, compress: bool, sidecar: bool):
diff --git a/test/unittests/converters/test_oasis_to_bids_utils.py b/test/unittests/converters/test_oasis_to_bids_utils.py
index b358d604..72e30b4c 100644
--- a/test/unittests/converters/test_oasis_to_bids_utils.py
+++ b/test/unittests/converters/test_oasis_to_bids_utils.py
@@ -310,7 +310,17 @@ def test_get_image_with_good_orientation(tmp_path) -> None:
     assert len(image.shape) == 3  # the image dimension should be 3D
 
 
-def test_get_subjects_list_from_data(tmp_path) -> None:
+def test_get_subjects_list_from_correct_data(tmp_path) -> None:
+    from clinica.converters.oasis_to_bids._utils import get_subjects_list
+
+    source_dir = tmp_path / "dataset"
+    (source_dir / "OAS1_0001_MR1").mkdir(parents=True)
+    (source_dir / "OAS1_0002_MR1").touch()
+
+    assert get_subjects_list(source_dir) == [source_dir / "OAS1_0001_MR1"]
+
+
+def test_get_subjects_list_from_wrong_data(tmp_path) -> None:
     from clinica.converters.oasis_to_bids._utils import get_subjects_list
 
     source_dir = tmp_path / "dataset"
@@ -325,44 +335,66 @@ def test_get_subjects_list_from_data(tmp_path) -> None:
     ):
         (source_dir / filename).mkdir()
 
-    (source_dir / "OAS1_0005_MR1").touch()
-
-    assert get_subjects_list(source_dir) == [source_dir / "OAS1_0001_MR1"]
+    with pytest.raises(ValueError):
+        get_subjects_list(source_dir)
 
 
-def test_get_subjects_list_from_file(tmp_path) -> None:
+def test_get_subjects_list_from_correct_file(tmp_path) -> None:
     from clinica.converters.oasis_to_bids._utils import get_subjects_list
 
     source_dir = tmp_path / "dataset"
-    source_dir.mkdir()
+    (source_dir / "OAS1_0001_MR1").mkdir(parents=True)
+    (source_dir / "OAS1_0002_MR1").touch()
+
+    subjects_list = tmp_path / "subjects_list.txt"
+    subjects_list.touch()
 
-    lines = [
-        "OAS1_0001_MR1\n",
-        "OAS2_0002_MR1\n",
-        "OAS1_0003_MR2\n",
-        "OAS1_004_MR1\n",
-        "foo\n",
+    with open(str(subjects_list), "a") as file:
+        file.writelines(
+            [
+                "OAS1_0001_MR1\n",
+                "OAS1_0002_MR1\n",
+            ]
+        )
+
+    assert get_subjects_list(source_dir, subjects_list) == [
+        source_dir / "OAS1_0001_MR1"
     ]
 
-    for filename in lines:
-        (source_dir / filename[:-1]).mkdir()
 
-    (source_dir / "OAS1_0005_MR1").touch()
+@pytest.mark.parametrize(
+    "lines",
+    [
+        (
+            [
+                "OAS2_0001_MR1\n",
+            ]
+        ),
+        (
+            [
+                "OAS1_002_MR1\n",
+            ]
+        ),
+        (["foo\n"]),
+    ],
+)
+def test_get_subjects_list_from_wrong_file(tmp_path, lines) -> None:
+    from clinica.converters.oasis_to_bids._utils import get_subjects_list
 
-    lines.append("OAS1_0005_MR1\n")
+    source_dir = tmp_path / "dataset"
+    source_dir.mkdir()
 
-    subjects_list_dir = tmp_path / "subjects_list_dir"
-    subjects_list_dir.mkdir()
+    for filename in lines:
+        (source_dir / filename[:-1]).mkdir()
 
-    subjects_list = subjects_list_dir / "subjects_list.txt"
+    subjects_list = tmp_path / "subjects_list.txt"
     subjects_list.touch()
 
     with open(str(subjects_list), "a") as file:
         file.writelines(lines)
 
-    assert get_subjects_list(source_dir, subjects_list) == [
-        source_dir / "OAS1_0001_MR1"
-    ]
+    with pytest.raises(ValueError):
+        get_subjects_list(source_dir, subjects_list)
 
 
 @pytest.mark.parametrize(