⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 landmarksvol.m

📁 mri_toolbox是一个工具用来MRI. 来自于SourceForge, 我上传这个软件,希望能结识对医疗软件感兴趣的兄弟.
💻 M
📖 第 1 页 / 共 3 页
字号:
    data=get(gcf,'Userdata');
    t=linspace(0,2*pi,100); 
    % in x
    radio=sqrt( data.radio^2 - (data.x-data.center(1) )^2 );
    y=radio*sin(t)+data.center(2); z=radio*cos(t)+data.center(3);
    axes(data.hxcte),
    hold on, plot(z,y,'.-'), plot(data.center(3),data.center(2),'*'), hold off
    
    % in y
    radio=sqrt( data.radio^2 - (data.y-data.center(2) )^2 );
    y=radio*sin(t)+data.center(1); z=radio*cos(t)+data.center(3);
    axes(data.hycte),
    hold on, plot(z,y,'.-'), plot(data.center(3),data.center(1),'*'),  hold off

    % in z
    radio=sqrt( data.radio^2 - (data.y-data.center(3) )^2 );
    y=radio*sin(t)+data.center(1); z=radio*cos(t)+data.center(2);
    axes(data.hzcte),
    hold on, plot(z,y,'.-'), plot(data.center(2),data.center(1),'*'), hold off

    
    
case 'updatecenter'
   data=get(gcf,'Userdata');
   data.x=round(data.center(1)); data.y=round(data.center(2)); data.z=round(data.center(3)); 
   set(data.hsliderx,'Value',data.x)
   set(data.hslidery,'Value',data.y)
   set(data.hsliderz,'Value',data.z)
   set(data.hedit,'String',num2str(double(data.vol(data.x,data.y,data.z))));
   pinta_data_puntoxyz(data)
   set(data.hfig,'UserData',data); 
   
    
case 'selectslp',
    data=get(gcf,'UserData');
    set(data.hfig,'WindowButtonMotionFcn','');
    deltaint=ana_header_io(data.header,-2);
    Np=sum(data.vol(:)==13); 
    mystring=['Points Interdistance (slices)', blanks(2),'Dx =',num2str(deltaint(1)),blanks(2),'Dy =',num2str(deltaint(2)),blanks(2),'Dz =',num2str(deltaint(3))];
    myhelp=helpdlg({['Number of solution points =',num2str(Np)],mystring},'Current Grid of solution');
    
    dlgTitle=' (Re-) Computation of the Grid of Solution Points ';
    prompt={[' Interdistance  in X direction (current value =', num2str(deltaint(1)),' )' ],...
            [' Interdistance  in Y direction (current value =', num2str(deltaint(2)),' )' ],...
            [' Interdistance  in Z direction (current value =', num2str(deltaint(3)),' )' ],...
            [' Defining isolated points. Number of neighbors smaller than:']};
    def={num2str(deltaint(1)),num2str(deltaint(2)),num2str(deltaint(3)),'1 to 6'};
    lineNo=1;
    otravez=1; 
    while otravez,
        estabien=0;
        dimelo=inputdlg(prompt,dlgTitle,lineNo,def); 
        %delta=deltaint;
        if ~isempty(dimelo),
            delta(1)=round(str2num(deblank(char(dimelo(1)))));
            delta(2)=round(str2num(deblank(char(dimelo(2)))));
            delta(3)=round(str2num(deblank(char(dimelo(3)))));
            Nmin=round(str2num(deblank(char(dimelo(4)))));
            estabien=isinrang(delta(1),[1,round(data.nx/2)]) &...
                     isinrang(delta(2),[1,round(data.ny/2)]) &...
                     isinrang(delta(3),[1,round(data.nz/2)])  &...
                     isinrang(Nmin,[1,6]);
        end
        otravez=(~isempty(dimelo) ) &  (~estabien );
    end
    if ~isempty(dimelo),
        deltaint=delta,
        VolOut=select_slp_in_vol(data.vol,deltaint(1),deltaint(2),deltaint(3),Nmin);
        Np=sum(VolOut(:)==13); 
        button = questdlg(['There are ',num2str(Np),' solution points. Do you accept this grid?' ],'New Grid Computation Results','Yes','No','No');
        if strcmp(button,'Yes')
            data.vol=VolOut;
            data.header=ana_header_io(data.header,2,deltaint);
            data.volchanged=1;
            set(data.hsaveimage,'Enable','on')
            data.min=min(data.vol(:));
            data.max=max(data.vol(:));
            set(data.hfig,'UserData',data); 
        end
    end
    close(myhelp)
    set(data.hfig,'WindowButtonMotionFcn','landmarksvol(''movimiento'')',...
        'Interruptible','on');      
    
otherwise
    myerror('Option not available')
end

function pinta_data_puntox(data)
axes(data.hxcte),
h=imshow(squeeze(data.vol(data.x,:,:)),[data.min, data.max]); hold on
%colormap(jet(256))
%h=imagesc(squeeze(data.vol(data.x,:,:)),[data.min, data.max]);
%set(h,'EraseMode','background');
scatter(data.z,data.y,'+','r','filled'), hold off
set(data.hxcte,'Xtick',[],'Ytick',[],'Ztick',[],'Box','on')   
title(['X = ',num2str(data.x)])

function pinta_data_puntoy(data)
axes(data.hycte),
h=imshow(squeeze(data.vol(:,data.y,:)),[data.min, data.max]); hold on
%colormap(jet(256))
%h=imagesc(squeeze(data.vol(:,data.y,:)),[data.min, data.max]);
%set(h,'EraseMode','background');
scatter(data.z,data.x,'+','r','filled'), hold off
set(data.hycte,'Xtick',[],'Ytick',[],'Ztick',[],'Box','on')   
title(['Y = ',num2str(data.y)])

function pinta_data_puntoz(data)
axes(data.hzcte)
h=imshow(squeeze(data.vol(:,:,data.z)),[data.min, data.max]); hold on
%colormap(jet(256))
%h=imagesc(squeeze(data.vol(:,:,data.z)),[data.min, data.max]);
%set(h,'EraseMode','background');
scatter(data.y,data.x,'+','r','filled'), hold off
set(data.hzcte,'Xtick',[],'Ytick',[],'Ztick',[],'Box','on')   
title(['Z = ',num2str(data.z)])

function pinta_data_puntoxyz(data)
pinta_data_puntox(data)
pinta_data_puntoy(data)
pinta_data_puntoz(data)
drawnow

function data=nuevovolumen(data,argu)
[data.nx,data.ny,data.nz]=size(data.vol);
data.x=round(data.nx*0.5);
data.y=round(data.ny*0.5);
data.z=round(data.nz*0.5);
data.center=[data.x,data.y,data.z];
data.max=max(data.vol(:));
data.min=min(data.vol(:));
data.fileout='No file selected';
data.volchanged=0;


function data=actualiza_sliders(data)
set(data.hsliderx,'Min',1,'Max',data.nx,'SliderStep',[1/data.nx, 0.25],'Value',data.x)
set(data.hslidery,'Min',1,'Max',data.ny,'SliderStep',[1/data.ny, 0.25],'Value',data.y)
set(data.hsliderz,'Min',1,'Max',data.nz,'SliderStep',[1/data.nz, 0.25],'Value',data.z)

function data=new_sliders_pos(data)
set(data.hsliderx,'Value',data.x)
set(data.hslidery,'Value',data.y)
set(data.hsliderz,'Value',data.z)

function data=controla_mouse_point(data, cual)
switch cual,
case 1,
   if data.x<1, data.x=1; end
   if data.x>data.nx, data.x=data.nx; end
case 2,
   if data.y<1, data.y=1; end
   if data.y>data.ny, data.y=data.ny; end
case 3,
   if data.z<1, data.z=1; end
   if data.z>data.nz, data.z=data.nz; end
end

function [xi,yi]=myroipoly(axishandle)
[xi,yi] = getline(axishandle,'closed');

function [Inx,Iny,Inz]=DondeEsta(data);
% posicion de los ejes
posx=get(data.hxcte,'Position');
posy=get(data.hycte,'Position');
posz=get(data.hzcte,'Position');
% posicion del cursor
cp=get(data.hfig,'CurrentPoint');
x = cp(1,1);
y = cp(1,2);
Inx=(x>posx(1) & x<posx(1)+posx(3) & y>posx(2) & y<posx(2)+posx(4));
Iny=(x>posy(1) & x<posy(1)+posy(3) & y>posy(2) & y<posy(2)+posy(4));
Inz=(x>posz(1) & x<posz(1)+posz(3) & y>posz(2) & y<posz(2)+posz(4));
% over

function header=IsAnalize(data)
% creates a header to save in Analize format 

%[PATH,NAME,EXT,VER] = FILEPARTS(data.filein);
%filename=[PATH,'\',NAME];
%if exist([PATH,'\',NAME,'.img'])==2 & exist([PATH,'\',NAME,'.hdr'])==2, % Analize
   %[header,formato]=Read_Ana_Header([PATH,'\',NAME,'.hdr']);
   %else
   header=Init_Ana_Header;
   header.dime.dim(1)=4;  % number of dimensions
   header.dime.dim(2)=data.nx;    % pixels in X
   header.dime.dim(3)=data.ny;    % pixels in Y
   header.dime.dim(4)=data.nz;    % pixels in Z slices
   header.dime.dim(5)=1;    % number of time frames
   if data.max<=65535 & data.max>=256, 
      header.dime.bitpix=16;  % use uint16
   elseif data.max<=255, 
      header.dime.bitpix=8;    % use uint16
   else
      myerror( ' Unable to detect number of bit per pixel ');
   end
   %end

   
   function local_selectslp(pregunta)
   %scrsz = get(0,'ScreenSize');
   % the handle of the second figure 
   fh=figure('MenuBar','None','Units','Normalized','NumberTitle','off',...
       'DefaultUicontrolUnits','Normalized','Name',[blanks(20),'Volume & Grid Information'],...
       'Position',[0.4600    0.0534    0.3555    0.5391]);

   % copy the data to the new figure data
   set(fh,'UserData',data);
   
   % the Volume Information Part       
   %hvolinf=uicontrol(fh,'Style','frame','Position',[-0.0027472527472527475, 0.0024154589371980675,1,1]);
   hvolTitle=uicontrol(fh,'Style','text','String','Volume Information',...
       'Position',[-0.0027472527472527475,0.9323671497584539,1,0.06521739130434782],...
       'ForeGroundColor','Red');
   
   mystring=['Number of slices', blanks(5),'Nx =',num2str(data.nx),blanks(5),'Ny =',num2str(data.ny),blanks(5),'Nz =',num2str(data.nz)];
   hvolDim=uicontrol(fh,'Style','text','String',mystring,...
       'Position',[-0.0027472527472527475,0.8743961352657005,1,0.06521739130434782],...
       'ForeGroundColor','White','Fontsize',9,'FontWeight','bold');

   mystring=['Pixel sizes ',blanks(5), 'Sx =',num2str(data.header.dime.pixdim(2)),blanks(5),...
             'Sy =',num2str(data.header.dime.pixdim(3)),blanks(5),...
             'Sz =',num2str(data.header.dime.pixdim(4)),blanks(5), 'in ',data.header.dime.vox_units];
   hvolDim=uicontrol(fh,'Style','text','String',mystring,...
       'Position',[-0.0027472527472527475,0.8115942028985507,1,0.06521739130434782],...
       'ForeGroundColor','White','Fontsize',9,'FontWeight','bold');
   
   
   % the Grid Information Part       
   %hgridinf=uicontrol(fh,'Style','frame');
   hgridTitle=uicontrol(fh,'Style','text','String','Grid Information',...
       'Position',[-0.0027472527472527475,0.6666666666666666,1,0.06521739130434782],...
       'ForeGroundColor','Red');

   mystring=['Points Interdistance ', blanks(5),'Dx =',num2str(data.nx),blanks(5),'Dy =',num2str(data.ny),blanks(5),'Dz =',num2str(data.nz)];
   hgridDim=uicontrol(fh,'Style','text','String',mystring,...
       'Position',[-0.0027472527472527475,0.6038647342995169,1,0.06521739130434782],...
       'ForeGroundColor','White','Fontsize',9,'FontWeight','bold');
 
   mystring=[blanks(5), 'Number of solution points = ',num2str(sum(data.vol(:)==13)) ];
   hgridNslp=uicontrol(fh,'Style','text','String',mystring,...
       'Position',[-0.0027472527472527475,0.538647342995169,1,0.06521739130434782],...
       'ForeGroundColor','White','Fontsize',9,'FontWeight','bold');
   
   mystring=[blanks(5), 'Press here to (re) compute the Grid of solution points' ];
   hgridGrid=uicontrol(fh,'Style','pushbutton','String',mystring,...
       'Position',[-0.0027472527472527475,0.4492753623188406,1,0.06521739130434782],...
       'ForeGroundColor','White','Fontsize',9,'FontWeight','bold', 'callback','landmarksvol(''computegrid'')');
   uiwait(fh)
   
   
function local_compute_grid
data=get(gcf,'UserData');
deltaint=ana_header_io(data.header,-2);
dlgTitle=' (Re-) Computation of the Grid of Solution Points ';
prompt={[' Interdistance  in X direction (current value =', num2str(deltaint(1)),' )' ],...
        [' Interdistance  in Y direction (current value =', num2str(deltaint(2)),' )' ],...
        [' Interdistance  in Z direction (current value =', num2str(deltaint(3)),' )' ]};
def={num2str(deltaint(1)),num2str(deltaint(2)),num2str(deltaint(3))};
lineNo=1;
otravez=1; 
while otravez,
    estabien=0;
    dimelo=inputdlg(prompt,dlgTitle,lineNo,def); 
    %delta=deltaint;
    if ~isempty(dimelo),
        delta(1)=round(str2num(deblank(char(dimelo(1)))));
        delta(2)=round(str2num(deblank(char(dimelo(2)))));
        delta(3)=round(str2num(deblank(char(dimelo(3)))));
        estabien=isinrang(delta(1),[1,round(data.nx/2)]) & isinrang(delta(2),[1,round(data.ny/2)]) & isinrang(delta(3),[1,round(data.nz/2)]);
    end
    otravez=(~isempty(dimelo) ) &  (~estabien );
end
if ~isempty(dimelo),
    deltaint=delta;
    VolOut=select_slp_in_vol(data.vol,deltaint(1),deltaint(2),deltaint(3));
    data.vol=VolOut;
    data.volchanged=1;
    % copy to data to Main figure
    set(data.hfig,'UserData',data); 
end   
   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -