function [amyg,sphere,amygsphere]=CREATEenclosedamyg(vol,surf);
% The function encloses the binary object and assign the value 1 for the
% object and the enclosing sphere -1. 
%
% [amyg,sphere,amygsphere]=CREATEenclosedamyg(vol,surf);
%  amyg:           50 x 50 x 50 cube containing an amygdala
%  sphere:         50 x 50 x 50 cube containing a sphere
%  amygsphere: 50 x 50 x 50 cube containing both the amygdala and the sphere
%
%
% (C) Moo K. Chung, 2008
%     mkchung@wisc.edu
% University of Wisconsin-Madison

%figure;imagesc(squeeze(vol(c(2),:,:)))
%figure;imagesc(squeeze(vol(:,c(1),:)))
%figure;imagesc(vol(:,:,c(3)))
% WARNING: dimension has been swapped between surface vertex and voxel
% position

% maximum radius of the sphere
%rin=17;
rin=23;
rout=25; %center

sphere=ones(2*rout,2*rout,2*rout);

for i=1:2*rout
    for j=1:2*rout
        for k=1:2*rout
            if (i-rout)^2 + (j-rout)^2 + (k-rout)^2 <rin^2
                sphere(i,j,k)=0;
            end;
        end;
    end;
end;
%figure;imagesc(sphere(:,:,rout)); colorbar


amyg=zeros(2*rout,2*rout,2*rout);
c=round(mean(surf.vertices));
amyg=vol((c(2)-rout):(c(2)+rout-1),(c(1)-rout):(c(1)+rout-1),(c(3)-rout):(c(3)+rout-1));
%figure;imagesc(amyg(:,:,rout)); colorbar

%amygsurf = isosurface(amyg)
amyg=double(amyg);
amygsphere=amyg-sphere;


%figure;imagesc(squeeze(amygcube(:,rout,:)))
%figure;imagesc(squeeze(cube(:,rout,:)))



