function mask = circular_mask(width, inset, lims_vert, lims_hor)
% TODO - description
% Makes logical array - circular mask
% used in recon.Reconstruction

% lims_x and lims_y are optional, but if supplied, both have to be defined
% lims_x and lims_y are vectors with 2 elements - indices of start and end
% in x and y direction

% TODO - switch x and y?
% TODO - move to +post, or some other package?
% TODO - check inputs

if nargin < 3
    lims_vert = [1, width];
    lims_hor = [1, width];
end
% create x-y meshgrid
[x ,y] = meshgrid(lims_vert(1):lims_vert(2), ...
                  lims_hor(1):lims_hor(2));
% create 2D circular mask
radius = width/2;
if nargin >= 2
    radius = radius - inset;
end
mask = sqrt((x - (width + 1)/2).^2 + (y - (width + 1)/2).^2) < radius;
mask = mask'; % needs to be transposed % TODO - make it so transposing is not needed
end

