function [amyg,sphere,amygsphere]=CREATEenclosedamyg2(vol,surf);
%
% [amyg,sphere,amygsphere]=CREATEenclosedamyg(vol,surf);
%  amyg:           49 x 49 x 49 cube containing an amygdala, 
%  then the centroide in 25,25,25
%  sphere:          49 x 49 x 49 cube containing a sphere
%  amygsphere: 49 x 49 x 49 cube containing both the amygdala and the sphere
%CENTERED in centroid


%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
rin=17;
rout=25;
dime=2*rout-1;

sphere=ones(dime,dime,dime);

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


amyg=zeros(dime,dime,dime);


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));
amyg=vol((c(2)-rout+1):(c(2)+rout-1),(c(1)-rout+1):(c(1)+rout-1),(c(3)-rout+1):(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,:)))


