-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,308 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
] |
Oops, something went wrong.