Protomix.binning

binning(spectra_df: DataFrame, bin_size: float, method='trapezoidal') DataFrame[source]

Perform uniform binning on an NMR spectrum by integrating the area under the curve for each bin.

This function applies uniform binning to the provided NMR spectra, dividing the spectrum into bins of a specified size and integrating the area under the curve within each bin. The integration can be performed using either the trapezoidal or rectangular method.

Parameters:
  • spectra_df (pd.DataFrame) – A DataFrame containing the spectra, where each row represents a sample, and columns represent ppm values.

  • bin_size (float) – The size of each bin in ppm.

  • method (str) – The integration method to use for binning. Options are “trapezoidal” (default) or “rectangular”.

Returns:

A DataFrame containing the binned spectra with integrated intensities for each bin.

Return type:

pd.DataFrame