def run(self): methodParameters = { 'dilation_': self.smoothnessDoubleSpinBox.value(), 'smoothness_': self.dilationSpinBox.value() } return methodParameters, self.getChangedValues(methodParameters, FABC())
def remove_baseline(df, method='ALS', segment=True, params=None): wvls = np.array(df['wvl'].columns.values, dtype='float') spectra = np.array(df['wvl'], dtype='float') # set baseline removal object (br) to the specified method if method == 'ALS': br = ALS(**params) elif method == 'Dietrich': br = Dietrich(**params) elif method == 'Polyfit': br = PolyFit(**params) elif method == 'AirPLS': br = AirPLS(**params) elif method == 'FABC': br = FABC(**params) elif method == 'KK': br = KK(**params) elif method == 'Median': br = MedianFilter(**params) elif method == 'Rubberband': br = Rubberband(**params) elif method == 'Wavelet a Trous + Spline': br = wavelet_spline(**params) elif method == 'Min + Interpolate': br = minimum_interp(**params) else: print(f'{method} is not recognized!') return 0 br.fit(wvls, spectra, segment=segment) df_baseline = df.copy() df_baseline['wvl'] = br.baseline df['wvl'] = df['wvl'] - df_baseline['wvl'] return df, df_baseline
def remove_baseline(df, method='ALS', segment=True, params=None): wvls = np.array(df['wvl'].columns.values, dtype='float') spectra = np.array(df['wvl'], dtype='float') # set baseline removal object (br) to the specified method if method == 'ALS': br = ALS() elif method == 'Dietrich': br = Dietrich() elif method == 'Polyfit': br = PolyFit() elif method == 'AirPLS': br = AirPLS() elif method == 'FABC': br = FABC() elif method == 'KK': br = KK() elif method == 'Mario': br = Mario() elif method == 'Median': br = MedianFilter() elif method == 'Rubberband': br = Rubberband() elif method == 'Wavelet a Trous + Spline': br = wavelet_spline() elif method == 'Min + Interpolate': br = minimum_interp() else: print(method + ' is not recognized!') # if parameters are provided, use them to set the parameters of br if params is not None: for i in params.keys(): try: setattr(br, i, params[i]) except: print('Required keys are:') print(br.__dict__.keys()) print('Exiting without removing baseline!') return br.fit(wvls, spectra, segment=segment) df_baseline = df.copy() df_baseline['wvl'] = br.baseline df['wvl'] = df['wvl']-df_baseline['wvl'] return df, df_baseline
def connectWidgets(self): br = FABC() self.smoothnessDoubleSpinBox.setValue(br.dilation_) self.dilationSpinBox.setValue(br.smoothness_)