BaselineRemoval package for background fluorescence/noise removal

1.1k Views Asked by At

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.

1

There are 1 best solutions below

0
On

A simple for loop should do it.

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

for row in input_array:
    print(BaselineRemoval(row).ModPoly(polynomial_degree))