forked from nickjhughes/feature-map-stats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pinw_density.m
30 lines (23 loc) · 844 Bytes
/
pinw_density.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
function [density_per_pixel, density_per_wl] = pinw_density(op, mask)
%PINW_DENSITY Calculate the pinwheel density of an orientation preference map.
%
% [density_per_pixel, density_per_wl] = pinw_density(op, mask)
%
% Calculates the average number of pinwheels either per pixel or per square
% map wavelength. The average map wavelength is computed using the map's
% Fourier spectrum. A binary mask can be given to restrict the analysis.
% Input defaults
if nargin < 2
mask = true(size(op));
end
% Calculate OP wavelength
op_wl = mean([fourier_wavelength(real(op)), fourier_wavelength(imag(op))]);
% Mask
op(~mask) = nan;
% Find pinwheels in OP map
pinw = locate_pinwheels(op);
npinw = size(pinw,1);
% Calculate per pixel
density_per_pixel = npinw/sum(mask(:));
% Calculate per wavelength
density_per_wl = density_per_pixel*op_wl^2;