I'm trying to use the BaselineRemoval
package to remove background fluorescence from some Raman spectra. In the code documentation, it states the preferred format for the input as input_array: A pandas dataframe column provided in input as dataframe['input_df_column']. It can also be a Python list object
My example-
df = pd.DataFrame(
{'Patient': [1, 2, 3, 4, 5, 6],
'Group': [1, 1, 1, 2, 2, 2],
'Samples': [list(np.random.randn(3).round(2)) for i in range(6)]
}
)
input_array = df['Samples']
polynomial_degree = 2
baseObj = BaselineRemoval(input_array)
Modpoly_output = baseObj.ModPoly(polynomial_degree)
However, this gives the error ValueError: setting an array element with a sequence.
Not sure how to proceed.
Samples
column. It seems like a list object[-0.89, 0.09, 1.23]
. Raman spectra can be calculated for an array of values. for exampleTemperature
orPressure
orWavelength
. BUT separately. What this pandas column instead has is [Temperature, pressure, wavelength]. Baseline removal can be done for an array object, not a multi-dimensional matrix. Instead, if you store these values in separate arrays and process each array separately then it will give you the desired baseline removed spectra. – Crenation