Skip to content

Commit

Permalink
Use intensities of the spectra at the spot and not the total mass df
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-l-kong committed May 30, 2024
1 parent 696882f commit be3d08f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/maldi_tools/extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ def peak_spectra(


def coordinate_integration(
total_mass_df: pd.DataFrame,
peak_df: pd.DataFrame,
l_ips_r: np.ndarray,
r_ips_r: np.ndarray,
Expand Down Expand Up @@ -271,13 +270,11 @@ def coordinate_integration(
for idx, (x, y, _) in tqdm(enumerate(imz_data.coordinates), total=len(imz_data.coordinates)):
mzs, intensities = imz_data.getspectrum(idx)

intensities[np.isin(mzs, peak_df["m/z"])]

for i_idx, peak in peak_df.loc[peak_df["m/z"].isin(mzs), "peak"].reset_index(drop=True).items():
left_idx = abs(total_mass_df.values - l_ips_r[i_idx]).idxmin()
right_idx = abs(total_mass_df.values - r_ips_r[i_idx]).idxmin()
left_idx = abs(intensities.values - l_ips_r[i_idx]).idxmin()
right_idx = abs(intensities.values - r_ips_r[i_idx]).idxmin()
imgs[peak_dict[peak], x - 1, y - 1] += integrate.simpson(
total_mass_df.values[left_idx:right_idx]
intensities.values[left_idx:right_idx]
) - (peak_widths_height * (right_idx - left_idx))

img_data = xr.DataArray(
Expand Down

0 comments on commit be3d08f

Please sign in to comment.