function figNum = initfigvol(V,Num,nbcoupe)

%screenSize = get(0,'ScreenSize')  -> 1 1 1024 768

	oldFigNumber=watchon;
   figNum =figure( ...
        'Name','affichage maison', ...
        'Units','Pixel', ...
        'Position',[2 155 568 568], ...
        'NumberTitle','off');
   colordef(figNum,'black');
   colormap(gray);

h0=figNum;

   axes('unit','pixel','Position',[29   80  482  482]);
   
   set(gcf,'position',[2 100  623 623]);
   
%   [left bottom width height]


%====================================
 % The PLUS  Moins buttons
    uicontrol( ...
        'Style','pushbutton', ...
        'Units','normalized', ...
        'Position',[0.85 0.89 0.05 0.05], ...
        'String','+', ...
        'Interruptible','on', ...
        'Callback','affichevol(1,''Plus'');');

    uicontrol( ...
        'Style','pushbutton', ...
        'Units','normalized', ...
        'Position',[0.91 0.89 0.05 0.05], ...
        'String','-', ...
        'Callback','affichevol(1,''Moins'')');

if exist('nbcoupe'),nz = nbcoupe; else,nz = size(V,3);end

str = ['/' num2str(nz)];

   hdl.txtcoupe = uicontrol( ...
	'Units','normalized', ...
	'ListboxTop',1, ...
	'Position',[0.91 0.955 0.061 0.03], ...
	'HorizontalAlignment','left',...
	'Style','text', ...
	'string', str,...
	'HorizontalAlignment', 'center',...
	'Tag','StaticText2');
    
   hdl.txt_editcoupe = uicontrol( ...
	'Units','normalized', ...
	'ListboxTop',1, ...
	'Position',[0.85 0.95 0.061 0.04], ...
	'HorizontalAlignment','left',...
	'Style','edit', ...
	'HorizontalAlignment', 'center',...
	'Tag','StaticText2', ...
        'Callback','affichevol(1,''go2coupe'')');

 %######################################################################
 % The Tpos handel buttons
 %######################################################################


%===================================
%The ROI buton

hdl.roi_draw ...
	= uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'ListboxTop',0, ...
	'Position',[0.55 0.96 0.03 0.03], ...
	'Style','checkbox', ...
	'Callback','affichevol(3,''ROI_draw'')');

    h1  = uicontrol('Parent',figNum, ...
	'Units','normalized', ...
        'Position',[0.6 0.96 0.1 0.03], ...
	'HorizontalAlignment','left',...
	'Style','text', ...
        'String','ROI draw',...
	'Tag','StaticText2');

%===================================

    %====================================
   % The CLOSE button
    
    uicontrol( ...
        'Style','push', ...
        'Units','normalized', ...
        'position',[0.92 0 0.08 0.08], ...
        'string','Close', ...
        'call','affichevol(1,''fermer'')');
     
          
    %====================================
    %the COLOR slice bar
    
hdl.slide_max = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[0.7 0.7 0.7], ...
	'Callback','affichevol(1,''slide'')', ...
	'ListboxTop',0, ...
	'Position',[0.1 0.07 0.3 0.025], ...
	'Style','slider', ...
	'Tag','Slider1');

hdl.slide_mean = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[0.7 0.7 0.7], ...
	'Callback','affichevol(1,''slide_mean'')', ...
	'ListboxTop',0, ...
	'Position',[0.1 0.04 0.3 0.025], ...
	'Style','slider', ...
	'Tag','Slider2');
	
hdl.slide_min = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[0.7 0.7 0.7], ...
	'Callback','affichevol(1,''slide'')', ...
	'ListboxTop',0, ...
	'Position',[0.1 0.01 0.3 0.025], ...
	'Style','slider', ...
	'Tag','Slider2');


hdl.edit_min = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[0.7 0.7 0.7], ...
	'ListboxTop',0, ...
	'Position',[0.03 0.03 0.05 0.03], ...
	'Style','text', ...
	'Tag','EditText1');

hdl.edit_max = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[0.7 0.7 0.7], ...
	'ListboxTop',0, ...
	'Position',[0.43 0.03 0.05 0.03], ...
	'Style','text', ...
	'Tag','EditText2');

h1 = uicontrol('Parent',h0, ...
	'Units','normalized', ...
	'BackgroundColor',[0.7 0.75 0.7], ...
	'Callback','affichevol(1,''colorlim_init'')', ...
	'ListboxTop',0, ...
	'Position',[0.5 0.01 0.04 0.03], ...
	'String','ini', ...
	'Tag','Pushbutton1');


    %====================================
    %initialisation image
    
    hdl.Im =imagesc(V(:,:,1),'EraseMode','none');
    set(gca,'ydir','normal');

    hdl.Num  = Num;
    hdl.Pos = 0;  
    hdl.Bw   = 0 ;  hdl.Cont=0;
    hdl.grill = 0;
    
    hold on
    if size(V,1)==64
       hdl.Pos = plot(0,0,'.g','MarkerSize',10,'eraseMode','none');
       hdl.Cont = plot(0,0,'.r','markerSize',4,'eraseMode','none');
    else       
       hdl.Pos = plot(0,0,'.g','MarkerSize',5,'eraseMode','none');
       hdl.Cont = plot(0,0,'.r','MarkerSize',1,'eraseMode','none');
    end
    
    hdl.Clus = plot(0,0,'or','MarkerSize',4,'eraseMode','none');
    


    set(figNum,'Visible','on', ...
        'UserData',hdl,'tag','affichevol');
     
     watchoff(oldFigNumber);
    figure(figNum);
        
    %====================================
    %====================================
%%%%%%%%%%%    UIMENU      %%%%%%%%%%%%%%%%%%%%%%%%    
    
   colormenuh = uimenu(gcf,'label','psss');
    uimenu(colormenuh,'label','debug','callback', 'affichevol(1,''Voyons'')');

%    menuh2 = uimenu(gcf,'label','Segm');
    
%    uimenu(menuh2,'label','Hist','callback','affichevol(2,''Hist'')');
%    uimenu(menuh2,'label','Seg','callback','affichevol(2,''Seg'')');
%    uimenu(menuh2,'label','mask->ROI','callback','affichevol(2,''Bw2Pos'')');
%    uimenu(menuh2,'label','LoadMask','callback','affichevol(2,''LoadMask'')');
% %    uimenu(menuh2,'label','SaveBw','callback','affichevol(2,''SaveBw'')');
%%    uimenu(menuh2,'label','LoadBw','callback','affichevol(2,''LoadBw'')');
%    uimenu(menuh2,'label','close mask','callback','affichevol(2,''CleanCont&Bw'')');
 
    menuh3 = uimenu(gcf,'label','ROI');

    uimenu(menuh3,'label','point by point','callback','affichevol(3,''ChoisiPos'')');
    uimenu(menuh3,'label','clean the selection','callback','affichevol(3,''clean_SelectPos'')');
    uimenu(menuh3,'label','load ROI','callback','affichevol(3,''loadPos'')');
    uimenu(menuh3,'label','Save ROI','callback','affichevol(3,''SavePos'')');
%    uimenu(menuh3,'label','ROI->mask','callback','affichevol(3,''ROItomask'')');
    uimenu(menuh3,'label','clear ROI','callback','affichevol(3,''CleanPos'')');
 
    visu    = uimenu(menuh3,'label','color or size','callback','affichevol(1,''visu_Pos'')');
 
    uimenu(visu,'label',' size','callback','affichevol(1,''visu_Pos_size'')');
    uimenu(visu,'label','color ','callback','affichevol(1,''visu_Pos_color'')');


    menuh2 = uimenu(gcf,'label','graph');
    uimenu(menuh2,'label','zoom','callback', 'zoom');
    menu_orient = uimenu(menuh2,'label','orient');
      uimenu(menu_orient,'label','axial','callback', 'affichevol(1,''orient_axial'')');
      uimenu(menu_orient,'label','coronal','callback', 'affichevol(1,''orient_coronal'')');
      uimenu(menu_orient,'label','sagittal','callback', 'affichevol(1,''orient_sagittal'')');
    color_m = uimenu(menuh2,'label','color');
   
%    menuh5 = uimenu(gcf,'label','Decours');
%    uimenu(menuh5,'label','init','callback','affichevol(5,''init'')');

maps = str2mat('gray','hsv','hot','pink','cool','bone','jet','copper','flag','prism');
colormenuh = uimenu(color_m,'label','colormaps');
    uimenu(color_m,'label','AutoLim','callback','affichevol(1,''Autolim'')');
    uimenu(color_m,'label','colorbar','callback','affichevol(1,''colorbar'')');

for k = 1:size(maps,1);
   uimenu(colormenuh,'label',maps(k,:),'callback',['colormap(' maps(k,:) ');']);
end

uimenu(colormenuh,'label','rand', 'callback','colormap(rand(lengthofmap,3))');

uimenu(colormenuh,'label','brighten','callback','brighten(.25)');
uimenu(colormenuh,'label','darken','callback','brighten(-.25)');

uimenu(colormenuh,'label','inverse','callback','colormap(flipud(colormap))');
uimenu(colormenuh,'label','fliplr','callback','colormap(fliplr(colormap))');
uimenu(colormenuh,'label','permute', ...
   'callback','c = colormap; colormap(c(:,[2 3 1]))');

uimenu(colormenuh,'label','spin','callback','spinmap');

uimenu(colormenuh,'label','remember','callback','affichevol(1,''remember'')');

uimenu(colormenuh,'label','restore', ...
   'callback','affichevol(1,''restore'')');


%uimenu(colormenuh,'label','done','Callback',...
%       'delete(colormenuh);clear stackofmaps lengthofmap maps colormenuh k');

    
    

