|
23 | 23 | # %% DEFINE PATH AND PARAMETERS (ADJUST HERE) |
24 | 24 |
|
25 | 25 | # set your data and results paths here: |
26 | | -DATA_PATH = "./input_data/" |
27 | | -RESULTS_PATH = "./results/" |
| 26 | +DATA_PATH = "/Users/husker/Workspace/Emine/DLC cFC/Data Test/" |
| 27 | +RESULTS_PATH = "/Users/husker/Workspace/Emine/DLC cFC/results/" |
28 | 28 |
|
29 | 29 | # define frame rate and time step: |
30 | 30 | frame_rate = 30 # fps |
|
42 | 42 | # threshold, you can filter out low-confidence points. |
43 | 43 |
|
44 | 44 | # define a threshold for movement detection: |
45 | | -movement_threshold = 100 # px/frame; note, if you set pixel_size to 1, this is in px/s; |
| 45 | +movement_threshold = 500 # px/frame; note, if you set pixel_size to 1, this is in px/s; |
46 | 46 | # if you set pixel_size to a value other than 1, this is in spatial_unit/s; |
47 | 47 | # this threshold is used to determine whether a body part is moving or not; |
48 | 48 | # if the velocity is above this threshold, the body part is considered to be moving; |
49 | 49 | # if the velocity is below this threshold, the body part is considered to be not moving; |
50 | 50 |
|
| 51 | +# set (optional!) y-axis limit for velocity plot: |
| 52 | +ylim = None # DON'T CHANGE THIS LINE |
| 53 | +# |
| 54 | +# uncomment if you want to set a fixed y-axis limit for the velocity plot: |
| 55 | +# |
| 56 | +# ylim = 1000 # set to a value, e.g., 1000, for fixed scaling; |
| 57 | +# |
| 58 | +# note: this is useful if you want to compare the velocity plots of different files; |
| 59 | +# if you set ylim to None, the y-axis limit will be automatically scaled to the data; |
| 60 | + |
| 61 | + |
| 62 | +# define bodyparts to be excluded from the velocity plot: |
| 63 | +bodypart_not_to_plot = None # DO NOT CHANGE THIS LINE |
| 64 | +# |
| 65 | +# uncomment if you want to exclude some body parts from the velocity plot: |
| 66 | +# |
| 67 | +# bodypart_not_to_plot = ['ear_L', 'ear_R'] # set to a list of body parts to be excluded from the velocity plot; |
| 68 | + |
| 69 | + |
51 | 70 | # define bodypart-groups: |
52 | 71 | # initialize bodypart_groups as None if not defined: |
53 | 72 | bodypart_groups = None # DON'T CHANGE THIS LINE |
54 | 73 | # |
55 | | -# uncomment the following if you want to group body parts together: |
| 74 | +# uncomment if you want to group body parts together: |
56 | 75 | # |
57 | 76 | # bodypart_groups = { |
58 | | -# 'group1': ['bodypart1', 'bodypart2'], |
59 | | -# 'group2': ['bodypart3']} |
| 77 | +# 'head': ['nose', 'ear_L', 'ear_R', 'neck'], |
| 78 | +# 'body': ['center']} |
60 | 79 | # |
61 | 80 | # grouping body parts together can be useful if you want to assess |
62 | 81 | # moving/non moving only for a subset of body parts, e.g., for all |
|
68 | 87 | # |
69 | 88 | # uncomment if you want to separate the analysis into time intervals: |
70 | 89 | # |
71 | | -# time_intervals = { |
72 | | -# 'interval1': [0, 2499], # in frames |
73 | | -# 'interval2': [2500, 12499], # in frames |
74 | | -# 'interval3': [12500, 17000]} # in frames |
| 90 | +time_intervals = { |
| 91 | + 'pre-shock': [0, 7200], # in frames |
| 92 | + 'after_shock1': [7200, 11050], # in frames |
| 93 | + 'after_shock2': [11051, 14700], |
| 94 | + 'after_shock3': [14701, 17500]} # in frames |
75 | 95 | # |
76 | 96 | # note: if you define time intervals, the analysis will be additionally performed for each |
77 | 97 | # interval separately; the results will be saved in separate CSV files for each interval; |
|
177 | 197 | #fig, ax = plt.subplots(2, 1, figsize=(12, 8), sharex=True) |
178 | 198 | ax[0].plot(frames_array,x, label=body_part+' x', c=colors[body_part_i]) |
179 | 199 | ax[0].plot(frames_array,y, label=body_part+' y', c=colors[body_part_i], alpha=0.5) |
180 | | - ax[1].plot(velocity, label=body_part, c=colors[body_part_i]) |
| 200 | + if bodypart_not_to_plot is not None: |
| 201 | + if body_part not in bodypart_not_to_plot: |
| 202 | + ax[1].plot(velocity, label=body_part, c=colors[body_part_i]) |
| 203 | + |
181 | 204 | # indicate with a shaded area the frames where the body part is moving; to do so, filter for consecutive True values: |
182 | 205 | moving_frames = velocity_df[body_part + '_moving'] |
183 | 206 | moving_frames_diff = np.diff(moving_frames.astype(int)) |
|
224 | 247 | ax[1].axhline(movement_threshold, color='r', linestyle='--', label=f'movement threshold\n({movement_threshold} {unit_snippet}/s)') |
225 | 248 | ax[1].legend(loc='upper right') |
226 | 249 | ax[1].set_xlim(0, len(velocity_df)) |
| 250 | + if ylim is not None: |
| 251 | + ax[1].set_ylim(0, ylim) |
227 | 252 | # change y-axis to log scale: |
228 | 253 | #ax[1].set_yscale('log') |
229 | 254 | ax[1].set_title(f"body parts movement velocity $v=\\sqrt{{v_x^2 + v_y^2}}$, with $v_{{x/y}}=\\frac{{\\Delta x/y}}{{\\Delta t}}$") |
|
0 commit comments