HowTo : Report the n Biggest Peaks of a sample analysis (OpenLab CDS Custom Calculator)

Version 3

    Taking the n biggest peak has always been a difficult process because peaks need to be sorted by descending order, and from this sorted list, the report need then to show only the n desired peaks.

     

    An easy way, is to create a Custom Calculation (CC) that sort the list of peaks, and then checks if the current peak is part of that list. The CC expression is then a Boolean test in a Peak or group scope:

     

    (CurrentInjection.AllPeaks.OrderByDescending(Function(p) p.Peak_Area)) .take(5).contains(currentpeakorgroup)

    2015-0729_N-BiggestPeaks_01_CC_Editor.png

    This CC:

    1. Creates a list of Peak_Area, in a the descending order
    2. Takes the 5 biggest. But "5" can also be a Sample Custom Field for example
    3. Test if the current peak is part of the list created

     

    The result of the Custom Calculator will return "True", when the peak is part of the n biggest peaks, or "False" otherwise

    2015-0729_N-BiggestPeaks_02_CC_Results.png

    In Intelligent Reporting, the 5 biggest peak spectra can then be reported by filtering the spectra with the following expression :

    =CCR((Compound_CustomCalculationResults),"CC Name") = True

     

    2015-0729_N-BiggestPeaks_03_ReportingFilter.png

     

    Only the 5 biggest peaks will be reported.

     

    Regards, Pierre

     

    (originally posted in OpenLAB Forum: https://zohodiscussions.com/openlabcdsforum#Topic/68030000000191007

    2015 July 29)