Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Integrate Loguru #53

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 2 additions & 0 deletions phys2denoise/metrics/cardiac.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Denoising metrics for cardio recordings."""
import numpy as np
from loguru import logger

from .. import references
from ..due import due
Expand All @@ -8,6 +9,7 @@
from .utils import convolve_and_rescale


@logger.catch
def _cardiac_metrics(card, peaks, samplerate, metric, window=6, central_measure="mean"):
"""
Compute cardiac metrics.
Expand Down
8 changes: 3 additions & 5 deletions phys2denoise/metrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
import logging

import numpy as np
from loguru import logger
from numpy.lib.stride_tricks import sliding_window_view as swv
from scipy.interpolate import interp1d
from scipy.stats import zscore

LGR = logging.getLogger(__name__)
LGR.setLevel(logging.INFO)


def print_metric_call(metric, args):
"""
Expand All @@ -33,7 +31,7 @@ def print_metric_call(metric, args):

msg = f"{msg}\n"

LGR.info(msg)
logger.info(msg)


def mirrorpad_1d(arr, buffer=250):
Expand All @@ -58,7 +56,7 @@ def mirrorpad_1d(arr, buffer=250):
post_mirror = np.take(mirror, idx, axis=0)
except IndexError:
len(arr)
LGR.warning(
logger.warning(
f"Requested buffer size ({buffer}) is longer than input array length "
f"({len(arr)}). Fixing buffer size to array length."
)
Expand Down
13 changes: 9 additions & 4 deletions phys2denoise/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import numpy as np
import pandas as pd
from loguru import logger

from phys2denoise.cli.run import _get_parser
from phys2denoise.metrics.cardiac import crf
Expand All @@ -32,8 +33,8 @@
from . import __version__
from .due import Doi, due

LGR = logging.getLogger(__name__)
LGR.setLevel(logging.INFO)
# LGR = logging.getLogger(__name__)
# LGR.setLevel(logging.INFO)


def save_bash_call(outdir):
Expand All @@ -59,6 +60,7 @@ def save_bash_call(outdir):
f.close()


@logger.catch
def select_input_args(metric, metric_args):
"""
Retrieve required args for metric from a dictionary of possible arguments.
Expand Down Expand Up @@ -112,6 +114,7 @@ def select_input_args(metric, metric_args):
version=__version__,
cite_module=True,
)
@logger.catch
def phys2denoise(
filename,
outdir=".",
Expand Down Expand Up @@ -182,8 +185,10 @@ def phys2denoise(
)

version_number = __version__
LGR.info(f"Currently running phys2denoise version {version_number}")
LGR.info(f"Input file is {filename}")
# LGR.info(f"Currently running phys2denoise version {version_number}")
# LGR.info(f"Input file is {filename}")
logger.info(f"Currently running phys2denoise version {version_number}")
logger.info(f"Input file is {filename}")

# Check options to make them internally coherent pt. II
# #!# This can probably be done while parsing?
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ test =
coverage
devtools =
pre-commit
logger =
loguru
dev =
%(devtools)s
%(doc)s
%(test)s
%(logger)s

[options.entry_points]
console_scripts =
Expand Down