-
Notifications
You must be signed in to change notification settings - Fork 0
/
Licking_Chewing_Phase_Analysis_20230821.m
46 lines (35 loc) · 1.35 KB
/
Licking_Chewing_Phase_Analysis_20230821.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
% This script is for analyzing phase relationship between chewing ans
% licking
TongueAreas = S.areas;
JawHeights = S.Jaw_heights;
JawHeights = double(JawHeights);
%% Apply Filters to Jaw Trace
samplingRate = 350;
setpointCutoff = 1; % Minimum frequency
lowpassCutoff = 15; % Maximum frequency
filterOrder = 3;
% Setpoint
[bh, ah] = butter(filterOrder, setpointCutoff / (samplingRate / 2), 'low');
JawHeightsSetpoint = filtfilt(bh, ah, JawHeights);
% Lowpass
[bl, al] = butter(filterOrder, lowpassCutoff / (samplingRate / 2), 'low');
JawHeightsLowpass = filtfilt(bl, al, JawHeights);
JawHeightsFiltered = (JawHeightsLowpass - JawHeightsSetpoint)';
%% Apply Filters to Tongue Trace
% Removing setpoint from licking trace seems to introduce artifact to the trace.
% Applying a lowpass filter creates artificial dips during the unseen licking period.
% These dips do not appear to introduce strange artifact.
% Lowpass
[bl, al] = butter(filterOrder, lowpassCutoff / (samplingRate / 2), 'low');
TongueAreasFiltered = filtfilt(bl, al, TongueAreas);
%% Plot to Test Filtering
plot(JawHeightsFiltered)
hold on
plot(TongueAreasFiltered*0.02)
%% Phase
% This part works fine. Just need to apply this during the licking period.
ChewingPhase = angle(hilbert(JawHeightsFiltered));
LickingPhase = angle(hilbert(TongueAreasFiltered));
plot(ChewingPhase)
hold on
plot(LickingPhase)