Skip to content

Commit

Permalink
minor formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Jun 4, 2024
1 parent d734303 commit 1ccca47
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/depiction/calibration/spectrum/calibration_method_mcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,32 @@ def __init__(
model_smoothing_activated: bool = True,
model_smoothing_kernel_size: int = 27,
model_smoothing_kernel_std: float = 10.0,
max_pairwise_distance: float = 500,
) -> None:
self._model_smoothing_activated = model_smoothing_activated
self._model_smoothing_kernel_size = model_smoothing_kernel_size
self._model_smoothing_kernel_std = model_smoothing_kernel_std
self._max_pairwise_distance = max_pairwise_distance

def extract_spectrum_features(self, peak_mz_arr: NDArray[float], peak_int_arr: NDArray[float]) -> DataArray:
l_none = 1.000482
# c_0 = 0.029
# c_1 = 4.98*10e-4

# compute all differences for elements in peak_mz_arr amd store in a DataArray
# delta = scipy.spatial.distance_matrix(np.expand_dims(peak_mz_arr,1), np.expand_dims(peak_mz_arr,1), p = 1)
# Compute all differences for elements in peak_mz_arr amd store in a DataArray
delta = scipy.spatial.distance.pdist(np.expand_dims(peak_mz_arr, 1), metric="cityblock")
# get all distances smaller then 500
delta = delta[delta < 500]
# for each x compute

# Get all distances smaller than the max pairwise distance
delta = delta[delta < self._max_pairwise_distance]

# Compute delta_lambda for each x
delta_lambda = np.zeros_like(delta)
for i, mi in enumerate(delta):
term1 = (mi) % l_none
term1 = mi % l_none
if term1 < 0.5:
delta_lambda[i] = term1
else:
delta_lambda[i] = -1 + term1
# create a scatterplot of delte_lambda vs x

sorted_indices = np.argsort(delta)
delta = delta[sorted_indices]
Expand All @@ -57,11 +58,12 @@ def extract_spectrum_features(self, peak_mz_arr: NDArray[float], peak_int_arr: N

delta_intercept = np.zeros_like(peak_mz_corrected)
for i, mi in enumerate(peak_mz_corrected):
term1 = (mi) % l_none
term1 = mi % l_none
if term1 < 0.5:
delta_intercept[i] = term1
else:
delta_intercept[i] = -1 + term1

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

Expand Down

0 comments on commit 1ccca47

Please sign in to comment.