Otolith shape contour analysis

Otra vez tratando de ajustar los contornos de los otolitos de jurel. Aunque en R-project quizás sea más fácil, miren el libro Morphometrics with R para varios ejemplos utilizando elipticas de fourier,  ya llevo un tiempo realizandolo en Matlab©.  Les comparto parte de código…

Libro

%% Read data
clear
clc

path = ('home\jquiroz\Documents\Proyectos\FIP_2007_27 \analisis\Data Fourier\@COQUIMBO');
cd(path)
files = dir(fullfile('home\jquiroz\Documents\Proyectos\FIP_2007_27\analisis\Data Fourier\','\@COQUIMBO\*.txt'));

%% Fourier
for i = 1: length(files)
 outline = textread(char(files(i).name));
 iNoOfHarmonicsAnalyse = 100;
 bNormaliseSizeState = 0; % (T=1 - F=0)
 bNormaliseOrientationState = 0; % (T=1 - F=0)
 rFSDs(:,:,i) = fEfourier(outline, iNoOfHarmonicsAnalyse, bNormaliseSizeState, bNormaliseOrientationState);
end

%% Recontruc
for i = 1: length(files)
 iNoOfHarmonicsReconstruct = 50;
 iNoOfPointsReconstruct = 100;
 outln(:,:,i) = rEfourier(rFSDs(:,:,i), iNoOfHarmonicsReconstruct,iNoOfPointsReconstruct);
end

figure
for i=1:8
 subplot(3,3,i)
 outline = textread(char(files(i).name));
 plot(outline(:,1),outline(:,2),'-r'); hold on;
 plot(outln(:,1,i),outln(:,2,i),'--k')
 set(gca,'DataAspectRatio',[1 1 1],'PlotBoxAspectRatio',[1 1 1],...
 'XTickLabel',{'0.1';'0.5';'1'},'YTickLabel',{'0.1';'0.5';'1';'1.5'})
end
%% Plot 1

clear X XX Y YY
X = outln(:,1,1);
Y = outln(:,2,1);
for i = 1: length(files)-1
 X = [X outln(:,1,i+1)]; Y = [Y outln(:,2,i+1)];
end

XX = mean(X');
YY = mean(Y');
plot([XX XX(1)],[YY YY(1)],'-k','LineWidth',2);

%% discriminant analysis

nFDs = 50;
for i = 1: length(files)
 tmp = rFSDs(:,1:nFDs,i)';
 analy(:,i) = tmp(:);
end

%% PLot 2

n = [0.05 0.10 0.50 1]*iNoOfHarmonicsAnalyse;
color = {'r','k','m','g'};
p= 1; % otolito
outline_s = textread(char(files(p).name));

for i=1:length(n)
 iNoOfHarmonicsReconstruct = n(i);
 iNoOfPointsReconstruct = 100;
 outlnn = rEfourier(rFSDs(:,:,p), iNoOfHarmonicsReconstruct,iNoOfPointsReconstruct);
 hold on; plot(outline_s(:,1),outline_s(:,2),':k',outlnn(:,1),outlnn(:,2),'--rs',...
 'LineWidth',1,'MarkerEdgeColor','k','MarkerFaceColor',...
 char(color(i)),'MarkerSize',3);
 hold off
end

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s