diff --git a/peakdet/cli/run.py b/peakdet/cli/run.py index a2d25e9..0c16fe4 100644 --- a/peakdet/cli/run.py +++ b/peakdet/cli/run.py @@ -142,14 +142,14 @@ def workflow(*, file_template, modality, fs, source='MRI', channel=1, """ # output file - print('OUTPUT FILE:\t\t{}\n'.format(output)) + logger.info('OUTPUT FILE:\t\t{}\n'.format(output)) # grab files from file template - print('FILE TEMPLATE:\t{}\n'.format(file_template)) + logger.info('FILE TEMPLATE:\t{}\n'.format(file_template)) files = glob.glob(file_template, recursive=True) # convert measurements to peakdet.HRV attribute friendly names try: - print('REQUESTED MEASUREMENTS: {}\n'.format(', '.join(measurements))) + logger.info('REQUESTED MEASUREMENTS: {}\n'.format(', '.join(measurements))) except TypeError: raise TypeError('It looks like you didn\'t select any of the options ' 'specifying desired output measurements. Please ' @@ -168,10 +168,10 @@ def workflow(*, file_template, modality, fs, source='MRI', channel=1, # requested on command line, warn and use existing measurements so # as not to totally fork up existing file if eheader != head: - warnings.warn('Desired output file already exists and requested ' - 'measurements do not match with measurements in ' - 'existing output file. Using the pre-existing ' - 'measurements, instead.') + logger.warning('Desired output file already exists and requested ' + 'measurements do not match with measurements in ' + 'existing output file. Using the pre-existing ' + 'measurements, instead.') measurements = [f.strip() for f in eheader.split(',')[1:]] head = '' # if output file doesn't exist, nbd @@ -183,7 +183,7 @@ def workflow(*, file_template, modality, fs, source='MRI', channel=1, # iterate through all files and do peak detection with manual editing for fname in files: fname = os.path.relpath(fname) - print('Currently processing {}'.format(fname)) + logger.info('Currently processing {}'.format(fname)) # if we want to save history, this is the output name it would take outname = os.path.join(os.path.dirname(fname), diff --git a/peakdet/external.py b/peakdet/external.py index 2ccb1aa..d0a274a 100644 --- a/peakdet/external.py +++ b/peakdet/external.py @@ -39,9 +39,9 @@ def load_rtpeaks(fname, channel, fs): """ if fname.startswith('/'): - warnings.warn('Provided file seems to be an absolute path. In order ' - 'to ensure full reproducibility it is recommended that ' - 'a relative path is provided.') + logger.warning('Provided file seems to be an absolute path. In order ' + 'to ensure full reproducibility it is recommended that ' + 'a relative path is provided.') with open(fname, 'r') as src: header = src.readline().strip().split(',') diff --git a/peakdet/io.py b/peakdet/io.py index 439aac1..68a0d00 100644 --- a/peakdet/io.py +++ b/peakdet/io.py @@ -66,9 +66,9 @@ def load_physio(data, *, fs=None, dtype=None, history=None, # if we got a numpy array, load that into a Physio object elif isinstance(data, np.ndarray): if history is None: - warnings.warn('Loading data from a numpy array without providing a' - 'history will render reproducibility functions ' - 'useless! Continuing anyways.') + logger.warning('Loading data from a numpy array without providing a' + 'history will render reproducibility functions ' + 'useless! Continuing anyways.') phys = physio.Physio(np.asarray(data, dtype=dtype), fs=fs, history=history) # create a new Physio object out of a provided Physio object @@ -81,7 +81,7 @@ def load_physio(data, *, fs=None, dtype=None, history=None, # reset sampling rate, as requested if fs is not None and fs != phys.fs: if not np.isnan(phys.fs): - warnings.warn('Provided sampling rate does not match loaded rate. ' + logger.warning('Provided sampling rate does not match loaded rate. ' 'Resetting loaded sampling rate {} to provided {}' .format(phys.fs, fs)) phys._fs = fs @@ -151,7 +151,7 @@ def load_history(file, verbose=False): data = None for (func, kwargs) in history: if verbose: - print('Rerunning {}'.format(func)) + logger.info('Rerunning {}'.format(func)) # loading functions don't have `data` input because it should be the # first thing in `history` (when the data was originally loaded!). # for safety, check if `data` is None; someone could have potentially @@ -197,9 +197,9 @@ def save_history(file, data): data = check_physio(data) if len(data.history) == 0: - warnings.warn('History of provided Physio object is empty. Saving ' - 'anyway, but reloading this file will result in an ' - 'error.') + logger.warning('History of provided Physio object is empty. Saving ' + 'anyway, but reloading this file will result in an ' + 'error.') file += '.json' if not file.endswith('.json') else '' with open(file, 'w') as dest: json.dump(data.history, dest, indent=4)