function structReduced = backboneFilterFun(structAll, atomi, atomj,user)

if user.backboneFilter  == 1

    diary('on')
    fprintf('\nKeeping only backbone assignments\n')
    diary('off')

    count                           = 1;
    out.backboneHNHA                = 0;

    for j = 1:length(structAll)
    
        bothAtoms                   = [atomi(j), atomj(j)];
    
        if size(find(ismember(bothAtoms, [1, 2])), 2) == 2 && size(find(ismember(bothAtoms, 2)), 2) ~= 2
        
            structReduced(count)    = structAll(j);
            count                   = count + 1;
            out.backboneHNHA        =  out.backboneHNHA + 1;
        
        end
    
    end
    
else
    
    structReduced = structAll;
    
end