1- # -*- coding: utf-8 -*-
1+ """Parser and physio workflow."""
2+
23import argparse
34import datetime
45import glob
4041
4142
4243def get_parser ():
43- """Parser for GUI and command-line arguments"""
44+ """Parser for GUI and command-line arguments. """
4445 parser = argparse .ArgumentParser ()
4546 parser .add_argument (
4647 "file_template" ,
@@ -53,7 +54,7 @@ def get_parser():
5354 )
5455
5556 inp_group = parser .add_argument_group (
56- "Inputs" , "Options to specify " " format of input files"
57+ "Inputs" , "Options to specify format of input files"
5758 )
5859 inp_group .add_argument (
5960 "--modality" ,
@@ -83,7 +84,7 @@ def get_parser():
8384 )
8485
8586 out_group = parser .add_argument_group (
86- "Outputs" , "Options to specify " " format of output files"
87+ "Outputs" , "Options to specify format of output files"
8788 )
8889 out_group .add_argument (
8990 "-o" ,
@@ -104,12 +105,12 @@ def get_parser():
104105 "-s" ,
105106 "--savehistory" ,
106107 action = "store_true" ,
107- help = "Whether to save history of data processing " " for each file." ,
108+ help = "Whether to save history of data processing for each file." ,
108109 )
109110
110111 edit_group = parser .add_argument_group (
111112 "Workflow arguments (optional!)" ,
112- "Options to specify modifications " " to workflow" ,
113+ "Options to specify modifications to workflow" ,
113114 )
114115 edit_group .add_argument (
115116 "-n" ,
@@ -135,7 +136,10 @@ def get_parser():
135136 "--debug" ,
136137 dest = "debug" ,
137138 action = "store_true" ,
138- help = "Print additional debugging info and error diagnostics to log file. Default is False." ,
139+ help = (
140+ "Print additional debugging info and error diagnostics to log file. "
141+ "Default is False."
142+ ),
139143 default = False ,
140144 )
141145 log_style_group_exclusive .add_argument (
@@ -162,12 +166,12 @@ def workflow(
162166 savehistory = True ,
163167 noedit = False ,
164168 thresh = 0.2 ,
165- measurements = ATTR_CONV . keys () ,
169+ measurements = None ,
166170 debug = False ,
167171 quiet = False ,
168172):
169173 """
170- Basic workflow for physiological data
174+ Run basic workflow for physiological data.
171175
172176 Parameters
173177 ----------
@@ -192,12 +196,15 @@ def workflow(
192196 Whether to disable interactive editing of physio data. Default: False
193197 thresh : [0, 1] float, optional
194198 Threshold for peak detection. Default: 0.2
195- measurements : list, optional
199+ measurements : None or list, optional
196200 Which HRV-related measurements to save from data. See ``peakdet.HRV``
197- for available measurements. Default: all available measurements.
201+ for available measurements.
202+ Default: None, that is all available measurements.
198203 verbose : bool, optional
199- Whether to include verbose logs when catching exceptions that include diagnostics
204+ Whether to include verbose logs when catching exceptions that include diagnostic
200205 """
206+ if measurements is None :
207+ measurements = ATTR_CONV .keys ()
201208 outdir = os .path .dirname (output )
202209 logger .info (f"Current path is { outdir } " )
203210
@@ -255,9 +262,9 @@ def workflow(
255262 )
256263
257264 # output file
258- logger .info ("OUTPUT FILE:\t \t {}" . format ( output ) )
265+ logger .info (f "OUTPUT FILE:\t \t { output } " )
259266 # grab files from file template
260- logger .info ("FILE TEMPLATE:\t {}" . format ( file_template ) )
267+ logger .info (f "FILE TEMPLATE:\t { file_template } " )
261268 files = glob .glob (file_template , recursive = True )
262269
263270 # convert measurements to peakdet.HRV attribute friendly names
@@ -277,7 +284,7 @@ def workflow(
277284 # check if output file exists -- if so, ensure headers will match
278285 head = "filename," + "," .join (measurements )
279286 if os .path .exists (output ):
280- with open (output , "r" ) as src :
287+ with open (output ) as src :
281288 eheader = src .readlines ()[0 ]
282289 # if existing output file does not have same measurements are those
283290 # requested on command line, warn and use existing measurements so
@@ -300,7 +307,7 @@ def workflow(
300307 # iterate through all files and do peak detection with manual editing
301308 for fname in files :
302309 fname = os .path .relpath (fname )
303- logger .info ("Currently processing {}" . format ( fname ) )
310+ logger .info (f "Currently processing { fname } " )
304311
305312 # if we want to save history, this is the output name it would take
306313 outname = os .path .join (
@@ -343,10 +350,12 @@ def workflow(
343350
344351
345352def main ():
353+ """Run main entrypoint."""
346354 logger .enable ("" )
347355 opts = get_parser ().parse_args ()
348356 workflow (** vars (opts ))
349357
350358
351359if __name__ == "__main__" :
360+ """Run main entrypoint."""
352361 main ()
0 commit comments