Skip to content

Commit

Permalink
[FIX] Fix logging in OASIS and AIBL converters (aramis-lab#1340)
Browse files Browse the repository at this point in the history
  • Loading branch information
AliceJoubert authored and NicolasGensollen committed Oct 24, 2024
1 parent d6123b3 commit 999cd3d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions clinica/iotools/converters/aibl_to_bids/utils/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,11 +630,19 @@ def _create_file(
Path or None :
Path to file
"""
from clinica.cmdline import setup_clinica_logging
from clinica.iotools.bids_utils import StudyName, bids_id_factory, json_from_dcm
from clinica.iotools.converter_utils import viscode_to_session
from clinica.iotools.utils.data_handling import center_nifti_origin
from clinica.utils.stream import cprint

# This function is executed in a multiprocessing context
# such that we need to re-configure the clinica logger in the child processes.
# Note that logging messages could easily be lost (for example when logging
# to a file from two different processes). A better solution would be to
# implement a logging process consuming logging messages from a multiprocessing.Queue...
setup_clinica_logging("INFO")

participant_id = bids_id_factory(StudyName.AIBL).from_original_study_id(
image.Subjects_ID
)
Expand Down
8 changes: 8 additions & 0 deletions clinica/iotools/converters/oasis_to_bids/oasis_to_bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,17 @@ def _create_modality_agnostic_files(self, bids_dir: Path):

@staticmethod
def convert_single_subject(subj_folder: Path, dest_dir: Path):
from clinica.cmdline import setup_clinica_logging
from clinica.iotools.bids_utils import StudyName, bids_id_factory
from clinica.utils.stream import cprint

# This function is executed in a multiprocessing context
# such that we need to re-configure the clinica logger in the child processes.
# Note that logging messages could easily be lost (for example when logging
# to a file from two different processes). A better solution would be to
# implement a logging process consuming logging messages from a multiprocessing.Queue...
setup_clinica_logging("INFO")

t1_folder = subj_folder / "PROCESSED" / "MPRAGE" / "SUBJ_111"
cprint(f"Converting {subj_folder.name}", lvl="info")
participant_id = bids_id_factory(StudyName.OASIS).from_original_study_id(
Expand Down

0 comments on commit 999cd3d

Please sign in to comment.