%%%%%%%%%%%%%%%%%%%%%%
%
%  Verify Image List is consistent with point model list
%
%%%%%%%%%%%%%%%%%%%%%%
function aam=get_names_with_pm(aam,cwd)
ind=findstr(aam.modelDirec(19:end),'\')+17;
dirname=[cwd,'\PointModels\',aam.modelDirec(19:ind(1))];
d=dir([dirname,'\','*_pm*']);
%now go through the list of files that we need, taking them from the dir
dnames={d.name};
m=1;
for i=1:length(aam.am_imagenames)
    imagename=aam.am_imagenames{i};
    filename=imagename(1:regexpi(imagename,'.jpg')-1);
    for j=1:length(dnames)
        pointmodelname=dnames{j}(1:findstr(dnames{j},'_pm')-1);
        %[filename,' ',pointmodelname]
        if strcmp(pointmodelname,filename) % non-empty disc file matches image filename
            selected_names{m}=imagename;
            m=m+1;
        end
    end
end
if exist('selected_names')
    aam=set(aam, 'am_imagenames',selected_names);
end