Average Calculations in Report Builder

How to set up calculations for area averages, retention time, asymmetry, among other parameters in a MassHunter report? Using the Report Builder

Parents Reply Children
  • Hello
    I wrote this code but
    How can I update this script so that Report Builder calculates the average only if 6 samples are processed, if more or fewer samples are processed the result is "--"?

    import System
    import System.IO

    # Inicializar Resplist se não estiver definida
    if 'Resplist' not in globals():
    Resplist = []

    # Adicionar o valor de TargetResponse à lista
    x = 0 if BoundItems["TargetPeak"] is None or BoundItems["TargetPeak"].IsTargetResponseNull() else BoundItems["TargetPeak"].TargetResponse
    Resplist.append(x)

    # Definir o número de elementos para calcular a média
    n = 6
    i = len(Resplist)

    # Calcular a média se houver elementos suficientes
    if i == n:
    mean = sum(Resplist[i-n:i]) / float(n)
    mean = round(mean) # Arredondar a média para o inteiro mais próximo
    else:
    mean = "--"

    # Exibir a média
    mean

    -------------------------------------------------------------------------------
    The way it is written, the code always presents the result in the sixth sample.

Was this helpful?