function scaledValue = scale2labSchemeFun(rawValue,ATOMj,resName_j,conditions,user)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



if ismember(ATOMj, conditions.all.exSolAtoms)
              
	scaleFactor       = (1-user.perCentD2O/100);        
                 
elseif ismember(ATOMj, conditions.all.HA)
                 
	scaleFactor       = (1-user.deut_HA/100);
                 
elseif ismember(ATOMj, conditions.all.methylPseudo(1:8))                                    % methyl pseudo not labled
                 
    scaleFactor       = 3 * (1-user.deut_Met/100); 
            
elseif ismember(ATOMj, conditions.all.methylAtoms)                                          % methyl single not labled
                 
    scaleFactor       = (1-user.deut_Met/100);
    
else
                                  
    scaleFactor       = (1-user.deut_Prot/100);
                 
end
                


labelFlag    = 0;
               
for a = 1:size(conditions.labelingScheme,2)
                
    if labelFlag == 0 && isequal(double(resName_j),double(conditions.labelingScheme(a).resName))    % conversion of char to double    
        
        if ismember(ATOMj, conditions.labelingScheme(a).grpNum)                             % Pseudo Atom
            
         	labelFlag = 1;
                        
           	scaleFactor = 3 * (1 - conditions.labelingScheme(a).deutLevel/100);
            
     	elseif ismember(ATOMj, conditions.labelingScheme(a).atoms)
                        
         	labelFlag = 1;
            
           	scaleFactor = (1 - conditions.labelingScheme(a).deutLevel/100);      % Single Atom
                        
        end
                    
    end
                
end


scaledValue       = rawValue * scaleFactor;