Skip to content

Commit

Permalink
working implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Jun 4, 2024
1 parent c7423fe commit 092cea9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/depiction/calibration/spectrum/calibration_method_mcc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np
import scipy
import scipy.stats as stats
import scipy.stats
import statsmodels.api as sm
from numpy.typing import NDArray
from statsmodels.robust.norms import HuberT
Expand Down Expand Up @@ -64,7 +63,7 @@ def extract_spectrum_features(self, peak_mz_arr: NDArray[float], peak_int_arr: N
else:
delta_intercept[i] = -1 + term1

intercept_coef = stats.trim_mean(delta_intercept, 0.3)
intercept_coef = scipy.stats.trim_mean(delta_intercept, 0.3)
return DataArray([intercept_coef, slope], dims=["c"])

def preprocess_image_features(self, all_features: DataArray) -> DataArray:
Expand All @@ -83,5 +82,6 @@ def fit_spectrum_model(self, features: DataArray) -> DataArray:
def apply_spectrum_model(
self, spectrum_mz_arr: NDArray[float], spectrum_int_arr: NDArray[float], model_coef: DataArray
) -> tuple[NDArray[float], NDArray[float]]:
spectrum_corrected = spectrum_mz_arr * (1 - model_coef.values[1]) + model_coef.values[0]
return spectrum_corrected
intercept, slope = model_coef.values
spectrum_corrected = spectrum_mz_arr * (1 - slope) + intercept
return spectrum_corrected, spectrum_int_arr

0 comments on commit 092cea9

Please sign in to comment.