@@ -42,15 +42,17 @@ def compute_respiration(raw_resp, srate, parameter_preset='human_airflow', param
42
42
recursive_update (params , parameters )
43
43
44
44
# 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
52
55
53
-
54
56
55
57
baseline = get_respiration_baseline (resp , srate , ** params ['baseline' ])
56
58
@@ -201,6 +203,15 @@ def detect_respiration_cycles_crossing_baseline(resp, srate, baseline_mode='manu
201
203
202
204
ind_insp , ind_exp = interleave_insp_exp (ind_insp , ind_exp , remove_first_insp = True , remove_first_exp = False )
203
205
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()
204
215
205
216
206
217
if inspiration_adjust_on_derivative :
0 commit comments