Skip to content
Open
39 changes: 39 additions & 0 deletions peakdet/blocks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from peakdet import load_physio, save_physio
from peakdet.operations import edit_physio, interpolate_physio, filter_physio, peakfind_physio

FUNCTION_MAPPINGS = {
"interpolate_physio": interpolate_physio,
"filter_physio": filter_physio,
"peakfind_physio": peakfind_physio
}

def process_signals(data, steps):
"""
Parameters
----------
data : :class:`peakdet.Physio`
steps : list

Return
------
data : :class:`peakdet.Physio` (w/ features from peakfind_physio)
"""
for step in steps:
func = list(step.keys())[0]
data = FUNCTION_MAPPINGS[func](data, **step[func])
return data


def manual_peaks(data, fname):
"""
data : str or array_like or Physio_like
Input physiological data. If array_like, should be one-dimensional
fname : str
Path to output file; .phys will be appended if necessary
"""
# Load signals
phys = load_physio(data, allow_pickle=True)
# Edit peaks
phys = edit_physio(data)
# Save edits
save_physio(fname, phys)
19 changes: 8 additions & 11 deletions peakdet/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from gooey import Gooey, GooeyParser
import peakdet

TARGET = 'pythonw' if sys.platform == 'darwin' else 'python'
TARGET += ' -u ' + os.path.abspath(__file__)

LOADERS = dict(
rtpeaks=peakdet.load_rtpeaks,
Expand Down Expand Up @@ -45,9 +43,8 @@

@Gooey(program_name='Physio pipeline',
program_description='Physiological processing pipeline',
default_size=(800, 600),
target=TARGET)
def get_parser():
default_size=(800, 600))
def _get_parser():
""" Parser for GUI and command-line arguments """
parser = GooeyParser()
parser.add_argument('file_template', metavar='Filename template',
Expand Down Expand Up @@ -224,10 +221,10 @@ def workflow(*, file_template, modality, fs, source='MRI', channel=1,
dest.write(','.join([fname] + outputs) + '\n')


def main():
opts = get_parser().parse_args()
workflow(**vars(opts))


if __name__ == '__main__':
main()
raise RuntimeError(
"peakdet/cli/run.py should not be run directly;\n"
"Please `pip install` peakdet and use the "
"`peakdet` command"
)

16 changes: 16 additions & 0 deletions peakdet/configs/config_ppg_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"PPG": [
{
"filter_physio": {
"cutoffs": 1.0,
"method": "lowpass"
}
},
{
"filter_physio": {
"cutoffs": 40,
"method": "highpass"
}
}
]
}
Loading