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

📄 dipplot.m

📁 含有多种ICA算法的eeglab工具箱
💻 M
📖 第 1 页 / 共 4 页
字号:
        axes('position', [0 0.5 0.5 .5]); dipplot(sourcesori, 'view', [0 0 1] , options{:}); axis off; if strcmpi(g.image, 'besa'), scalegca(0.1); end;        axes('position', [.5 .5 0.5 .5]); dipplot(sourcesori, 'view', [0 -1 0], options{:}); axis off; if strcmpi(g.image, 'besa'), scalegca(0.1); end;        axes('position', [0.5 0 0.5 0.5]);         %p = get(gcf, 'position');        %p(2) = p(2)+p(4)-800;        %p(4) = 800;        %p(3) = 800;        %set(gcf, 'position', p);        colorcount = 1;        if isfield(sources, 'component')            for index = 1:length(sources)                if index~=1                     if sources(index).component ~= sources(index-1).component                        textforgui(colorcount) = { sprintf(...             'Component %d (R.V. %3.2f)', sources(index).component, 100*sources(index).rv) };                        colorcount = colorcount+1;                    end;                else                     textforgui(colorcount) = { sprintf(...             'Component %d (R.V. %3.2f)', sources(index).component, 100*sources(index).rv) };                    colorcount = colorcount+1;                end;            end;            colorcount = colorcount-1;            allstr = strvcat(textforgui{:});            h = text(0,0.5, allstr);            if colorcount >= 15, set(h, 'fontsize', 8);end;            if colorcount >= 20, set(h, 'fontsize', 6);end;            if strcmp(BACKCOLOR, 'k'), set(h, 'color', 'w'); end;        end;        axis off;        return;    end;            % plot head graph in 3D    % ---------------------    if strcmp(g.gui, 'on')        figure;         pos = get(gca, 'position');        set(gca, 'position', [pos(1)+0.05 pos(2:end)]);    end;    plotimgs( dat, [1 1 1]);        set(gca, 'color', BACKCOLOR);    %warning off; a = imread('besaside.pcx'); warning on;    % BECAUSE OF A BUG IN THE WARP FUNCTION, THIS DOES NOT WORK (11/02)    %hold on; warp([], wy, wz, a);    % set camera target     % -----------------        % format axis (BESA or MRI)    axis equal;    set(gca, 'cameraviewanglemode', 'manual'); % disable change size    camzoom(1.2^2);    view(g.view);    %set(gca, 'cameratarget',   dat.zeroloc); % disable change size    %set(gca, 'cameraposition', dat.zeroloc+g.view*g.zoom); % disable change size    axis off;            % plot sphere mesh and nose    % -------------------------    SPHEREGRAIN = 20; % 20 is Matlab default    [x y z] = sphere(SPHEREGRAIN);    hold on;     [xx yy zz] = transcoords(x, y, z, dat.tcparams, dat.coreg);    if strcmpi(COLORMESH, 'w')        hh = mesh(xx, yy, zz, 'cdata', ones(21,21,3), 'tag', 'mesh'); hidden off;    else        hh = mesh(xx, yy, zz, 'cdata', zeros(21,21,3), 'tag', 'mesh'); hidden off;    end;    %x = x*100*scaling; y = y*100*scaling; z=z*100*scaling;    %h = line(xx,yy,zz); set(h, 'color', COLORMESH, 'linestyle', '--', 'tag', 'mesh');    %h = line(xx,zz,yy); set(h, 'color', COLORMESH, 'linestyle', '--', 'tag', 'mesh');    %h = line([0 0;0 0],[-1 -1.2; -1.2 -1], [-0.3 -0.7; -0.7 -0.7]);    %set(h, 'color', COLORMESH, 'linewidth', 3, 'tag', 'noze');        % determine max length if besatextori exist    % -----------------------------------------    sizedip = [];    for index = 1:length(sources)        sizedip = [ sizedip sources(index).momxyz(3) ];     end;    maxlength = max(sizedip);        % diph = gca; % DEBUG    % colormap('jet');    % cbar    % axes(diph);    for index = 1:length(sources)        nbdip = 1;        if size(sources(index).posxyz, 1) > 1 & any(sources(index).posxyz(2,:)) nbdip = 2; end;                % reorder dipoles for plotting        if nbdip == 2            if sources(index).posxyz(1,1) > sources(index).posxyz(2,1)                tmp = sources(index).posxyz(2,:);                sources(index).posxyz(2,:) = sources(index).posxyz(1,:);                sources(index).posxyz(1,:) = tmp;                tmp = sources(index).momxyz(2,:);                sources(index).momxyz(2,:) = sources(index).momxyz(1,:);                sources(index).momxyz(1,:) = tmp;            end;            if isfield(sources, 'active'),                nbdip = length(sources(index).active);            end;        end;                for dip = 1:nbdip                    x = sources(index).posxyz(dip,1);            y = sources(index).posxyz(dip,2);            z = sources(index).posxyz(dip,3);            xo = sources(index).momxyz(dip,1)*g.dipolelength;            yo = sources(index).momxyz(dip,2)*g.dipolelength;            zo = sources(index).momxyz(dip,3)*g.dipolelength;                        % copy for output            % ---------------            XX(index) = -y;            YY(index) = x;            ZZ(index) = z;            XO(index) = -yo;            YO(index) = xo;            ZO(index) = zo;                        if abs([x+xo,y+yo,z+zo]) >= abs([x,y,z])                xo1 = x+xo;                yo1 = y+yo;                zo1 = z+zo;            elseif strcmpi(g.pointout,'on')                xo1 = x-xo; % make dipole point outward from head center                yo1 = y-yo;                zo1 = z-zo;             else                xo1 = x+xo;                yo1 = y+yo;                zo1 = z+zo;            end            x = -x; xo1 = -xo1;             y = -y; yo1 = -yo1;             %            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% draw dipole bar %%%%%%%%%%%%%%%%%%%%%%%%%%%%%            %            tag = [ 'dipole' num2str(index) ];            [xx   yy   zz]   = transcoords(x,   y,   z,    dat.tcparams, dat.coreg);                         [xxo1 yyo1 zzo1] = transcoords(xo1, yo1, zo1,  dat.tcparams, dat.coreg);             if ~strcmpi(g.spheres,'on') % plot dipole direction lines               h1 = line( [xx xxo1]', [yy yyo1]', [zz zzo1]');            elseif g.dipolelength>0 % plot dipole direction cylinders with end cap patch              disp('Cannot plot bar with sphere');              %thetas = 180/pi*atan(sqrt((xxo1-xx).^2+(yyo1-yy).^2)./(zzo1-zz));              %for k=1:length(xx)              %  [cx cy cz] = cylinder([1 1 1],SPHEREGRAIN);              %  % rotate(h1,[yy(k)-yyo1(k) xxo1(k)-xx(k) 0],thetas(k));              %  cx = cx*g.spheresize/3 + xx(k);              %  cy = cy*g.spheresize/3 + yy(k);              %  cz = cz*g.dipolelength + zz(k);              %  caxis([0 33])              %  cax =caxis;              %  s1 = surf(cx,cy,cz);  % draw the 3-D cylinder              %  set(s1,'cdatamapping','direct','FaceColor','r'); % tries to make cylinder red - doesnt work!?!              %  p1  = patch(cx(end,:),cy(end,:),cz(end,:),cax(2)*ones(size(cz(end,:))));               %end            end            dipstruct.pos3d  = [xx yy zz];            % value used for fitting MRI            dipstruct.posxyz = sources(index).posxyz; % value used for other purposes            dipstruct.rv     = sprintf('C %d (%3.2f)',sources(index).component,...                                                             sources(index).rv*100);            if ~strcmpi(g.spheres,'on') % plot disk markers               set(h1,'userdata',dipstruct,'tag',tag,'color','k','linewidth',g.dipolesize/7.5);               if strcmp(BACKCOLOR, 'k'), set(h1, 'color', g.color{index}); end;            end                        %            %%%%%%%%%%%%%%%%%%%%%%%%%%%%% draw sphere or disk marker %%%%%%%%%%%%%%%%%%%%%%%%%            %            hold on;            if strcmpi(g.spheres,'on') % plot spheres                if strcmpi(g.projimg, 'on')                    tmpcolor = g.color{index} / 2;                    h = plotsphere([xx yy zz], g.dipolesize/6, 'color', g.color{index}, 'proj', ...                                   [-dat.maxcoord(3) dat.maxcoord(2) -dat.maxcoord(1)]*97/100, 'projcol', tmpcolor);                    set(h(2:end), 'userdata', 'proj', 'tag', tag);                else                    h = plotsphere([xx yy zz], g.dipolesize/6, 'color', g.color{index});                end;                                    set(h(1), 'userdata', dipstruct, 'tag', tag);            else % plot dipole markers               h = plot3(xx,  yy,  zz);                set(h, 'userdata', dipstruct, 'tag', tag, ...                   'marker', '.', 'markersize', g.dipolesize, 'color', g.color{index});            end            %            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% project onto images %%%%%%%%%%%%%%%%%%%%%%%%%            %            if strcmpi(g.projimg, 'on') & strcmpi(g.spheres, 'off')                tmpcolor = g.projcol{index};                                % project onto z axis                tag = [ 'dipole' num2str(index) ];                if ~strcmpi(g.image, 'besa')                    h = line( [xx xxo1]', [yy yyo1]', [-1 -1]'*dat.maxcoord(1));                    set(h, 'userdata', 'proj', 'tag', tag, 'color','k', 'linewidth', g.dipolesize/7.5);                end;                if strcmp(BACKCOLOR, 'k'), set(h, 'color', tmpcolor); end;                h = plot3(xx,  yy,  -dat.maxcoord(1));                 set(h, 'userdata', 'proj', 'tag', tag, ...                       'marker', '.', 'markersize', g.dipolesize, 'color', tmpcolor);                                % project onto x axis                tag = [ 'dipole' num2str(index) ];                if ~strcmpi(g.image, 'besa')                    h = line( [xx xxo1]', [1 1]'*dat.maxcoord(2), [zz zzo1]');                    set(h, 'userdata', 'proj', 'tag', tag, 'color','k', 'linewidth', g.dipolesize/7.5);                end;                if strcmp(BACKCOLOR, 'k'), set(h, 'color', tmpcolor); end;                h = plot3(xx,  dat.maxcoord(2),  zz);                 set(h, 'userdata', 'proj', 'tag', tag, ...                       'marker', '.', 'markersize', g.dipolesize, 'color', tmpcolor);                                % project onto y axis                tag = [ 'dipole' num2str(index) ];                if ~strcmpi(g.image, 'besa')                    h = line( [-1 -1]'*dat.maxcoord(3), [yy yyo1]', [zz zzo1]');                    set(h, 'userdata', 'proj', 'tag', tag, 'color','k', 'linewidth', g.dipolesize/7.5);                end;                if strcmp(BACKCOLOR, 'k'), set(h, 'color', tmpcolor); end;                h = plot3(-dat.maxcoord(3),  yy,  zz);                 set(h, 'userdata', 'proj', 'tag', tag, ...                       'marker', '.', 'markersize', g.dipolesize, 'color', tmpcolor);            end;            %            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% project onto axes %%%%%%%%%%%%%%%%%%%%%%%%%            %            if strcmpi(g.projlines, 'on')                                clear h;                % project onto z axis                tag = [ 'dipole' num2str(index) ];                h(1) = line( [xx xx]', [yy yy]', [zz -dat.maxcoord(1)]');                set(h(1), 'userdata', 'proj', 'linestyle', '--', ...                             'tag', tag, 'color', g.color{index}, 'linewidth', g.dipolesize/7.5/5);                                % project onto x axis                tag = [ 'dipole' num2str(index) ];                h(2) = line( [xx xx]', [yy dat.maxcoord(2)]', [zz zz]');                set(h(2), 'userdata', 'proj', 'linestyle', '--', ...                             'tag', tag, 'color', g.color{index}, 'linewidth', g.dipolesize/7.5/5);                                % project onto y axis                tag = [ 'dipole' num2str(index) ];                h(3) = line( [xx -dat.maxcoord(3)]', [yy yy]', [zz zz]');                set(h(3), 'userdata', 'proj', 'linestyle', '--', ...                             'tag', tag, 'color', g.color{index}, 'linewidth', g.dipolesize/7.5/5);                if ~isempty(g.projcol)                    set(h, 'color', g.projcol{index});                end;            end;            %                       %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% draw text  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%            %            if isfield(sources, 'component')                if strcmp(g.num, 'on')                    h = text(xx,  yy,  zz, [ '  ' int2str(sources(index).component)]);                    set(h, 'userdata', dipstruct, 'tag', tag, 'fontsize', g.dipolesize/2 );                    if ~strcmpi(g.image, 'besa'), set(h, 'color', 'w'); end;                end;            end;        end;    end;    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3-D settings    if strcmpi(g.spheres, 'on')        lighting phong;        material shiny;        camlight left;        camlight right;    end;        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% draw elipse for group of dipoles  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%        if ~isempty(g.std)        for index = 1:length(g.std)            if ~iscell(g.std{index})                plotellipse(sources, g.std{index}, 1, dat.tcparams, dat.coreg);            else                sc = plotellipse(sources, g.std{index}{1}, g.std{index}{2}, dat.tcparams, dat.coreg);                if length( g.std{index} ) > 2                    set(sc, g.std{index}{3:end});                end;            end;        end;    end;    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% buttons %%%%%%%%%%%%%%%%%%%%%%%%%%%%%    nbsrc = int2str(length(sources));    cbmesh = [ 'if get(gcbo, ''userdata''), ' ...               '    set(findobj(''parent'', gca, ''tag'', ''mesh''), ''visible'', ''off'');' ...               '    set(gcbo, ''string'', ''Mesh on'');' ...               '    set(gcbo, ''userdata'', 0);' ...               'else,' ...               '    set(findobj(''parent'', gca, ''tag'', ''mesh''), ''visible'', ''on'');' ...               '    set(gcbo, ''string'', ''Mesh off'');' ...               '    set(gcbo, ''userdata'', 1);' ...               'end;' ];    cbview = [ 'tmpuserdat = get(gca, ''userdata'');' ...             'if tmpuserdat.axistight, ' ...             '    set(gcbo, ''string'', ''Tight view'');' ...             'else,' ...             '    set(gcbo, ''string'', ''Loose view'');' ...             'end;' ...             'tmpuserdat.axistight = ~tmpuserdat.axistight;' ...             'set(gca, ''userdata'', tmpuserdat);' ...             'clear tmpuserdat;' ...             'dipplot(gcbf);' ];    viewstyle  = fastif(strcmpi(dat.mode, 'besa'), 'text', 'pushbutton');    viewstring = fastif(dat.axistight, 'Loose view', 'Tight view');        h = uicontrol( 'unit', 'normalized', 'position', [0 0 .15 .05], 'tag', 'tmp', ...                  'style', 'pushbutton', 'string', 'Top view', 'callback', 'view([0 0 1]);');    h = uicontrol( 'unit', 'normalized', 'position', [0 0.05 .15 .05], 'tag', 'tmp', ...                  'style', 'pushbutton', 'string', 'Coronal view', 'callback', 'view([0 -1 0]);');    h = uicontrol( 'unit', 'normalized', 'position', [0 0.1 .15 .05], 'tag', 'tmp', ...                  'style', 'pushbutton', 'string', 'Sagital view', 'callback', 'view([1 0 0]);');    h = uicontrol( 'unit', 'normalized', 'position', [0 0.15 .15 .05], 'tag', 'tmp', ...                  'style', 'text', 'string', '');    h = uicontrol( 'unit', 'normalized', 'position', [0 0.2  .15 .05], 'tag', 'tmp', ...                  'style',  viewstyle   , 'string', viewstring, 'callback', cbview);    h = uicontrol( 'unit', 'normalized', 'position', [0 0.25 .15 .05], 'tag', 'tmp', ...                  'style', 'pushbutton', 'string', 'Mesh on', 'userdata', 0, 'callback', cbmesh);    h = uicontrol( 'unit', 'normalized', 'position', [0 0.3 .15 .05], 'tag', 'tmp', ...                  'style', 'text', 'string', 'Display:','fontweight', 'bold' );    h = uicontrol( 'unit', 'normalized', 'position', [0 0.35 .15 .05], 'tag', 'tmp', ...                  'style', 'text', 'string', '');    h = uicontrol( 'unit', 'normalized', 'position', [0 0.4 .15 .05], 'tag', 'tmp', ...                  'style', 'pushbutton', 'fontweight', 'bold', 'string', 'No controls', 'callback', ...                   'set(findobj(''parent'', gcbf, ''tag'', ''tmp''), ''visible'', ''off'');');    h = uicontrol( 'unit', 'normalized', 'position', [0 0.45 .15 .05], 'tag', 'tmp', ...                  'style', 'text', 'string', '');    h = uicontrol( 'unit', 'normalized', 'position', [0 0.50 .15 .05], 'tag', 'tmp', ...                  'style', 'pushbutton', 'string', 'Keep|Prev', 'callback', ...                [ 'editobj = findobj(''parent'', gcf, ''userdata'', ''editor'');' ...                  'set(editobj, ''string'', num2str(str2num(get(editobj, ''string''))-1));' ...                  'tmpobj = get(gcf, ''userdata'');' ...                  'eval(get(editobj, ''callback''));' ...                  'set(tmpobj, ''visible'', ''on'');' ...

⌨️ 快捷键说明

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