mplot3d - MATLAB set('XData'....) -


i'm having problem updating plot. basically, have function creates figure 3 subplots. have function runs create figure function , updates plot. it's important update don't create new graph each loop since it's 3d data , takes while load.

the problem lies in second subplot. load 3 images (3 slices) using slice() , want plot position vector. set position vector (0,0,0) initially, thought update in loop setting 'xdata', 'ydata'... respective values. reason it's not working , spitting error "undefined function 'xdata' input arguments of type 'double'." please help, below code, thanks!!!

note--- error lies in update plot function after "%refresh plot"

initial plot

function [fig] = endosliceviewer_createfigure(figindex,dicomparam) %this function creates , returns figure object visualizes dicom data %in plane orthogonal endoscopic view, rgb view of camera %and orientation of navigation  %set resolution endo slice plot fig.resolendoslice=300;  fig.resolendorgb=[720 1280];  fig.resolendonavi=[500 500 500];   %init figure on screen fig.fig=figure(figindex); gcf; set(fig.fig,'position',[50 500 1500 500],'name','endo slice viewer'); %set(fig.fig,'keypressfcn','global kpressed; global fig; kpressed = get(fig.fig,''currentchar'');');  fig.sub1=subplot(1,3,1); fig.sub1im=image(uint8(zeros(fig.resolendorgb(1), fig.resolendorgb(2),3))); title('endo camera view'); daspect([1 1 1]);  fig.sub2=subplot(1,3,2); fig.sub2im=plot3(0,0,0); h=slice(dicomparam.vd,dicomparam.cx,dicomparam.cy,dicomparam.cz); colormap bone; set(h,'facecolor','interp',...     'edgecolor','none',...     'diffusestrength',.8) title('navigation view'); xlim([-0.2*fig.resolendonavi(1),  1.2*fig.resolendonavi(1)]); ylim([-0.2*fig.resolendonavi(2),  1.2*fig.resolendonavi(2)]); zlim([-0.2*fig.resolendonavi(3),  1.2*fig.resolendonavi(3)]); xlabel('x [vox]'); ylabel('y [vox]'); zlabel('z [vox]'); daspect([1 1 1]);  fig.sub3=subplot(1,3,3); fig.sub3im=imagesc(zeros(fig.resolendoslice, fig.resolendoslice)); title('endo slice view'); xlim([0 fig.resolendoslice]); ylim([0 fig.resolendoslice]); xlabel('xendo [vox]'); ylabel('yendo [vox]'); daspect([1 1 1]); colormap bone drawnow;  %potentially: add subplot navigation position display later end 

update plot

function [  ] = endosliceviewerjp( naviparam,  dicomparam) %rgbparam should included later - add +1 nargin values   %visualizes:  %1st: rgb camera live view  %2nd: orientation , position of navigation system %3rd: dicom slice relative navigated endoscope in , orientation %in slice perpendicular endoscope %assumes navigation system running referenced tool (naviparam.tool=4 or naviparam.tool=5)  %currently plots slices according endoscope position, add %vector in plot shows orientation of scope... disp('endo slice viewer'); disp('" ": exit on space key'); global kpressed; kpressed = 0;  global fig fig=endosliceviewer_createfigure(1,dicomparam); set(fig.fig,'keypressfcn','global kpressed; global fig; kpressed = get(fig.fig,''currentchar'');');  %create matrices , filter smoothing of endo slice data xrel=-(ones(fig.resolendoslice,1)*(1:fig.resolendoslice)-fig.resolendoslice/2)'; yrel=-(ones(fig.resolendoslice,1)*(1:fig.resolendoslice)-fig.resolendoslice/2); slimage=zeros(fig.resolendoslice,fig.resolendoslice); posvec=zeros(fig.resolendoslice,fig.resolendoslice,3); gfilt = fspecial('gaussian',5,1.5); depth = 50;   exitflag = 0; while (exitflag == 0)      %check on keyboard input      if kpressed ~= 0         switch kpressed             case 'r'                 depth=depth+2             case 'f'                 depth=depth-2             case ' '                 exitflag = 1;                 disp('**** exit endo slice viewer ****')          end         kpressed = 0;      end  if (nargin>=1) %naviparam passed - update navigation view      %capture new navigation data      naviparam=navi_acquire(naviparam);      naviparam=navi_calc_data(naviparam);       %refreshn avigation view      %not yet implemented: update navigation plot        if (nargin==2) %dicomparam passed - update endoslice view          endovecx=inv(dicomparam.calib.navi2dicom(1:3,1:3))*inv(naviparam.data.endo_refhommat(1:3,1:3))*[1;0;0];          endovecy=inv(dicomparam.calib.navi2dicom(1:3,1:3))*inv(naviparam.data.endo_refhommat(1:3,1:3))*[0;1;0];          endovecz=inv(dicomparam.calib.navi2dicom(1:3,1:3))*inv(naviparam.data.endo_refhommat(1:3,1:3))*[0;0;-1];          disp(naviparam.data.endo_refhommat(1:3,1:3));          endovecx=endovecx/norm(endovecx);          endovecy=endovecy/norm(endovecy);          endovecz=endovecz/norm(endovecz);          mask=ones(fig.resolendoslice,fig.resolendoslice);          s=[dicomparam.sx; dicomparam.sy; dicomparam.sz];           dicompos = dicomparam.calib.navi2dicom*[naviparam.data.endo_refoffsetposvec;1];           i=1:3              %point on plane defined endo position plus distance*viewing direction vector              posvec(:,:,i)=(dicompos(i)+depth*endovecz(i))+xrel*endovecx(i)+yrel*endovecy(i);              %limit positions integer values inside dicom data cube              posvec(:,:,i)=round(posvec(:,:,i));              posvec(:,:,i)=min(max(posvec(:,:,i),1),s(i));              %create mask set points outside data cube 0              mask=double(posvec(:,:,i)>1).*double(posvec(:,:,i)<s(i).*mask(:,:));          end          %access data cube via indexed labelling          xpostemp=posvec(:,:,1); ypostemp=posvec(:,:,2); zpostemp=posvec(:,:,3);          indextemp=sub2ind(size(dicomparam.vd), xpostemp(:), ypostemp(:),zpostemp(:));          slimage(:)=dicomparam.vd(indextemp(:));           slimage=slimage.*mask;          slimage=imfilter(slimage,gfilt);           %refresh plot          set(fig.sub3im, 'cdata', slimage);      axes(fig.sub2);      set(lineseries, 'xdata', dicompos(1), 'ydata', dicompos(2), 'zdata', dicompos(3));      set(lineseries, 'marker', '*', 'color', 'b');      disp(dicompos);      end end  %rgbparam passed - update rgb camera view %capture new rgb data %handles.rgbparam=rgb_acquire(handles.rgbparam); %refresh rgb camera view %set(fig.sub1im, 'cdata', imresize(handles.rgbparam.image,[fig.resolendorgb(1) fig.resolendorgb(2)]));     drawnow; end  close(fig.fig); clear global;   end 

the function set called in following manner

set(objecthandle, 'propertyname_1', propertyvalue_1, 'propertyname_2', propertyvalue_2); 

adding more name-value pairs fit. in case be

set(linehandle, 'xdata', dicompos(1), 'ydata', dicompos(2), 'zdata', dicompos(3)); 

for changing position data. note of these properties belong line, not axes, need handle line updating. assuming axes contains 1 line can done ad-hoc adding code before loop:

linehandle = findobj(fig.sub2, 'type', 'line'); 

also, can't change linestyle in manner: set(linehandle, 'b*'). reason error "invalid parameter/value pair arguments."

first off, need property name before each property value, , second, there no property name linestyle. have change color , marker separately, example this:

set(linehandle, 'marker', '*', 'color', 'b'); 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -