Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changes/newsfragments/239.enh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve logging consistency of components by `Synchon Mandal`_
7 changes: 6 additions & 1 deletion junifer/api/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import shutil
from pathlib import Path

import structlog

from ..api.queue_context import GnuParallelLocalAdapter, HTCondorAdapter
from ..datagrabber import BaseDataGrabber
from ..markers import BaseMarker
Expand All @@ -27,11 +29,14 @@
PreprocessorLike,
StorageLike,
)
from ..utils import logger, raise_error, warn_with_log, yaml
from ..utils import raise_error, warn_with_log, yaml


__all__ = ["collect", "list_elements", "queue", "reset", "run"]

_log = structlog.get_logger("junifer")
logger = _log.bind(pkg="api")


def _get_datagrabber(datagrabber_config: dict) -> DataGrabberLike:
"""Get DataGrabber.
Expand Down
3 changes: 2 additions & 1 deletion junifer/api/queue_context/gnu_parallel_local_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
from typing import Any

from ...typing import Elements
from ...utils import logger, make_executable, raise_error, run_ext_cmd
from ...utils import make_executable, raise_error, run_ext_cmd
from .queue_context_adapter import (
EnvKind,
EnvShell,
QueueContextAdapter,
QueueContextEnv,
logger,
)


Expand Down
3 changes: 2 additions & 1 deletion junifer/api/queue_context/htcondor_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
from typing import Any

from ...typing import Elements
from ...utils import logger, make_executable, raise_error, run_ext_cmd
from ...utils import make_executable, raise_error, run_ext_cmd
from .queue_context_adapter import (
EnvKind,
EnvShell,
QueueContextAdapter,
QueueContextEnv,
logger,
)


Expand Down
4 changes: 4 additions & 0 deletions junifer/api/queue_context/queue_context_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@
from abc import ABC, abstractmethod
from enum import Enum

import structlog
from pydantic import BaseModel, ConfigDict

from ...utils import raise_error


__all__ = ["EnvKind", "EnvShell", "QueueContextAdapter", "QueueContextEnv"]

_log = structlog.get_logger("junifer")
logger = _log.bind(pkg="api")


class EnvKind(str, Enum):
"""Accepted Python environment kind."""
Expand Down
6 changes: 5 additions & 1 deletion junifer/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@
from pathlib import Path

import pandas as pd
import structlog

from ..typing import Elements
from ..utils import logger, raise_error, warn_with_log, yaml
from ..utils import raise_error, warn_with_log, yaml


__all__ = ["parse_elements", "parse_yaml"]

_log = structlog.get_logger("junifer")
logger = _log.bind(pkg="cli")


def parse_yaml(filepath: str | Path) -> dict: # noqa: C901
"""Parse YAML.
Expand Down
5 changes: 4 additions & 1 deletion junifer/data/coordinates/_ants_coordinates_warper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from numpy.typing import ArrayLike

from ...pipeline import WorkDirManager
from ...utils import logger, run_ext_cmd
from ...utils import run_ext_cmd


__all__ = ["ANTsCoordinatesWarper"]
Expand Down Expand Up @@ -46,6 +46,9 @@ def warp(
The transformed coordinates.

"""
# Imported here to avoid circular import
from ._coordinates import logger

logger.debug("Using ANTs for coordinates transformation")

# Create element-specific tempdir for storing post-warping assets
Expand Down
6 changes: 5 additions & 1 deletion junifer/data/coordinates/_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@

import numpy as np
import pandas as pd
import structlog
from junifer_data import get
from numpy.typing import ArrayLike

from ...utils import logger, raise_error
from ...utils import raise_error
from ..pipeline_data_registry_base import BasePipelineDataRegistry
from ..utils import JUNIFER_DATA_PARAMS, get_dataset_path, get_native_warper
from ._ants_coordinates_warper import ANTsCoordinatesWarper
Expand All @@ -21,6 +22,9 @@

__all__ = ["CoordinatesRegistry"]

_log = structlog.get_logger("junifer")
logger = _log.bind(pkg="data")


class CoordinatesRegistry(BasePipelineDataRegistry):
"""Class for coordinates data registry.
Expand Down
5 changes: 4 additions & 1 deletion junifer/data/coordinates/_fsl_coordinates_warper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from numpy.typing import ArrayLike

from ...pipeline import WorkDirManager
from ...utils import logger, run_ext_cmd
from ...utils import run_ext_cmd


__all__ = ["FSLCoordinatesWarper"]
Expand Down Expand Up @@ -46,6 +46,9 @@ def warp(
The transformed coordinates.

"""
# Imported here to avoid circular import
from ._coordinates import logger

logger.debug("Using FSL for coordinates transformation")

# Create element-specific tempdir for storing post-warping assets
Expand Down
5 changes: 4 additions & 1 deletion junifer/data/maps/_ants_maps_warper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import nibabel as nib

from ...pipeline import WorkDirManager
from ...utils import logger, raise_error, run_ext_cmd
from ...utils import raise_error, run_ext_cmd
from ..template_spaces import get_template, get_xfm


Expand Down Expand Up @@ -71,6 +71,9 @@ def warp(
If ``warp_data`` is None when ``dst="T1w"``.

"""
# Imported here to avoid circular import
from ._maps import logger

# Create element-scoped tempdir so that warped maps is
# available later as nibabel stores file path reference for
# loading on computation
Expand Down
5 changes: 4 additions & 1 deletion junifer/data/maps/_fsl_maps_warper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import nibabel as nib

from ...pipeline import WorkDirManager
from ...utils import logger, run_ext_cmd
from ...utils import run_ext_cmd


if TYPE_CHECKING:
Expand Down Expand Up @@ -53,6 +53,9 @@ def warp(
The transformed maps image.

"""
# Imported here to avoid circular import
from ._maps import logger

logger.debug("Using FSL for maps transformation")

# Create element-scoped tempdir so that warped maps is
Expand Down
6 changes: 5 additions & 1 deletion junifer/data/maps/_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
import nibabel as nib
import nilearn.image as nimg
import numpy as np
import structlog
from junifer_data import get

from ...utils import logger, raise_error
from ...utils import raise_error
from ..pipeline_data_registry_base import BasePipelineDataRegistry
from ..utils import (
JUNIFER_DATA_PARAMS,
Expand All @@ -29,6 +30,9 @@

__all__ = ["MapsRegistry"]

_log = structlog.get_logger("junifer")
logger = _log.bind(pkg="data")


class MapsRegistry(BasePipelineDataRegistry):
"""Class for maps data registry.
Expand Down
5 changes: 4 additions & 1 deletion junifer/data/masks/_ants_mask_warper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np

from ...pipeline import WorkDirManager
from ...utils import logger, raise_error, run_ext_cmd
from ...utils import raise_error, run_ext_cmd
from ..template_spaces import get_template, get_xfm


Expand Down Expand Up @@ -92,6 +92,9 @@ def warp(
If ``warp_data`` is None when ``dst="T1w"``.

"""
# Imported here to avoid circular import
from ._masks import logger

# Create element-scoped tempdir so that warped mask is
# available later as nibabel stores file path reference for
# loading on computation
Expand Down
5 changes: 4 additions & 1 deletion junifer/data/masks/_fsl_mask_warper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np

from ...pipeline import WorkDirManager
from ...utils import logger, run_ext_cmd
from ...utils import run_ext_cmd


if TYPE_CHECKING:
Expand Down Expand Up @@ -74,6 +74,9 @@ def warp(
The transformed mask image.

"""
# Imported here to avoid circular import
from ._masks import logger

logger.debug("Using FSL for mask transformation")

# Create element-scoped tempdir so that warped mask is
Expand Down
6 changes: 5 additions & 1 deletion junifer/data/masks/_masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
import nibabel as nib
import nilearn.image as nimg
import numpy as np
import structlog
from junifer_data import get
from nilearn.masking import (
compute_background_mask,
compute_epi_mask,
intersect_masks,
)

from ...utils import logger, raise_error
from ...utils import raise_error
from ..pipeline_data_registry_base import BasePipelineDataRegistry
from ..template_spaces import get_template
from ..utils import (
Expand All @@ -41,6 +42,9 @@

__all__ = ["MaskRegistry", "compute_brain_mask"]

_log = structlog.get_logger("junifer")
logger = _log.bind(pkg="data")


def compute_brain_mask(
target_data: dict[str, Any],
Expand Down
5 changes: 4 additions & 1 deletion junifer/data/parcellations/_ants_parcellation_warper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import nibabel as nib

from ...pipeline import WorkDirManager
from ...utils import logger, raise_error, run_ext_cmd
from ...utils import raise_error, run_ext_cmd
from ..template_spaces import get_template, get_xfm


Expand Down Expand Up @@ -71,6 +71,9 @@ def warp(
If ``warp_data`` is None when ``dst="T1w"``.

"""
# Imported here to avoid circular import
from ._parcellations import logger

# Create element-scoped tempdir so that warped parcellation is
# available later as nibabel stores file path reference for
# loading on computation
Expand Down
5 changes: 4 additions & 1 deletion junifer/data/parcellations/_fsl_parcellation_warper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import nibabel as nib

from ...pipeline import WorkDirManager
from ...utils import logger, run_ext_cmd
from ...utils import run_ext_cmd


if TYPE_CHECKING:
Expand Down Expand Up @@ -53,6 +53,9 @@ def warp(
The transformed parcellation image.

"""
# Imported here to avoid circular import
from ._parcellations import logger

logger.debug("Using FSL for parcellation transformation")

# Create element-scoped tempdir so that warped parcellation is
Expand Down
14 changes: 11 additions & 3 deletions junifer/data/parcellations/_parcellations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
import nilearn.image as nimg
import numpy as np
import pandas as pd
import structlog
from junifer_data import get

from ...utils import logger, raise_error, warn_with_log
from ...utils import raise_error, warn_with_log
from ..pipeline_data_registry_base import BasePipelineDataRegistry
from ..utils import (
JUNIFER_DATA_PARAMS,
Expand All @@ -36,6 +37,9 @@
"merge_parcellations",
]

_log = structlog.get_logger("junifer")
logger = _log.bind(pkg="data")


class ParcellationRegistry(BasePipelineDataRegistry):
"""Class for parcellation data registry.
Expand All @@ -58,8 +62,12 @@ def __init__(self) -> None:
# The built-in parcellations are files that are shipped with the
# junifer-data dataset.
# Make built-in and external dictionaries for validation later
self._builtin = {}
self._external = {}
self._builtin: dict[
str, dict[str, str | int | Path | list[str] | list[int]]
] = {}
self._external: dict[
str, dict[str, str | int | Path | list[str] | list[int]]
] = {}

# Add SUIT
self._builtin.update(
Expand Down
6 changes: 5 additions & 1 deletion junifer/data/template_spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@

import nibabel as nib
import numpy as np
import structlog
from junifer_data import get
from templateflow import api as tflow

from ..utils import logger, raise_error
from ..utils import raise_error
from .utils import JUNIFER_DATA_PARAMS, closest_resolution, get_dataset_path


__all__ = ["get_template", "get_xfm"]

_log = structlog.get_logger("junifer")
logger = _log.bind(pkg="data")


def get_xfm(src: str, dst: str) -> Path: # pragma: no cover
"""Fetch warp files to convert from ``src`` to ``dst``.
Expand Down
5 changes: 4 additions & 1 deletion junifer/data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
from pathlib import Path

import numpy as np
import structlog

from ..utils import config, logger, raise_error
from ..utils import config, raise_error


__all__ = [
Expand All @@ -21,6 +22,8 @@
"get_native_warper",
]

_log = structlog.get_logger("junifer")
logger = _log.bind(pkg="data")

# junifer-data version constant
JUNIFER_DATA_VERSION = "7"
Expand Down
Loading
Loading