Skip to content

Commit

Permalink
Updated tonal annotation tool: species and call dropdowns now update …
Browse files Browse the repository at this point in the history
…to first selected tonal; by-species is now more consistent
  • Loading branch information
joshua-zingale committed Mar 6, 2024
1 parent d5dbdf6 commit 6bd075b
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions src/matlab/user_interface/dtTonalAnnotate.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@
data.AnnotationColorN = 20;
data.AnnotationColorNext = 1;
data.AnnotationColormap = hsv(data.AnnotationColorN);
data.AnnotationColormap = ...
data.AnnotationColormap(randperm(data.AnnotationColorN), :);
data.AnnotationColorIdxIncrement = 9;
% I do not know why this randomization was applied
% I have removed it as of 3/5/2024 to make the colors deterministic
%data.AnnotationColormap = ...
% data.AnnotationColormap(randperm(data.AnnotationColorN), :);
data.LineWidth = 2;
data.LineStyle = '-';
data.LineSelectedStyle = ':';
Expand Down Expand Up @@ -374,10 +377,10 @@

% Labeling data
data.species_call_map = dtGetLabelOptions();
species_names = (data.species_call_map.keys)';
handles.species_label.String = species_names;
data.species_names = (data.species_call_map.keys)';
handles.species_label.String = data.species_names;
handles.species_label.Value = 1;
call_info = data.species_call_map(species_names{1});
call_info = data.species_call_map(data.species_names{1});
handles.call_label.String = call_info.calls;
handles.call_label.Value = call_info.selected;
SaveDataInFigure(handles, data); % save user/figure data before plot
Expand Down Expand Up @@ -1297,6 +1300,25 @@ function selectTonal_Callback(hObject, eventdata, varargin)
guidata(figureH, handles);
end
tonal_selected_count(handles); % update info about selections

% update label dropdown to display the selected tonal's species & call
% species
species = char(get(handles.Selected(1), 'UserData').getSpecies());
if ~isempty(species) && (numel(handles.Selected) == 1)
sf = strfind((data.species_names), species);
species_idx = find(~cellfun('isempty', sf));

set(handles.species_label, 'Value', species_idx)

% call
call = char(get(handles.Selected(1), 'UserData').getCall());
new_calls = data.species_call_map(species).calls;
set(handles.call_label, 'String', new_calls);

sf = strfind(new_calls, call);
call_idx = find(~cellfun('isempty', sf));
set(handles.call_label, 'Value', call_idx)
end
end

function new_s = start_in_range(start_s, handles, data)
Expand Down Expand Up @@ -2234,7 +2256,7 @@ function annotationFilenameToClipboard_Callback(hObject, eventdata, handles)
% Reserve the first color for when there are no labels
species = a_tonal.getSpecies();
speciesN = size(handles.species_label.String, 1);
coloridx = find(strcmp(species, handles.species_label.String));
coloridx = data.AnnotationColorIdxIncrement * find(strcmp(species, handles.species_label.String));
if isempty(coloridx)
coloridx = 1; % No label
else
Expand All @@ -2250,7 +2272,7 @@ function annotationFilenameToClipboard_Callback(hObject, eventdata, handles)
callN = size(handles.call_label.String, 1);
coloridx = find(strcmp(call, handles.call_label.String));
if isempty(coloridx)
coloridx = 1 % No label
coloridx = 1; % No label
else
coloridx = coloridx + 1;
end
Expand Down Expand Up @@ -2870,6 +2892,7 @@ function updateAnnotationLabel(handles, annotations)
current = annotationsN;
set(handles.MoveToAnnotationN, 'Max', annotationsN);
set(handles.MoveToAnnotationN, 'Value', current);
set(handles.SelectAnnotationN, 'String', round(current));
end
if annotationsN == 1
% Special case, slider does not show in min/max are the same
Expand All @@ -2886,6 +2909,7 @@ function updateAnnotationLabel(handles, annotations)
set(handles.GotoAnnotationPrev, 'Enable', 'on');
set(handles.GotoAnnotationLabel, 'String', ...
sprintf('%d/%d', current, annotations.size()));
set(handles.SelectAnnotationN, 'String', round(current));
end


Expand Down Expand Up @@ -3538,5 +3562,4 @@ function SelectAnnotationN_Callback(hObject, eventdata, handles)
set(handles.MoveToAnnotationN, 'Value', value)
MoveToAnnotationN_Callback(hObject, eventdata, handles);

set(hObject, 'String', value);
end

0 comments on commit 6bd075b

Please sign in to comment.