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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- repo: https://github.com/psf/black
rev: 24.8.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.1.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.13.2
rev: 7.0.0
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
rev: 7.3.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/pydocstyle
Expand Down
1 change: 0 additions & 1 deletion phys2denoise/cli/run.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
"""Parser for phys2denoise."""


import argparse

from phys2denoise import __version__
Expand Down
24 changes: 8 additions & 16 deletions phys2denoise/metrics/cardiac.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,18 @@ def _cardiac_metrics(
data = io.load_physio(data, fs=fs)
data._metadata["peaks"] = peaks
else:
raise ValueError(
"""
raise ValueError("""
To use this function you should either provide a Physio object
with existing peaks metadata (e.g. using the peakdet module), or
by providing the physiological data timeseries, the sampling frequency,
and the peak indices separately.
"""
)
""")
if data.peaks.size == 0:
raise ValueError(
"""
raise ValueError("""
Peaks must be a non-empty list.
Make sure to run peak detection on your physiological data first,
using the peakdet module, or other software of your choice.
"""
)
""")

# Convert window to samples, but halves it.
halfwindow_samples = int(round(window * data.fs / 2))
Expand Down Expand Up @@ -384,22 +380,18 @@ def cardiac_phase(data, slice_timings, n_scans, t_r, peaks=None, fs=None, **kwar
data = io.load_physio(data, fs=fs)
data._metadata["peaks"] = peaks
else:
raise ValueError(
"""
raise ValueError("""
To use this function you should either provide a Physio object
with existing peaks metadata (e.g. using the peakdet module), or
by providing the physiological data timeseries, the sampling frequency,
and the peak indices separately.
"""
)
""")
if data.peaks.size == 0:
raise ValueError(
"""
raise ValueError("""
Peaks must be a non-empty list.
Make sure to run peak detection on your physiological data first,
using the peakdet module, or other software of your choice.
"""
)
""")

assert slice_timings.ndim == 1, "Slice times must be a 1D array"
n_slices = np.size(slice_timings)
Expand Down
30 changes: 10 additions & 20 deletions phys2denoise/metrics/chest_belt.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,18 @@ def respiratory_variance_time(
data._metadata["peaks"] = peaks
data._metadata["troughs"] = troughs
else:
raise ValueError(
"""
raise ValueError("""
To use this function you should either provide a Physio object
with existing peaks and troughs metadata (e.g. using the peakdet module), or
by providing the physiological data timeseries, the sampling frequency,
and the peak and trough indices separately.
"""
)
""")
if data.peaks.size == 0 or data.troughs.size == 0:
raise ValueError(
"""
raise ValueError("""
Peaks and troughs must be non-empty lists.
Make sure to run peak/trough detection on your physiological data first,
using the peakdet module, or other software of your choice.
"""
)
""")

timestep = 1 / data.fs
# respiration belt timing
Expand Down Expand Up @@ -219,14 +215,12 @@ def _respiratory_pattern_variability(data, window):
elif fs is not None:
data = io.load_physio(data, fs=fs)
else:
raise ValueError(
"""
raise ValueError("""
To use this function you should either provide a Physio object
with the sampling frequency encapsulated, or
by providing the physiological data timeseries and the sampling
frequency separately.
"""
)
""")

# Convert window to Hertz
window = int(window * data.fs)
Expand Down Expand Up @@ -288,14 +282,12 @@ def respiratory_variance(data, fs=None, window=6, **kwargs):
elif fs is not None:
data = io.load_physio(data, fs=fs)
else:
raise ValueError(
"""
raise ValueError("""
To use this function you should either provide a Physio object
with the sampling frequency encapsulated, or
by providing the physiological data timeseries and the sampling
frequency separately.
"""
)
""")

# Convert window to Hertz
halfwindow_samples = int(round(window * data.fs / 2))
Expand Down Expand Up @@ -338,14 +330,12 @@ def respiratory_phase(data, n_scans, slice_timings, t_r, fs=None, **kwargs):
elif fs is not None:
data = io.load_physio(data, fs=fs)
else:
raise ValueError(
"""
raise ValueError("""
To use this function you should either provide a Physio object
with the sampling frequency encapsulated, or
by providing the physiological data timeseries and the sampling
frequency separately.
"""
)
""")

assert slice_timings.ndim == 1, "Slice times must be a 1D array"
n_slices = np.size(slice_timings)
Expand Down
18 changes: 6 additions & 12 deletions phys2denoise/metrics/multimodal.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,37 +66,31 @@ def retroicor(
if data.physio_type is None and physio_type is not None:
data._physio_type = physio_type
elif data.physio_type is None and physio_type is None:
raise ValueError(
"""
raise ValueError("""
Since the provided Physio object does not specify a `physio_type`,
this function's `physio_type` parameter must be specified as a
value from {'cardiac', 'respiratory'}
"""
)
""")

elif fs is not None and physio_type is not None:
data = io.load_physio(data, fs=fs)
data._physio_type = physio_type
if data.physio_type == "cardiac":
data._metadata["peaks"] = cardiac_peaks
else:
raise ValueError(
"""
raise ValueError("""
To use this function you should either provide a Physio object
with existing peaks metadata if it describes a cardiac signal
(e.g. using the peakdet module), or
by providing the physiological data timeseries, the sampling frequency,
the physio_type and the peak indices separately.
"""
)
""")
if not data.peaks and data.physio_type == "cardiac":
raise ValueError(
"""
raise ValueError("""
Peaks must be a non-empty list for cardiac data.
Make sure to run peak detection on your cardiac data first,
using the peakdet module, or other software of your choice.
"""
)
""")

n_slices = np.shape(slice_timings) # number of slices

Expand Down
4 changes: 1 addition & 3 deletions versioneer.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=
return stdout, p.returncode


LONG_VERSION_PY[
"git"
] = '''
LONG_VERSION_PY["git"] = '''
# This file helps to compute a version number in source trees obtained from
# git-archive tarball (such as those provided by githubs download-from-tag
# feature). Distribution tarballs (built by setup.py sdist) and build
Expand Down