Skip to content

Commit

Permalink
fix for new calibration api
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Oct 24, 2024
1 parent 5953952 commit c7a2a03
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
import xarray
from numpy.typing import NDArray
from xarray import DataArray

Expand Down Expand Up @@ -30,16 +31,12 @@ def extract_spectrum_features(self, peak_mz_arr: NDArray[float], peak_int_arr: N

def preprocess_image_features(self, all_features: MultiChannelImage) -> MultiChannelImage:
# we compute the actual global distance here
global_distance = np.nanmedian(all_features.data_flat.ravel())
# create one copy per spectrum
n_spectra = all_features.n_nonzero
global_distance = np.nanmedian(all_features.data_flat.data.ravel())
# return one value per spectrum
return MultiChannelImage(
data=DataArray(
np.full((n_spectra, 1, 1), global_distance), dims=["y", "x", "c"], coords=all_features.coordinates_flat
),
is_foreground=DataArray(
np.ones((n_spectra, 1), dtype=bool), dims=["y", "x"], coords=all_features.coordinates_flat
),
data=xarray.full_like(all_features.data_spatial.isel(c=[0]), global_distance),
is_foreground=all_features.fg_mask,
is_foreground_label=all_features.is_foreground_label,
)

def fit_spectrum_model(self, features: DataArray) -> DataArray:
Expand Down

0 comments on commit c7a2a03

Please sign in to comment.