diff --git a/mu_map/data/review_mu_map.py b/mu_map/data/review_mu_map.py index 1bf377184e56fe8543e9b2cb3286b2e2a6f28276..3f12762cc0ab4d456cf96d48871641241293c90a 100644 --- a/mu_map/data/review_mu_map.py +++ b/mu_map/data/review_mu_map.py @@ -1,3 +1,5 @@ +from typing import Optional + import numpy as np import pandas as pd @@ -6,22 +8,30 @@ HEADER_DISC_FIRST = "discard_first" HEADER_DISC_LAST = "discard_last" -def discard_slices(row: pd.Series, μ_map: np.ndarray) -> np.ndarray: +def discard_slices(row: pd.Series, μ_map: np.ndarray, recon: Optional[np.ndarray] = None) -> np.ndarray: """ Discard slices based on the flags in the row of th according table. The row is expected to contain the flags 'discard_first' and 'discard_last'. :param row: the row of meta configuration file of a dataset :param μ_map: the μ_map + :param recon: optional reconstruction of which the same slice is discarded so that the alignment stays the same :return: the μ_map with according slices removed """ _res = μ_map if row[HEADER_DISC_FIRST]: _res = _res[1:] + if recon is not None: + recon = recon[1:] if row[HEADER_DISC_LAST]: _res = _res[:-1] + if recon is not None: + recon = recon[:-1] + + if recon is not None: + return _res, recon return _res