Skip to content

Commit c7a2a03

Browse files
committed
fix for new calibration api
1 parent 5953952 commit c7a2a03

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/depiction/calibration/methods/calibration_method_constant_global_shift.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import numpy as np
2+
import xarray
23
from numpy.typing import NDArray
34
from xarray import DataArray
45

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

3132
def preprocess_image_features(self, all_features: MultiChannelImage) -> MultiChannelImage:
3233
# we compute the actual global distance here
33-
global_distance = np.nanmedian(all_features.data_flat.ravel())
34-
# create one copy per spectrum
35-
n_spectra = all_features.n_nonzero
34+
global_distance = np.nanmedian(all_features.data_flat.data.ravel())
35+
# return one value per spectrum
3636
return MultiChannelImage(
37-
data=DataArray(
38-
np.full((n_spectra, 1, 1), global_distance), dims=["y", "x", "c"], coords=all_features.coordinates_flat
39-
),
40-
is_foreground=DataArray(
41-
np.ones((n_spectra, 1), dtype=bool), dims=["y", "x"], coords=all_features.coordinates_flat
42-
),
37+
data=xarray.full_like(all_features.data_spatial.isel(c=[0]), global_distance),
38+
is_foreground=all_features.fg_mask,
39+
is_foreground_label=all_features.is_foreground_label,
4340
)
4441

4542
def fit_spectrum_model(self, features: DataArray) -> DataArray:

0 commit comments

Comments
 (0)