Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
imline() require user click after the 3rd line on same plot

Subject: imline() require user click after the 3rd line on same plot

From: Hoi Wong

Date: 5 Apr, 2009 05:47:01

Message: 1 of 2

I'm trying to create 6 draggable threshold lines to dynamically update my plots, but I noticed that RIGHT after the 3rd line is created, it waits for me to click on the plot before continuing, and it happens again (waiting for my click) right after the 5th line is created. Is this normal behavior or is that a bug?

For debug purposes, I've rewritten my for-loop code into this:

            h(1,1) = imline(handles.panel.episodes.infoDisplay.axes_electrogram, [0 T], [1 1]*(Yoffsets(1)+0.5*max(y(:,1))), 'PositionConstraintFcn', @constraintVerticalLine);
fprintf('1\n');
            setColor(h(1,1), [0.5 0.5 0.5]);
fprintf('1B\n');
            h(1,2) = imline(handles.panel.episodes.infoDisplay.axes_electrogram, [0 T], [1 1]*(Yoffsets(1)+0.5*min(y(:,1))), 'PositionConstraintFcn', @constraintVerticalLine);
fprintf('2\n');
            setColor(h(1,2), [0.5 0.5 0.5]);
fprintf('2B\n');
            h(2,1) = imline(handles.panel.episodes.infoDisplay.axes_electrogram, [0 T], [1 1]*(Yoffsets(2)+0.5*max(y(:,2))), 'PositionConstraintFcn', @constraintVerticalLine);
% Waits for user click here
fprintf('3\n');
            setColor(h(2,1), [0.5 0.5 0.5]);
fprintf('3B\n');
            h(2,2) = imline(handles.panel.episodes.infoDisplay.axes_electrogram, [0 T], [1 1]*(Yoffsets(2)+0.5*min(y(:,2))), 'PositionConstraintFcn', @constraintVerticalLine);
fprintf('4\n');
            setColor(h(2,2), [0.5 0.5 0.5]);
fprintf('4B\n');
            h(3,1) = imline(handles.panel.episodes.infoDisplay.axes_electrogram, [0 T], [1 1]*(Yoffsets(3)+0.5*max(y(:,3))), 'PositionConstraintFcn', @constraintVerticalLine);
% Waits for user click here
fprintf('5\n');
            setColor(h(3,1), [0.5 0.5 0.5]);
fprintf('5B\n');
            h(3,2) = imline(handles.panel.episodes.infoDisplay.axes_electrogram, [0 T], [1 1]*(Yoffsets(3)+0.5*min(y(:,3))), 'PositionConstraintFcn', @constraintVerticalLine);
fprintf('6\n');
            setColor(h(3,2), [0.5 0.5 0.5]);
fprintf('6B\n');

Subject: imline() require user click after the 3rd line on same plot

From: Hoi Wong

Date: 5 Apr, 2009 06:07:09

Message: 2 of 2

"Hoi Wong" <wonghoi.ee@gmailNOSPAM.com> wrote in message <gr9gkl$bv$1@fred.mathworks.com>...
> I'm trying to create 6 draggable threshold lines to dynamically update my plots, but I noticed that RIGHT after the 3rd line is created, it waits for me to click on the plot before continuing, and it happens again (waiting for my click) right after the 5th line is created. Is this normal behavior or is that a bug?
>
> For debug purposes, I've rewritten my for-loop code into this:
>
> h(1,1) = imline(handles.panel.episodes.infoDisplay.axes_electrogram, [0 T], [1 1]*(Yoffsets(1)+0.5*max(y(:,1))), 'PositionConstraintFcn', @constraintVerticalLine);
> fprintf('1\n');
> setColor(h(1,1), [0.5 0.5 0.5]);
> fprintf('1B\n');
> h(1,2) = imline(handles.panel.episodes.infoDisplay.axes_electrogram, [0 T], [1 1]*(Yoffsets(1)+0.5*min(y(:,1))), 'PositionConstraintFcn', @constraintVerticalLine);
> fprintf('2\n');
> setColor(h(1,2), [0.5 0.5 0.5]);
> fprintf('2B\n');
> h(2,1) = imline(handles.panel.episodes.infoDisplay.axes_electrogram, [0 T], [1 1]*(Yoffsets(2)+0.5*max(y(:,2))), 'PositionConstraintFcn', @constraintVerticalLine);
> % Waits for user click here
> fprintf('3\n');
> setColor(h(2,1), [0.5 0.5 0.5]);
> fprintf('3B\n');
> h(2,2) = imline(handles.panel.episodes.infoDisplay.axes_electrogram, [0 T], [1 1]*(Yoffsets(2)+0.5*min(y(:,2))), 'PositionConstraintFcn', @constraintVerticalLine);
> fprintf('4\n');
> setColor(h(2,2), [0.5 0.5 0.5]);
> fprintf('4B\n');
> h(3,1) = imline(handles.panel.episodes.infoDisplay.axes_electrogram, [0 T], [1 1]*(Yoffsets(3)+0.5*max(y(:,3))), 'PositionConstraintFcn', @constraintVerticalLine);
> % Waits for user click here
> fprintf('5\n');
> setColor(h(3,1), [0.5 0.5 0.5]);
> fprintf('5B\n');
> h(3,2) = imline(handles.panel.episodes.infoDisplay.axes_electrogram, [0 T], [1 1]*(Yoffsets(3)+0.5*min(y(:,3))), 'PositionConstraintFcn', @constraintVerticalLine);
> fprintf('6\n');
> setColor(h(3,2), [0.5 0.5 0.5]);
> fprintf('6B\n');

I just solved it myself by saving the ROI handles as cells. I suspsect that the ROI handle behaves a little bit special: it doesn't like to be treated as a number to be put in a matrix. So MATLAB crashed when I do setColor(h, ...), while h is an numerical matrix of ROIs I put in.

After that I checked my code and remembered to extract the handle from the h (ROI) matrix that I created, the I did something like setColor(h(1,2), ...) and it gives me akward behavior like my post above. Clearly the image processing toolbox needs to handle ROI classes better (at least overload subsasgn properly, or check for non-singleton matrix handle input) to avoid these confusing behavior.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us