-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyze_body_motion_energy_distributions.m
71 lines (62 loc) · 2.85 KB
/
analyze_body_motion_energy_distributions.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
% analyze_body_motion_energy_distributions.m
%
% Description:
% This script compares the distributions of motion energy between two trial
% types, RVT and RV, across multiple probe recordings. For each probe, it
% aggregates motion energy values during periods of active motion, enabling
% comparison of the motion profiles between different conditions.
%
% Analysis Workflow:
% 1. **Data Loading and Selection**:
% - Loads motion energy data for each probe across two trial types:
% RVT (and RVT with gain up) and RV (and RV with gain up).
% - Extracts motion energy values during treadmill motion periods within
% each trial type.
%
% 2. **Distribution Comparison**:
% - Aggregates motion energy data across all trials within each trial type
% for each probe.
% - Plots histograms of motion energy distributions for RVT and RV trial
% types side-by-side, enabling visual comparison.
% - Computes and displays the median motion energy for each trial type
% within each probe.
%
% Outputs:
% - Histograms for each probe, comparing the motion energy distributions
% for RVT and RV trial types.
% - Printed summary statistics showing the median motion energy for RVT and
% RV trials per probe, providing a concise numerical comparison.
%
% Usage:
% Specify the `trial_types` and `probe_ids` variables as needed, then run
% the script to analyze and visualize motion energy distributions for each
% probe across conditions.
% trial_types = {'RVT_gain_up', 'RV_gain_up'}; %{'RVT', 'RV'};
trial_types = {{'RVT', 'RVT_gain_up'}, {'RV', 'RV_gain_up'}};
ctl = RC2Analysis();
% probe_ids = ctl.get_probe_ids('mismatch_nov20', 'mismatch_jul21');
probe_ids = ctl.get_probe_ids('visual_flow', 'mismatch_nov20', 'mismatch_jul21');
figure(1)
for probe_i = 1 : length(probe_ids)
data = ctl.load_formatted_data(probe_ids{probe_i});
distribution_RVT = [];
trials = data.get_trials_with_trial_group_label(trial_types{1});
for trial_i = 1 : length(trials)
trial = trials{trial_i}.to_aligned;
distribution_RVT = cat(1, distribution_RVT, trial.camera1(trial.motion_mask));
end
distribution_RV = [];
trials = data.get_trials_with_trial_group_label(trial_types{2});
for trial_i = 1 : length(trials)
trial = trials{trial_i}.to_aligned;
distribution_RV = cat(1, distribution_RV, trial.camera1(trial.motion_mask));
end
subplot(length(probe_ids), 1, probe_i)
histogram(distribution_RVT)
hold on
histogram(distribution_RV)
legend('RVT', 'RV')
title(sprintf(probe_ids{probe_i}))
sprintf('Probe: %s, Median RVT: %.2f', probe_ids{probe_i}, median(distribution_RVT))
sprintf('Median RV: %.2f', median(distribution_RV))
end