Skip to content

Commit

Permalink
Merge branch 'master' into rvt
Browse files Browse the repository at this point in the history
  • Loading branch information
kristinazvolanek authored Nov 29, 2022
2 parents d4fd563 + 772ab8e commit 8da6f7a
Show file tree
Hide file tree
Showing 16 changed files with 1,308 additions and 4 deletions.
12 changes: 11 additions & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"infra",
"projectManagement",
"code",
"ideas"
"ideas",
"doc"
]
},
{
Expand All @@ -47,6 +48,15 @@
"ideas",
"review"
]
},
{
"login": "ineschh",
"name": "Inés Chavarría",
"avatar_url": "https://avatars.githubusercontent.com/u/72545702?v=4",
"profile": "https://github.com/ineschh",
"contributions": [
"infra"
]
}
],
"contributorsPerLine": 8,
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.7
python-version: '3.7'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -29,4 +29,4 @@ jobs:
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m python setup.py sdist bdist_wheel
python -m twine upload dist/*
python -m twine upload dist/*
47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 0.2.0 (Thu Feb 25 2021)

#### 💥 Breaking Change during development

- Add initial set of metrics [#19](https://github.com/physiopy/phys2denoise/pull/19) ([@CesarCaballeroGaudes](https://github.com/CesarCaballeroGaudes) [@tsalo](https://github.com/tsalo) [@smoia](https://github.com/smoia))

#### Authors: 3

- Cesar Caballero Gaudes ([@CesarCaballeroGaudes](https://github.com/CesarCaballeroGaudes))
- Stefano Moia ([@smoia](https://github.com/smoia))
- Taylor Salo ([@tsalo](https://github.com/tsalo))

---

# 0.1.0 (Thu Feb 25 2021)

:tada: This release contains work from new contributors! :tada:

Thanks for all your work!

:heart: Stefano Moia ([@smoia](https://github.com/smoia))

:heart: Inés Chavarría ([@ineschh](https://github.com/ineschh))

#### 💥 Breaking Change during development

- Add main workflow of phys2denoise [#17](https://github.com/physiopy/phys2denoise/pull/17) ([@smoia](https://github.com/smoia) [@ineschh](https://github.com/ineschh))

#### ⚠️ Pushed to `master`

- update all-contributors ([@smoia](https://github.com/smoia))
- Correct attributes ([@smoia](https://github.com/smoia))
- Add duecredit to setup ([@smoia](https://github.com/smoia))
- General configuration of the infrastructure ([@smoia](https://github.com/smoia))
- Correct development status ([@smoia](https://github.com/smoia))
- Add infra files ([@smoia](https://github.com/smoia))
- Initial commit ([@smoia](https://github.com/smoia))

#### 🏠 Internal

- Update PR template to match `phys2bids` [#20](https://github.com/physiopy/phys2denoise/pull/20) ([@smoia](https://github.com/smoia))
- Add initial infrastructure [#12](https://github.com/physiopy/phys2denoise/pull/12) ([@smoia](https://github.com/smoia))

#### Authors: 2

- Inés Chavarría ([@ineschh](https://github.com/ineschh))
- Stefano Moia ([@smoia](https://github.com/smoia))
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<tr>
<td align="center"><a href="https://github.com/CesarCaballeroGaudes"><img src="https://avatars1.githubusercontent.com/u/7611340?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Cesar Caballero Gaudes</b></sub></a><br /><a href="https://github.com/physiopy/phys2denoise/commits?author=CesarCaballeroGaudes" title="Code">💻</a> <a href="#ideas-CesarCaballeroGaudes" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="http://rossmarkello.com"><img src="https://avatars0.githubusercontent.com/u/14265705?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ross Markello</b></sub></a><br /><a href="#infra-rmarkello" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
<td align="center"><a href="https://github.com/smoia"><img src="https://avatars3.githubusercontent.com/u/35300580?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stefano Moia</b></sub></a><br /><a href="#data-smoia" title="Data">🔣</a> <a href="#infra-smoia" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#projectManagement-smoia" title="Project Management">📆</a> <a href="https://github.com/physiopy/phys2denoise/commits?author=smoia" title="Code">💻</a> <a href="#ideas-smoia" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="https://github.com/smoia"><img src="https://avatars3.githubusercontent.com/u/35300580?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stefano Moia</b></sub></a><br /><a href="#data-smoia" title="Data">🔣</a> <a href="#infra-smoia" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#projectManagement-smoia" title="Project Management">📆</a> <a href="https://github.com/physiopy/phys2denoise/commits?author=smoia" title="Code">💻</a> <a href="#ideas-smoia" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/physiopy/phys2denoise/commits?author=smoia" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/tsalo"><img src="https://avatars3.githubusercontent.com/u/8228902?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Taylor Salo</b></sub></a><br /><a href="https://github.com/physiopy/phys2denoise/commits?author=tsalo" title="Code">💻</a> <a href="#ideas-tsalo" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/physiopy/phys2denoise/pulls?q=is%3Apr+reviewed-by%3Atsalo" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://github.com/ineschh"><img src="https://avatars.githubusercontent.com/u/72545702?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Inés Chavarría</b></sub></a><br /><a href="#infra-ineschh" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
</tr>
</table>

Expand Down
195 changes: 195 additions & 0 deletions phys2denoise/cli/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
# -*- coding: utf-8 -*-
"""Parser for phys2denoise."""


import argparse

from phys2denoise import __version__
from phys2denoise.metrics.cardiac import crf
from phys2denoise.metrics.chest_belt import rpv, rv, rvt, rrf, env


def _get_parser():
"""
Parse command line inputs for this function.
Returns
-------
parser.parse_args() : argparse dict
Notes
-----
Default values must be updated in __call__ method from MetricsArgDict class.
# Argument parser follow template provided by RalphyZ.
# https://stackoverflow.com/a/43456577
"""

parser = argparse.ArgumentParser()
optional = parser._action_groups.pop()
required = parser.add_argument_group("Required Argument")
metrics = parser.add_argument_group("Metrics")
metric_arg = parser.add_argument_group("Metrics Arguments")
# Required arguments
required.add_argument("-in", "--input-file",
dest="filename",
type=str,
help="Full path and name of the file containing "
"physiological data, with or without extension.",
required=True)
# Important optional arguments
optional.add_argument("-outdir", "--output-dir",
dest="outdir",
type=str,
help="Folder where output should be placed. "
"Default is current folder.",
default=".")
# Metric selection
metrics.add_argument("-crf", "--cardiac-response-function",
dest="metrics",
action="append_const",
const=crf,
help="Cardiac response function. Requires the following "
"inputs:sample-rate, oversampling, time-length, "
"onset and tr.",
default=[])
metrics.add_argument("-rpv", "--respiratory-pattern-variability",
dest="metrics",
action="append_const",
const=rpv,
help="Respiratory pattern variability. Requires the following "
"input: window.",
default=[])
metrics.add_argument("-env", "--envelope",
dest="metrics",
action="append_const",
const=env,
help="Respiratory pattern variability calculated across a sliding "
"window. Requires the following inputs: sample-rate, window and lags.",
default=[])
metrics.add_argument("-rv", "--respiratory-variance",
dest="metrics",
action="append_const",
const=rv,
help="Respiratory variance. Requires the following inputs: "
"sample-rate, window and lags. If the input file "
"not a .phys file, it also requires peaks and troughs",
default=[])
"""
metrics.add_argument("-rvt", "--respiratory-volume-per-time",
dest="metrics",
action="append_const",
const="rvt",
help="Respiratory volume-per-time. Requires the following inputs: "
"sample-rate, window, lags, peaks and troughs.",
default=[])
"""
metrics.add_argument("-rrf", "--respiratory-response-function",
dest="metrics",
action="append_const",
const=rrf,
help="Respiratory response function. Requires the following inputs: "
"sample-rate, oversampling, time-length, onset and tr.",
default=[])
metrics.add_argument("-rcard", "--retroicor-card",
dest="metrics",
action="append_const",
const="r_card",
help="Computes regressors for cardiac signal. Requires the following "
"inputs: tr, nscans and n_harm.",
default=[])
metrics.add_argument("-rresp", "--retroicor-resp",
dest="metrics",
action="append_const",
const="r_resp",
help="Computes regressors for respiratory signal. Requires the following "
"inputs: tr, nscans and n_harm.",
default=[])
# Metric arguments
metric_arg.add_argument("-sr", "--sample-rate",
dest="sample_rate",
type=float,
help="Sampling rate of the physiological data in Hz.",
default=None)
metric_arg.add_argument("-pk", "--peaks",
dest="peaks",
type=str,
help="Full path and filename of the list with the indexed peaks' "
"positions of the physiological data.",
default=None)
metric_arg.add_argument("-tg", "--troughs",
dest="troughs",
type=str,
help="Full path and filename of the list with the indexed troughs' "
"positions of the physiological data.",
default=None)
metric_arg.add_argument("-os", "--oversampling",
dest="oversampling",
type=int,
help="Temporal oversampling factor. "
"Default is 50.",
default=50)
metric_arg.add_argument("-tl", "--time-length",
dest="time_length",
type=int,
help="RRF or CRF Kernel length in seconds.",
default=None)
metric_arg.add_argument("-onset", "--onset",
dest="onset",
type=float,
help="Onset of the response in seconds. "
"Default is 0.",
default=0)
metric_arg.add_argument("-tr", "--tr",
dest="tr",
type=float,
help="TR of sequence in seconds.",
default=None)
metric_arg.add_argument("-win", "--window",
dest="window",
type=int,
help="Size of the sliding window in seconds. "
"Default is 6 seconds.",
default=6)
metric_arg.add_argument("-lags", "--lags",
dest="lags",
nargs="*",
type=int,
help="List of lags to apply to the RV estimate "
"in seconds.",
default=None)
metric_arg.add_argument("-nscans", "--number-scans",
dest="nscans",
type=int,
help="Number of timepoints in the imaging data. "
"Also called sub-bricks, TRs, scans, volumes."
"Default is 1.",
default=1)
metric_arg.add_argument("-nharm", "--number-harmonics",
dest="n_harm",
type=int,
help="Number of harmonics.",
default=None)

# Other optional arguments
optional.add_argument("-debug", "--debug",
dest="debug",
action="store_true",
help="Only print debugging info to log file. Default is False.",
default=False)
optional.add_argument("-quiet", "--quiet",
dest="quiet",
action="store_true",
help="Only print warnings to log file. Default is False.",
default=False)
optional.add_argument("-v", "--version", action="version",
version=("%(prog)s " + __version__))

parser._action_groups.append(optional)

return parser


if __name__ == "__main__":
raise RuntimeError("phys2denoise/cli/run.py should not be run directly;\n"
"Please `pip install` phys2denoise and use the "
"`phys2denoise` command")
77 changes: 77 additions & 0 deletions phys2denoise/due.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# emacs: at the end of the file
# ex: set sts=4 ts=4 sw=4 et:
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
"""Stub file for a guaranteed safe import of duecredit constructs if duecredit is not available.
To use it, place it into your project codebase to be imported, e.g. copy as
cp stub.py /path/tomodule/module/due.py
Note that it might be better to avoid naming it duecredit.py to avoid shadowing
installed duecredit.
Then use in your code as
from .due import due, Doi, BibTeX, Text
See https://github.com/duecredit/duecredit/blob/master/README.md for examples.
Origin: Originally a part of the duecredit
Copyright: 2015-2019 DueCredit developers
License: BSD-2
"""

__version__ = "0.0.8"


class InactiveDueCreditCollector(object):
"""Just a stub at the Collector which would not do anything."""

def _donothing(self, *args, **kwargs):
"""Perform no good and no bad."""
pass

def dcite(self, *args, **kwargs):
"""If I could cite I would."""

def nondecorating_decorator(func):
return func

return nondecorating_decorator

active = False
activate = add = cite = dump = load = _donothing

def __repr__(self):
"""Perform magic."""
return self.__class__.__name__ + "()"


def _donothing_func(*args, **kwargs):
"""Perform no good and no bad."""
pass


try:
from duecredit import BibTeX, Doi, Text, Url, due

if "due" in locals() and not hasattr(due, "cite"):
raise RuntimeError("Imported due lacks .cite. DueCredit is now disabled")
except Exception as e:
if not isinstance(e, ImportError):
import logging

logging.getLogger("duecredit").error(
"Failed to import duecredit due to %s" % str(e)
)
# Initiate due stub
due = InactiveDueCreditCollector()
BibTeX = Doi = Url = Text = _donothing_func

# Emacs mode definitions
# Local Variables:
# mode: python
# py-indent-offset: 4
# tab-width: 4
# indent-tabs-mode: nil
# End:
15 changes: 15 additions & 0 deletions phys2denoise/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Metrics derived from physiological signals."""
from .cardiac import crf, cardiac_phase
from .chest_belt import rpv, env, rv, rrf, respiratory_phase
from .multimodal import retroicor

__all__ = [
"crf",
"cardiac_phase",
"rpv",
"env",
"rv",
"rrf",
"respiratory_phase",
"retroicor",
]
Loading

0 comments on commit 8da6f7a

Please sign in to comment.