Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
%FIGURE_HISTOGRAM generate a simple barplot, showing the fraction of time
% spent in the inner vs outer areas of the arena WT vs MT.
%
% Friedrich Kretschmer
% Max-Planck Institute for Brain Research
% sciclist@brain.mpg.de
clear variables
arenaSize = 1000; %square size of arena in mm
%Define various zones
innerZone1 = [300, 300, 400, 400];
innerZone2 = [100, 100, 800, 800];
innerZone3 = [50, 50, 900, 900];
%Select zone to analyse in histogram
innerZone = innerZone1; %Select inner zone
fdir_wt = '/storage/scic/Data/External/People/Bea/set3/wt';
fdir_mt = '/storage/scic/Data/External/People/Bea/set3/gad';
fdir_result = '/storage/scic/Data/External/People/Bea/set3';
%Collect from all wildtype files
d = dir([fdir_wt, filesep, '*.mat']);
tInner_wt = nan(size(d,1), 1);
tOuter_wt = nan(size(d,1), 1);
animalNumber_wt = nan(size(d,1), 1);
for i = 1:size(d,1)
fileName = [fdir_wt, filesep, d(i).name];
s = whos('-file', fileName);
animalNumber_wt(i) = str2double(d(i).name(1:2));
if ismember('mousePos', {s.name})
load(fileName, 'mousePos', 'frameRate');
frameOnset = round(60*frameRate); %Start at 1min
frameOffset = round(660*frameRate); %Stop at 11min
[nInnerZone, nOuterZone] = getInnerOuter(mousePos(frameOnset:frameOffset,:), innerZone);
tInner_wt(i) = nInnerZone/frameRate;
tOuter_wt(i) = nOuterZone/frameRate;
end
end
%Collect from all mutant files
d = dir([fdir_mt, filesep, '*.mat']);
tInner_mt = nan(size(d,1), 1);
tOuter_mt = nan(size(d,1), 1);
animalNumber_mt = nan(size(d,1), 1);
for i = 1:size(d,1)
fileName = [fdir_mt, filesep, d(i).name];
s = whos('-file', fileName);
animalNumber_mt(i) = str2double(d(i).name(1:2));
if ismember('mousePos', {s.name})
load(fileName, 'mousePos', 'frameRate');
frameOnset = round(60*frameRate); %Start at 1min
frameOffset = round(660*frameRate); %Stop at 11min
[nInnerZone, nOuterZone] = getInnerOuter(mousePos(frameOnset:frameOffset,:), innerZone);
tInner_mt(i) = nInnerZone/frameRate;
tOuter_mt(i) = nOuterZone/frameRate;
end
end
tInner = [tInner_wt; tInner_mt];
tOuter = [tOuter_wt; tOuter_mt];
animalNumber = [animalNumber_wt; animalNumber_mt];
r_wt = tInner_wt./tOuter_wt;
r_mt = tInner_mt./tOuter_mt;
%Create plot
figure
bar(1:size(r_wt,1) , r_wt, 'k');
hold on
bar(size(r_wt, 1)+1:size(r_wt, 1)+size(r_mt, 1), r_mt, 'r');
legend({'Wildtype', 'Gad^{-/-}'});
set(gca,'Xtick',1:numel(animalNumber));
set(gca, 'XTickLabel', animalNumber);
ylabel ('Fraction of time spent in inner and outer area');
xlabel('Animal');
m = [animalNumber, tInner./tOuter];
%Save result
csvwrite([fdir_result, filesep, 'zone_', mat2str(innerZone), '_ratios.csv'], m);
saveas(gcf, [fdir_result, filesep, 'zone_', mat2str(innerZone), '_histogram.pdf']);