Skip to content

Commit 9f951cf

Browse files
committed
update display of continuous vector images
1 parent 8a18b7b commit 9f951cf

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

ImageM/+imagem/+tools/PlotVectorImageChannels.m

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
%% Properties
2020
properties
21+
XData;
22+
2123
Handles;
2224

2325
LastClickedPoint;
@@ -57,10 +59,21 @@ function select(obj) %#ok<*MANU>
5759
img = obj.Viewer.Doc.Image;
5860
displayRange = [min(img.Data(:)) max(img.Data(:))];
5961

62+
obj.XData = 1:channelCount(img);
63+
xRange = [0 obj.XData(end)+1];
64+
channelNames = obj.Viewer.Doc.Image.ChannelNames;
65+
if ~isempty(channelNames)
66+
values = str2num(char(channelNames(:)')); %#ok<ST2NM>
67+
if all(isfinite(values))
68+
obj.XData = values(:)';
69+
xRange = [min(obj.XData) max(obj.XData)];
70+
end
71+
end
72+
6073
% configure axis
6174
ax = gca;
6275
hold(ax, 'on');
63-
set(ax, 'xlim', [0 channelCount(img)+1]);
76+
set(ax, 'xlim', xRange);
6477
set(ax, 'ylim', displayRange);
6578
titleStr = 'Spectral Profile';
6679
if ~isempty(img.Name)
@@ -69,13 +82,12 @@ function select(obj) %#ok<*MANU>
6982
title(ax, titleStr);
7083
xlabel(ax, 'Channel');
7184
ylabel(ax, 'Channel values');
72-
73-
channelNames = obj.Viewer.Doc.Image.ChannelNames;
74-
if ~isempty(channelNames)
75-
set(ax, 'XTick', 1:length(channelNames))
76-
set(ax, 'XTickLabels', channelNames)
77-
end
78-
85+
86+
% if ~isempty(channelNames)
87+
% set(ax, 'XTick', 1:length(channelNames))
88+
% set(ax, 'XTickLabels', channelNames)
89+
% end
90+
7991
% store settings
8092
userdata = struct('profiles', [], 'profileHandles', []);
8193
set(gca, 'userdata', userdata);
@@ -112,18 +124,18 @@ function deselect(obj)
112124
%% Implements Mouse Listener methods
113125
methods
114126
function onMouseButtonPressed(obj, hObject, eventdata) %#ok<INUSD>
115-
127+
% Update plot display based on last click position.
128+
129+
% get coordinates of last click on image.
116130
pos = get(obj.Viewer.Handles.ImageAxis, 'CurrentPoint');
117131
pos = pos(1, 1:2);
118132
if is3dImage(obj.Viewer.Doc.Image)
119133
pos = [pos obj.Viewer.SliceIndex];
120134
end
121-
122135
obj.LastClickedPoint = pos;
123136

137+
% convert to pixel coordinates
124138
img = obj.Viewer.Doc.Image;
125-
% coord = round(pointToIndex(img, [pos(1, 1:2) obj.Viewer.SliceIndex]));
126-
127139
coord = round(pointToIndex(img, pos));
128140
coord = coord(1:2);
129141

@@ -140,11 +152,11 @@ function onMouseButtonPressed(obj, hObject, eventdata) %#ok<INUSD>
140152
% create a new curve
141153
switch obj.Viewer.Doc.ChannelDisplayType
142154
case 'Curve'
143-
obj.Handles.CProfileCurve = plot(obj.Handles.CProfileAxis, profile, 'b');
155+
obj.Handles.CProfileCurve = plot(obj.Handles.CProfileAxis, obj.XData, profile, 'b');
144156
case 'Bar'
145-
obj.Handles.CProfileCurve = bar(obj.Handles.CProfileAxis, profile, 'b');
157+
obj.Handles.CProfileCurve = bar(obj.Handles.CProfileAxis, obj.XData, profile, 'b');
146158
case 'Stem'
147-
obj.Handles.CProfileCurve = stem(obj.Handles.CProfileAxis, profile, 'b');
159+
obj.Handles.CProfileCurve = stem(obj.Handles.CProfileAxis, obj.XData, profile, 'b');
148160
otherwise
149161
warning('Unknown channel display type');
150162
end

0 commit comments

Comments
 (0)