Skip to content

Commit db22e69

Browse files
committed
Optionally skip preprocessing in compute_respiration
1 parent 2b327cf commit db22e69

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

physio/respiration.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,17 @@ def compute_respiration(raw_resp, srate, parameter_preset='human_airflow', param
4242
recursive_update(params, parameters)
4343

4444
# filter and smooth : more or less 2 times a low pass
45-
center = np.mean(raw_resp)
46-
resp = raw_resp - center
47-
resp = preprocess(resp, srate, **params['preprocess'])
48-
if params['smooth'] is not None:
49-
resp = smooth_signal(resp, srate, **params['smooth'])
50-
resp += center
51-
45+
if params['preprocess'] is not None and params['smooth'] is not None:
46+
center = np.mean(raw_resp)
47+
resp = raw_resp - center
48+
if params['preprocess'] is not None:
49+
resp = preprocess(resp, srate, **params['preprocess'])
50+
if params['smooth'] is not None:
51+
resp = smooth_signal(resp, srate, **params['smooth'])
52+
resp += center
53+
else:
54+
resp = raw_resp
5255

53-
5456

5557
baseline = get_respiration_baseline(resp, srate, **params['baseline'])
5658

@@ -201,6 +203,15 @@ def detect_respiration_cycles_crossing_baseline(resp, srate, baseline_mode='manu
201203

202204
ind_insp, ind_exp = interleave_insp_exp(ind_insp, ind_exp, remove_first_insp=True, remove_first_exp=False)
203205

206+
# import matplotlib.pyplot as plt
207+
# fig, ax = plt.subplots()
208+
# ax.plot(resp)
209+
# ax.scatter(ind_insp, resp[ind_insp], color='g')
210+
# ax.scatter(ind_exp, resp[ind_exp], color='r')
211+
# ax.axhline(baseline_dw)
212+
# ax.axhline(baseline_insp)
213+
# ax.axhline(baseline)
214+
# plt.show()
204215

205216

206217
if inspiration_adjust_on_derivative:

0 commit comments

Comments
 (0)