Repository: matchms/matchms
Pull request #454 (2023-07-02 14:10:25)

refactor filter functions and their path structure
- Divide filter functions into three folders: `filter_utils`, `metadata_processing`, and `peak_processing`.
- Removal of the filters `make_ionmode_lowercase` and `set_ionmode_na_when_missing`
(their functionality should meanwhile be completely be covered by our `Metadata` class.
- Adjust imports and __init__.py files accordingly
- Some code lintings
- Add missing docstrings.


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9cf455ff..a6643a97 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 ### Changed
 ### Fixed
 
+## [0.21.1] - 2023-07-03
+
+### Added
+
+- missing code documentations [#454](https://github.com/matchms/matchms/pull/454)
+
+### Changed
+
+- Moved matchms filter functions into new folder structure [#454](https://github.com/matchms/matchms/pull/454).
+- Removed outdated (redundant) filters: `make_ionmode_lowercase` and `set_ionmode_na_when_missing` [#454](https://github.com/matchms/matchms/pull/454).
+
 ## [0.21.0] - 2023-06-30
 
 ### Added
diff --git a/matchms/Metadata.py b/matchms/Metadata.py
index eedb47b6..3ddb0845 100644
--- a/matchms/Metadata.py
+++ b/matchms/Metadata.py
@@ -1,10 +1,13 @@
 from collections.abc import Mapping
 import numpy as np
 from pickydict import PickyDict
-from .filtering.add_precursor_mz import _add_precursor_mz_metadata
-from .filtering.add_retention import _add_retention
-from .filtering.interpret_pepmass import _interpret_pepmass_metadata
-from .filtering.make_charge_int import _convert_charge_to_int
+from .filtering.metadata_processing.add_precursor_mz import \
+    _add_precursor_mz_metadata
+from .filtering.metadata_processing.add_retention import _add_retention
+from .filtering.metadata_processing.interpret_pepmass import \
+    _interpret_pepmass_metadata
+from .filtering.metadata_processing.make_charge_int import \
+    _convert_charge_to_int
 from .utils import load_export_key_conversions, load_known_key_conversions
 
 
@@ -91,6 +94,11 @@ class Metadata:
         self._data.key_replacements = _key_replacements
 
     def harmonize_values(self):
+        """Runs default harmonization of metadata.
+
+        This includes harmonizing entries for ionmode, retention time and index,
+        charge, as well as the removal of invalid entried ("", "NA", "N/A", "NaN").
+        """
         metadata_filtered = _interpret_pepmass_metadata(self.data)
         metadata_filtered = _add_precursor_mz_metadata(metadata_filtered)
 
diff --git a/matchms/Spectrum.py b/matchms/Spectrum.py
index df7e60b0..cdbb3230 100644
--- a/matchms/Spectrum.py
+++ b/matchms/Spectrum.py
@@ -184,6 +184,7 @@ class Spectrum:
         return spectrum_dict
 
     def metadata_dict(self, export_style: str = "matchms") -> dict:
+        """Convert spectrum metadata to Python dictionary."""
         return self._metadata.to_dict(export_style)
 
     @property
@@ -230,6 +231,7 @@ class Spectrum:
 
     @classmethod
     def update_peak_comments_mz_tolerance(cls, mz_tolerance: float):
+        """Change current peak comment m/z tolerance to mz_tolerance."""
         cls._peak_comments_mz_tolerance = mz_tolerance
 
     def _reiterate_peak_comments(self, peaks: Fragments):
diff --git a/matchms/__init__.py b/matchms/__init__.py
index d78128b8..f77e76bf 100644
--- a/matchms/__init__.py
+++ b/matchms/__init__.py
@@ -12,8 +12,8 @@ from .Spectrum import Spectrum
 _init_logger()
 
 
-__author__ = "Netherlands eScience Center"
-__email__ = 'generalization@esciencecenter.nl'
+__author__ = "Matchms developers community"
+__email__ = 'florian.huber@hs-duesseldorf.de'
 __all__ = [
     "__version__",
     "calculate_scores",
diff --git a/matchms/filtering/SpeciesString.py b/matchms/filtering/SpeciesString.py
index 23df2d5d..1bf9082f 100644
--- a/matchms/filtering/SpeciesString.py
+++ b/matchms/filtering/SpeciesString.py
@@ -2,8 +2,32 @@ import re
 
 
 class SpeciesString:
-
+    """
+    A class to process and clean different types of chemical structure strings including InChI, 
+    InChIKey, and SMILES.
+
+    The class takes a raw input string, determines the intended structure type, and then cleans 
+    the string based on its type.
+
+    Attributes
+    ----------
+    dirty : str
+        Raw input string representing a chemical structure.
+    target : str
+        The intended structure type determined from the input string. Could be 'inchi', 'inchikey', 
+        'smiles', or None if no valid type was identified.
+    cleaned : str
+        The cleaned structure string. 
+    """
     def __init__(self, dirty: str):
+        """
+        Constructs a new instance of the SpeciesString class.
+
+        Parameters
+        ----------
+        dirty : str
+            The raw input string representing a chemical structure.
+        """
         self.dirty = dirty
         self.target = None
         self.cleaned = None
@@ -16,7 +40,7 @@ class SpeciesString:
         return f"({self.target}): {self.cleaned}"
 
     def clean(self):
-
+        """Clean the input string based on its determined structure type."""
         if self.target is None:
             self.cleaned = ""
 
@@ -59,7 +83,7 @@ class SpeciesString:
             self.cleaned = found[0]
 
     def guess_target(self):
-
+        """Determine the intended structure type of the input string."""
         if self.looks_like_an_inchikey():
             self.target = "inchikey"
         elif self.looks_like_an_inchi():
diff --git a/matchms/filtering/__init__.py b/matchms/filtering/__init__.py
index db36ea1b..9b7f193c 100644
--- a/matchms/filtering/__init__.py
+++ b/matchms/filtering/__init__.py
@@ -36,57 +36,74 @@ Should output
    Sketch of matchms spectrum processing.
 
 """
-from .add_compound_name import add_compound_name
-from .add_fingerprint import add_fingerprint
-from .add_losses import add_losses
-from .add_parent_mass import add_parent_mass
-from .add_precursor_mz import add_precursor_mz
-from .add_retention import add_retention_index, add_retention_time
-from .clean_compound_name import clean_compound_name
-from .correct_charge import correct_charge
 from .default_filters import default_filters
-from .derive_adduct_from_name import derive_adduct_from_name
-from .derive_formula_from_name import derive_formula_from_name
-from .derive_inchi_from_smiles import derive_inchi_from_smiles
-from .derive_inchikey_from_inchi import derive_inchikey_from_inchi
-from .derive_ionmode import derive_ionmode
-from .derive_smiles_from_inchi import derive_smiles_from_inchi
-from .harmonize_undefined_inchi import harmonize_undefined_inchi
-from .harmonize_undefined_inchikey import harmonize_undefined_inchikey
-from .harmonize_undefined_smiles import harmonize_undefined_smiles
-from .interpret_pepmass import interpret_pepmass
-from .make_charge_int import make_charge_int
-from .make_charge_scalar import make_charge_scalar
-from .make_ionmode_lowercase import make_ionmode_lowercase
-from .normalize_intensities import normalize_intensities
-from .reduce_to_number_of_peaks import reduce_to_number_of_peaks
-from .remove_peaks_around_precursor_mz import remove_peaks_around_precursor_mz
-from .remove_peaks_outside_top_k import remove_peaks_outside_top_k
-from .repair_adduct.clean_adduct import clean_adduct
-from .repair_adduct.repair_adduct_based_on_smiles import \
+from .metadata_processing.add_compound_name import add_compound_name
+from .metadata_processing.add_fingerprint import add_fingerprint
+from .metadata_processing.add_parent_mass import add_parent_mass
+from .metadata_processing.add_precursor_mz import add_precursor_mz
+from .metadata_processing.add_retention import (add_retention_index,
+                                                add_retention_time)
+from .metadata_processing.clean_adduct import clean_adduct
+from .metadata_processing.clean_compound_name import clean_compound_name
+from .metadata_processing.correct_charge import correct_charge
+from .metadata_processing.derive_adduct_from_name import \
+    derive_adduct_from_name
+from .metadata_processing.derive_formula_from_name import \
+    derive_formula_from_name
+from .metadata_processing.derive_inchi_from_smiles import \
+    derive_inchi_from_smiles
+from .metadata_processing.derive_inchikey_from_inchi import \
+    derive_inchikey_from_inchi
+from .metadata_processing.derive_ionmode import derive_ionmode
+from .metadata_processing.derive_smiles_from_inchi import \
+    derive_smiles_from_inchi
+from .metadata_processing.harmonize_undefined_inchi import \
+    harmonize_undefined_inchi
+from .metadata_processing.harmonize_undefined_inchikey import \
+    harmonize_undefined_inchikey
+from .metadata_processing.harmonize_undefined_smiles import \
+    harmonize_undefined_smiles
+from .metadata_processing.interpret_pepmass import interpret_pepmass
+from .metadata_processing.make_charge_int import make_charge_int
+from .metadata_processing.make_charge_scalar import make_charge_scalar
+from .metadata_processing.repair_adduct_based_on_smiles import \
     repair_adduct_based_on_smiles
-from .repair_inchi_inchikey_smiles import repair_inchi_inchikey_smiles
-from .repair_parent_mass_from_smiles.repair_parent_mass_is_mol_wt import \
+from .metadata_processing.repair_inchi_inchikey_smiles import \
+    repair_inchi_inchikey_smiles
+from .metadata_processing.repair_parent_mass_is_mol_wt import \
     repair_parent_mass_is_mol_wt
-from .repair_parent_mass_from_smiles.repair_parent_mass_match_smiles_wrapper import \
+from .metadata_processing.repair_parent_mass_match_smiles_wrapper import \
     repair_parent_mass_match_smiles_wrapper
-from .repair_parent_mass_from_smiles.repair_precursor_is_parent_mass import \
+from .metadata_processing.repair_precursor_is_parent_mass import \
     repair_precursor_is_parent_mass
-from .repair_parent_mass_from_smiles.repair_smiles_of_salts import \
-    repair_smiles_of_salts
-from .repair_parent_mass_from_smiles.require_parent_mass_match_smiles import \
+from .metadata_processing.repair_smiles_from_compound_name import \
+    repair_smiles_from_compound_name
+from .metadata_processing.repair_smiles_of_salts import repair_smiles_of_salts
+from .metadata_processing.require_correct_ionmode import \
+    require_correct_ionmode
+from .metadata_processing.require_parent_mass_match_smiles import \
     require_parent_mass_match_smiles
-from .repair_smiles_from_compound_name import repair_smiles_from_compound_name
-from .require_correct_ionmode import require_correct_ionmode
-from .require_minimum_number_of_peaks import require_minimum_number_of_peaks
-from .require_minimum_of_high_peaks import require_minimum_of_high_peaks
-from .require_precursor_below_mz import require_precursor_below_mz
-from .require_precursor_mz import require_precursor_mz
-from .require_valid_annotation import require_valid_annotation
-from .select_by_intensity import select_by_intensity
-from .select_by_mz import select_by_mz
-from .select_by_relative_intensity import select_by_relative_intensity
-from .set_ionmode_na_when_missing import set_ionmode_na_when_missing
+from .metadata_processing.require_precursor_below_mz import \
+    require_precursor_below_mz
+from .metadata_processing.require_precursor_mz import require_precursor_mz
+from .metadata_processing.require_valid_annotation import \
+    require_valid_annotation
+from .peak_processing.add_losses import add_losses
+from .peak_processing.normalize_intensities import normalize_intensities
+from .peak_processing.reduce_to_number_of_peaks import \
+    reduce_to_number_of_peaks
+from .peak_processing.remove_peaks_around_precursor_mz import \
+    remove_peaks_around_precursor_mz
+from .peak_processing.remove_peaks_outside_top_k import \
+    remove_peaks_outside_top_k
+from .peak_processing.require_minimum_number_of_peaks import \
+    require_minimum_number_of_peaks
+from .peak_processing.require_minimum_of_high_peaks import \
+    require_minimum_of_high_peaks
+from .peak_processing.select_by_intensity import select_by_intensity
+from .peak_processing.select_by_mz import select_by_mz
+from .peak_processing.select_by_relative_intensity import \
+    select_by_relative_intensity
 from .SpeciesString import SpeciesString
 
 
@@ -114,7 +131,6 @@ __all__ = [
     "interpret_pepmass",
     "make_charge_int",
     "make_charge_scalar",
-    "make_ionmode_lowercase",
     "normalize_intensities",
     "reduce_to_number_of_peaks",
     "remove_peaks_around_precursor_mz",
@@ -136,6 +152,5 @@ __all__ = [
     "select_by_intensity",
     "select_by_mz",
     "select_by_relative_intensity",
-    "set_ionmode_na_when_missing",
     "SpeciesString",
 ]
diff --git a/matchms/filtering/default_filters.py b/matchms/filtering/default_filters.py
index eba8d297..9c306984 100644
--- a/matchms/filtering/default_filters.py
+++ b/matchms/filtering/default_filters.py
@@ -1,15 +1,15 @@
-from ..typing import SpectrumType
-from .add_compound_name import add_compound_name
-from .add_precursor_mz import add_precursor_mz
-from .clean_compound_name import clean_compound_name
-from .correct_charge import correct_charge
-from .derive_adduct_from_name import derive_adduct_from_name
-from .derive_formula_from_name import derive_formula_from_name
-from .derive_ionmode import derive_ionmode
-from .interpret_pepmass import interpret_pepmass
-from .make_charge_int import make_charge_int
-from .make_ionmode_lowercase import make_ionmode_lowercase
-from .set_ionmode_na_when_missing import set_ionmode_na_when_missing
+from matchms.typing import SpectrumType
+from .metadata_processing.add_compound_name import add_compound_name
+from .metadata_processing.add_precursor_mz import add_precursor_mz
+from .metadata_processing.clean_compound_name import clean_compound_name
+from .metadata_processing.correct_charge import correct_charge
+from .metadata_processing.derive_adduct_from_name import \
+    derive_adduct_from_name
+from .metadata_processing.derive_formula_from_name import \
+    derive_formula_from_name
+from .metadata_processing.derive_ionmode import derive_ionmode
+from .metadata_processing.interpret_pepmass import interpret_pepmass
+from .metadata_processing.make_charge_int import make_charge_int
 
 
 def default_filters(spectrum: SpectrumType) -> SpectrumType:
@@ -18,22 +18,18 @@ def default_filters(spectrum: SpectrumType) -> SpectrumType:
 
     Collection is
 
-    1. :meth:`~matchms.filtering.make_charge_int`
-    2. :meth:`~matchms.filtering.make_ionmode_lowercase`
-    3. :meth:`~matchms.filtering.set_ionmode_na_when_missing`
-    4. :meth:`~matchms.filtering.add_compound_name`
-    5. :meth:`~matchms.filtering.derive_adduct_from_name`
-    6. :meth:`~matchms.filtering.derive_formula_from_name`
-    7. :meth:`~matchms.filtering.clean_compound_name`
-    8. :meth:`~matchms.filtering.interpret_pepmass`
-    9. :meth:`~matchms.filtering.add_precursor_mz`
-    10. :meth:`~matchms.filtering.derive_ionmode`
-    11. :meth:`~matchms.filtering.correct_charge`
+    1. :meth:`~matchms.filtering.metadata_processing.make_charge_int`
+    2. :meth:`~matchms.filtering.metadata_processing.add_compound_name`
+    3. :meth:`~matchms.filtering.metadata_processing.derive_adduct_from_name`
+    4. :meth:`~matchms.filtering.metadata_processing.derive_formula_from_name`
+    5. :meth:`~matchms.filtering.metadata_processing.clean_compound_name`
+    6. :meth:`~matchms.filtering.metadata_processing.interpret_pepmass`
+    7. :meth:`~matchms.filtering.metadata_processing.add_precursor_mz`
+    8. :meth:`~matchms.filtering.metadata_processing.derive_ionmode`
+    9. :meth:`~matchms.filtering.metadata_processing.correct_charge`
 
     """
     spectrum = make_charge_int(spectrum)
-    spectrum = make_ionmode_lowercase(spectrum)
-    spectrum = set_ionmode_na_when_missing(spectrum)
     spectrum = add_compound_name(spectrum)
     spectrum = derive_adduct_from_name(spectrum)
     spectrum = derive_formula_from_name(spectrum)
diff --git a/matchms/filtering/filter_utils/__init__.py b/matchms/filtering/filter_utils/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/matchms/filtering/filter_utils/derive_precursor_mz_and_parent_mass.py b/matchms/filtering/filter_utils/derive_precursor_mz_and_parent_mass.py
index c06c989b..6ed0f199 100644
--- a/matchms/filtering/filter_utils/derive_precursor_mz_and_parent_mass.py
+++ b/matchms/filtering/filter_utils/derive_precursor_mz_and_parent_mass.py
@@ -2,18 +2,17 @@ import logging
 from matchms.constants import PROTON_MASS
 from matchms.filtering.filter_utils.interpret_unknown_adduct import \
     get_multiplier_and_mass_from_adduct
-from matchms.filtering.repair_adduct.clean_adduct import (_clean_adduct,
-                                                          load_known_adducts)
+from matchms.filtering.metadata_processing.clean_adduct import (
+    _clean_adduct, load_known_adducts)
 
 
 logger = logging.getLogger("matchms")
 
 
-def derive_parent_mass_from_precursor_mz(spectrum_in, estimate_from_adduct):
-    if spectrum_in is None:
+def derive_parent_mass_from_precursor_mz(spectrum, estimate_from_adduct):
+    if spectrum is None:
         return None
 
-    spectrum = spectrum_in.clone()
     precursor_mz = spectrum.get("precursor_mz", None)
     if precursor_mz is None:
         logger.warning("Missing precursor m/z to derive parent mass.")
@@ -21,7 +20,8 @@ def derive_parent_mass_from_precursor_mz(spectrum_in, estimate_from_adduct):
     charge = _get_charge(spectrum)
 
     if estimate_from_adduct:
-        multiplier, correction_mass = _get_multiplier_and_correction_mass_from_adduct(spectrum.get("adduct"))
+        multiplier, correction_mass = _get_multiplier_and_correction_mass_from_adduct(
+            spectrum.get("adduct"))
         if correction_mass is not None and multiplier is not None:
             parent_mass = (precursor_mz - correction_mass) / multiplier
             return parent_mass
@@ -32,21 +32,22 @@ def derive_parent_mass_from_precursor_mz(spectrum_in, estimate_from_adduct):
         precursor_mass = precursor_mz * abs(charge)
         parent_mass = precursor_mass - protons_mass
         return parent_mass
+    return None
 
 
-def derive_precursor_mz_from_parent_mass(spectrum_in):
+def derive_precursor_mz_from_parent_mass(spectrum):
     """Derives the precursor_mz from the parent mass and adduct or charge"""
     estimate_from_adduct = True
-    if spectrum_in is None:
+    if spectrum is None:
         return None
 
-    spectrum = spectrum_in.clone()
     parent_mass = spectrum.get("parent_mass")
     if parent_mass is None:
         logger.warning("Missing parent mass to derive precursor mz.")
         return None
     if estimate_from_adduct:
-        multiplier, correction_mass = _get_multiplier_and_correction_mass_from_adduct(spectrum.get("adduct"))
+        multiplier, correction_mass = _get_multiplier_and_correction_mass_from_adduct(
+            spectrum.get("adduct"))
         if correction_mass is not None and multiplier is not None:
             precursor_mz = parent_mass * multiplier + correction_mass
             return precursor_mz
@@ -59,6 +60,7 @@ def derive_precursor_mz_from_parent_mass(spectrum_in):
         precursor_mz = precursor_mass / abs(charge)
         return precursor_mz
     logger.error("Precursor mz could not be derived from parent mass, since charge and adduct were missing")
+    return None
 
 
 def _get_multiplier_and_correction_mass_from_adduct(adduct):
diff --git a/matchms/filtering/filter_utils/interpret_unknown_adduct.py b/matchms/filtering/filter_utils/interpret_unknown_adduct.py
index 65661c39..6976d1fa 100644
--- a/matchms/filtering/filter_utils/interpret_unknown_adduct.py
+++ b/matchms/filtering/filter_utils/interpret_unknown_adduct.py
@@ -41,7 +41,7 @@ def get_multiplier_and_mass_from_adduct(adduct) -> Tuple[Optional[float], Option
     mass_of_ions = get_mass_of_ion(ions)
     if mass_of_ions is None:
         return None, None
-    added_mass = mass_of_ions + ELECTRTON_MASS * -charge
+    added_mass = mass_of_ions - ELECTRTON_MASS * charge
 
     multiplier = 1/abs(charge)*parent_mass
     correction_mass = added_mass/(abs(charge))
@@ -58,13 +58,15 @@ def get_ions_from_adduct(adduct):
     if "[" in adduct:
         ions_part = re.findall((r"\[(.*)\]"), adduct)
         if len(ions_part) != 1:
-            logger.warning(f"Expected to find brackets [] once, not the case in {adduct}")
+            logger.warning("Expected to find brackets [] once, not the case in %s",
+                           adduct)
             return None, None
         adduct = ions_part[0]
     # Finds the pattern M or 2M in adduct it makes sure it is in between
     parent_mass = re.findall(r'(?:^|[+-])([0-9]?M)(?:$|[+-])', adduct)
     if len(parent_mass) != 1:
-        logger.warning(f"The parent mass (e.g. 2M or M) was found {len(parent_mass)} times in {adduct}")
+        logger.warning("The parent mass (e.g. 2M or M) was found %s times in %s",
+                       len(parent_mass), adduct)
     parent_mass = parent_mass[0]
     if parent_mass == "M":
         parent_mass = 1
@@ -97,8 +99,7 @@ def replace_abbreviations(ions_split):
     corrected_ions = []
     for ion in ions_split:
         sign, number, ion = split_ion(ion)
-        if ion in abbrev_to_formula:
-            ion = abbrev_to_formula[ion]
+        ion = abbrev_to_formula.get(ion, ion)
         corrected_ions.append(sign + str(number) + ion)
     return corrected_ions
 
@@ -123,7 +124,8 @@ def get_mass_of_ion(ions):
 def get_charge_of_adduct(adduct)->Optional[int]:
     charge = re.findall((r"\]([0-9]?[+-])"), adduct)
     if len(charge) != 1:
-        logger.warning(f'Charge was found {len(charge)} times in adduct {adduct}')
+        logger.warning("Charge was found %s times in adduct %s",
+                       len(charge), adduct)
         return None
     charge = charge[0]
     if len(charge) == 1:
@@ -133,7 +135,7 @@ def get_charge_of_adduct(adduct)->Optional[int]:
         charge_size = charge[0]
         charge_sign = charge[1]
     else:
-        logger.warning(f"Charge is expected of length 1 or 2 {charge} was given")
+        logger.warning("Charge is expected of length 1 or 2, but %s was given", charge)
         return None
     return int(charge_sign+charge_size)
 
@@ -149,15 +151,15 @@ def get_mass_of_formula(formula):
     parts = re.findall("[A-Z][a-z]?|[0-9]+", formula)
     mass = 0
 
-    for index in range(len(parts)):
-        if parts[index].isnumeric():
+    for i, part in enumerate(parts):
+        if part.isnumeric():
             continue
         periodic_table = Chem.GetPeriodicTable()
         try:
-            atom_mass = periodic_table.GetMostCommonIsotopeMass(parts[index])
+            atom_mass = periodic_table.GetMostCommonIsotopeMass(part)
         except RuntimeError:
-            logger.warning("The atom: %s in the formula %s is not known", parts[index], formula)
+            logger.warning("The atom: %s in the formula %s is not known", part, formula)
             return None
-        multiplier = int(parts[index + 1]) if len(parts) > index + 1 and parts[index + 1].isnumeric() else 1
+        multiplier = int(parts[i + 1]) if len(parts) > i + 1 and parts[i + 1].isnumeric() else 1
         mass += atom_mass * multiplier
     return mass
diff --git a/matchms/filtering/make_ionmode_lowercase.py b/matchms/filtering/make_ionmode_lowercase.py
deleted file mode 100644
index f628013f..00000000
--- a/matchms/filtering/make_ionmode_lowercase.py
+++ /dev/null
@@ -1,15 +0,0 @@
-from ..typing import SpectrumType
-
-
-def make_ionmode_lowercase(spectrum_in: SpectrumType) -> SpectrumType:
-    """Convert entry in field "ionmode" to lower case."""
-    if spectrum_in is None:
-        return None
-
-    spectrum = spectrum_in.clone()
-
-    # if the ionmode key exists in the metadata, lowercase its value
-    if spectrum.get("ionmode") is not None:
-        spectrum.set("ionmode", spectrum.get("ionmode").lower())
-
-    return spectrum
diff --git a/matchms/filtering/metadata_processing/__init__.py b/matchms/filtering/metadata_processing/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/matchms/filtering/add_compound_name.py b/matchms/filtering/metadata_processing/add_compound_name.py
similarity index 94%
rename from matchms/filtering/add_compound_name.py
rename to matchms/filtering/metadata_processing/add_compound_name.py
index 333cc188..2a3264fd 100644
--- a/matchms/filtering/add_compound_name.py
+++ b/matchms/filtering/metadata_processing/add_compound_name.py
@@ -1,5 +1,5 @@
 import logging
-from ..typing import SpectrumType
+from matchms.typing import SpectrumType
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/add_fingerprint.py b/matchms/filtering/metadata_processing/add_fingerprint.py
similarity index 91%
rename from matchms/filtering/add_fingerprint.py
rename to matchms/filtering/metadata_processing/add_fingerprint.py
index db5194f8..b48ba586 100644
--- a/matchms/filtering/add_fingerprint.py
+++ b/matchms/filtering/metadata_processing/add_fingerprint.py
@@ -1,8 +1,8 @@
 import logging
 import numpy as np
-from ..metadata_utils import (derive_fingerprint_from_inchi,
-                              derive_fingerprint_from_smiles)
-from ..typing import SpectrumType
+from matchms.typing import SpectrumType
+from ...metadata_utils import (derive_fingerprint_from_inchi,
+                               derive_fingerprint_from_smiles)
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/add_parent_mass.py b/matchms/filtering/metadata_processing/add_parent_mass.py
similarity index 97%
rename from matchms/filtering/add_parent_mass.py
rename to matchms/filtering/metadata_processing/add_parent_mass.py
index 772867de..ab620331 100644
--- a/matchms/filtering/add_parent_mass.py
+++ b/matchms/filtering/metadata_processing/add_parent_mass.py
@@ -1,8 +1,8 @@
 import logging
 from matchms.filtering.filter_utils.derive_precursor_mz_and_parent_mass import \
     derive_parent_mass_from_precursor_mz
-from ..typing import SpectrumType
-from ..utils import get_first_common_element
+from matchms.typing import SpectrumType
+from ...utils import get_first_common_element
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/add_precursor_mz.py b/matchms/filtering/metadata_processing/add_precursor_mz.py
similarity index 100%
rename from matchms/filtering/add_precursor_mz.py
rename to matchms/filtering/metadata_processing/add_precursor_mz.py
diff --git a/matchms/filtering/add_retention.py b/matchms/filtering/metadata_processing/add_retention.py
similarity index 95%
rename from matchms/filtering/add_retention.py
rename to matchms/filtering/metadata_processing/add_retention.py
index c6673573..7bae32d8 100644
--- a/matchms/filtering/add_retention.py
+++ b/matchms/filtering/metadata_processing/add_retention.py
@@ -1,131 +1,131 @@
-import logging
-from typing import Any, List, Optional
-from matchms.utils import filter_none, get_common_keys
-from ..typing import SpectrumType
-
-
-logger = logging.getLogger("matchms")
-
-
-_retention_time_keys = ["retention_time", "retentiontime", "rt", "scan_start_time",
-                        "rt_query", "rtinseconds"]
-_retention_index_keys = ["retention_index", "retentionindex", "ri"]
-
-
-def safe_store_value(metadata: dict, value: Any, target_key: str) -> dict:
-    """Helper function to safely store a value in the target key without throwing an exception, but storing 'None' instead.
-
-    Parameters
-    ----------
-    spectrum
-        Spectrum to which to add 'value' in 'target_key'.
-    value
-        Value to parse into 'target_key'.
-    target_key
-        Name of the key in which to store the value.
-
-    Returns
-    -------
-    Spectrum with added key.
-    """
-    if value is not None:   # one of accepted keys is present
-        value = safe_convert_to_float(value)
-    metadata[target_key] = value
-    return metadata
-
-
-def safe_convert_to_float(value: Any) -> Optional[float]:
-    """Safely convert value to float. Return 'None' on failure.
-
-    Parameters
-    ----------
-    value
-        Object to convert to float.
-
-    Returns
-    -------
-    Converted float value or 'None' if conversion is not possible.
-    """
-    if isinstance(value, list):
-        if len(value) == 1:
-            value = value[0]
-        else:
-            return None
-    try:
-        value = float(value)
-        rt = value if value >= 0 else None  # discard negative RT values
-    except (ValueError, TypeError):
-        logger.warning("%s can't be converted to float.", str(value))
-        rt = None
-    return rt
-
-
-def _add_retention(metadata: dict, target_key: str, accepted_keys: List[str]) -> dict:
-    """Add value from one of accepted keys to target key.
-
-    Parameters
-    ----------
-    spectrum
-        Spectrum from which to read the values.
-    target_key
-        Key under which to store the value.
-    accepted_keys
-        List of accepted keys from which a value will be read (in order).
-
-    Returns
-    -------
-    Spectrum with value from first accepted key stored under target_key.
-    """
-    common_keys = get_common_keys(metadata.keys(), accepted_keys)
-    values_for_keys = filter_none([metadata[key] for key in common_keys])
-    values = list(map(safe_convert_to_float, values_for_keys))
-    value = next(filter_none(values), None)
-
-    metadata = safe_store_value(metadata, value, target_key)
-    return metadata
-
-
-def add_retention_time(spectrum_in: SpectrumType) -> SpectrumType:
-    """Add retention time information to the 'retention_time' key as float.
-    Negative values and those not convertible to a float result in 'retention_time'
-    being 'None'.
-
-    Parameters
-    ----------
-    spectrum
-        Spectrum with retention time information.
-
-    Returns
-    -------
-    Spectrum with harmonized retention time information.
-    """
-    if spectrum_in is None:
-        return None
-
-    spectrum = spectrum_in.clone()
-
-    target_key = "retention_time"
-    spectrum.metadata = _add_retention(spectrum.metadata, target_key, _retention_time_keys)
-    return spectrum
-
-
-def add_retention_index(spectrum_in: SpectrumType) -> SpectrumType:
-    """Add retention index into 'retention_index' key if present.
-
-
-    Parameters
-    ----------
-    spectrum
-        Spectrum with RI information.
-    Returns
-    -------
-    Spectrum with RI info stored under 'retention_index'.
-    """
-    if spectrum_in is None:
-        return None
-
-    spectrum = spectrum_in.clone()
-
-    target_key = "retention_index"
-    spectrum.metadata = _add_retention(spectrum.metadata, target_key, _retention_index_keys)
-    return spectrum
+import logging
+from typing import Any, List, Optional
+from matchms.typing import SpectrumType
+from matchms.utils import filter_none, get_common_keys
+
+
+logger = logging.getLogger("matchms")
+
+
+_retention_time_keys = ["retention_time", "retentiontime", "rt", "scan_start_time",
+                        "rt_query", "rtinseconds"]
+_retention_index_keys = ["retention_index", "retentionindex", "ri"]
+
+
+def safe_store_value(metadata: dict, value: Any, target_key: str) -> dict:
+    """Helper function to safely store a value in the target key without throwing an exception, but storing 'None' instead.
+
+    Parameters
+    ----------
+    spectrum
+        Spectrum to which to add 'value' in 'target_key'.
+    value
+        Value to parse into 'target_key'.
+    target_key
+        Name of the key in which to store the value.
+
+    Returns
+    -------
+    Spectrum with added key.
+    """
+    if value is not None:   # one of accepted keys is present
+        value = safe_convert_to_float(value)
+    metadata[target_key] = value
+    return metadata
+
+
+def safe_convert_to_float(value: Any) -> Optional[float]:
+    """Safely convert value to float. Return 'None' on failure.
+
+    Parameters
+    ----------
+    value
+        Object to convert to float.
+
+    Returns
+    -------
+    Converted float value or 'None' if conversion is not possible.
+    """
+    if isinstance(value, list):
+        if len(value) == 1:
+            value = value[0]
+        else:
+            return None
+    try:
+        value = float(value)
+        rt = value if value >= 0 else None  # discard negative RT values
+    except (ValueError, TypeError):
+        logger.warning("%s can't be converted to float.", str(value))
+        rt = None
+    return rt
+
+
+def _add_retention(metadata: dict, target_key: str, accepted_keys: List[str]) -> dict:
+    """Add value from one of accepted keys to target key.
+
+    Parameters
+    ----------
+    spectrum
+        Spectrum from which to read the values.
+    target_key
+        Key under which to store the value.
+    accepted_keys
+        List of accepted keys from which a value will be read (in order).
+
+    Returns
+    -------
+    Spectrum with value from first accepted key stored under target_key.
+    """
+    common_keys = get_common_keys(metadata.keys(), accepted_keys)
+    values_for_keys = filter_none([metadata[key] for key in common_keys])
+    values = list(map(safe_convert_to_float, values_for_keys))
+    value = next(filter_none(values), None)
+
+    metadata = safe_store_value(metadata, value, target_key)
+    return metadata
+
+
+def add_retention_time(spectrum_in: SpectrumType) -> SpectrumType:
+    """Add retention time information to the 'retention_time' key as float.
+    Negative values and those not convertible to a float result in 'retention_time'
+    being 'None'.
+
+    Parameters
+    ----------
+    spectrum
+        Spectrum with retention time information.
+
+    Returns
+    -------
+    Spectrum with harmonized retention time information.
+    """
+    if spectrum_in is None:
+        return None
+
+    spectrum = spectrum_in.clone()
+
+    target_key = "retention_time"
+    spectrum.metadata = _add_retention(spectrum.metadata, target_key, _retention_time_keys)
+    return spectrum
+
+
+def add_retention_index(spectrum_in: SpectrumType) -> SpectrumType:
+    """Add retention index into 'retention_index' key if present.
+
+
+    Parameters
+    ----------
+    spectrum
+        Spectrum with RI information.
+    Returns
+    -------
+    Spectrum with RI info stored under 'retention_index'.
+    """
+    if spectrum_in is None:
+        return None
+
+    spectrum = spectrum_in.clone()
+
+    target_key = "retention_index"
+    spectrum.metadata = _add_retention(spectrum.metadata, target_key, _retention_index_keys)
+    return spectrum
diff --git a/matchms/filtering/repair_adduct/clean_adduct.py b/matchms/filtering/metadata_processing/clean_adduct.py
similarity index 94%
rename from matchms/filtering/repair_adduct/clean_adduct.py
rename to matchms/filtering/metadata_processing/clean_adduct.py
index 7709bf42..7460409d 100644
--- a/matchms/filtering/repair_adduct/clean_adduct.py
+++ b/matchms/filtering/metadata_processing/clean_adduct.py
@@ -11,6 +11,14 @@ logger = logging.getLogger("matchms")
 
 
 def clean_adduct(spectrum_in):
+    """Clean adduct and make it consistent in style.
+    Will transform adduct strings of type 'M+H+' to '[M+H]+'.
+
+    Parameters
+    ----------
+    spectrum_in
+        Matchms Spectrum object.
+    """
     if spectrum_in is None:
         return None
     spectrum = spectrum_in.clone()
diff --git a/matchms/filtering/clean_compound_name.py b/matchms/filtering/metadata_processing/clean_compound_name.py
similarity index 98%
rename from matchms/filtering/clean_compound_name.py
rename to matchms/filtering/metadata_processing/clean_compound_name.py
index a73c0881..bb60e637 100644
--- a/matchms/filtering/clean_compound_name.py
+++ b/matchms/filtering/metadata_processing/clean_compound_name.py
@@ -1,6 +1,6 @@
 import logging
 import re
-from ..typing import SpectrumType
+from matchms.typing import SpectrumType
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/correct_charge.py b/matchms/filtering/metadata_processing/correct_charge.py
similarity index 97%
rename from matchms/filtering/correct_charge.py
rename to matchms/filtering/metadata_processing/correct_charge.py
index b216ffef..66d7e6f1 100644
--- a/matchms/filtering/correct_charge.py
+++ b/matchms/filtering/metadata_processing/correct_charge.py
@@ -1,6 +1,6 @@
 import logging
 import numpy as np
-from ..typing import SpectrumType
+from matchms.typing import SpectrumType
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/derive_adduct_from_name.py b/matchms/filtering/metadata_processing/derive_adduct_from_name.py
similarity index 95%
rename from matchms/filtering/derive_adduct_from_name.py
rename to matchms/filtering/metadata_processing/derive_adduct_from_name.py
index 81d6d8ff..a365c1fc 100644
--- a/matchms/filtering/derive_adduct_from_name.py
+++ b/matchms/filtering/metadata_processing/derive_adduct_from_name.py
@@ -1,7 +1,7 @@
 import logging
 import re
-from ..typing import SpectrumType
-from .repair_adduct.clean_adduct import _clean_adduct, load_known_adducts
+from matchms.typing import SpectrumType
+from .clean_adduct import _clean_adduct, load_known_adducts
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/derive_formula_from_name.py b/matchms/filtering/metadata_processing/derive_formula_from_name.py
similarity index 98%
rename from matchms/filtering/derive_formula_from_name.py
rename to matchms/filtering/metadata_processing/derive_formula_from_name.py
index 604c1aca..49c66b8f 100644
--- a/matchms/filtering/derive_formula_from_name.py
+++ b/matchms/filtering/metadata_processing/derive_formula_from_name.py
@@ -1,6 +1,6 @@
 import logging
 import re
-from ..typing import SpectrumType
+from matchms.typing import SpectrumType
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/derive_inchi_from_smiles.py b/matchms/filtering/metadata_processing/derive_inchi_from_smiles.py
similarity index 82%
rename from matchms/filtering/derive_inchi_from_smiles.py
rename to matchms/filtering/metadata_processing/derive_inchi_from_smiles.py
index 6af1eba7..62b7bd51 100644
--- a/matchms/filtering/derive_inchi_from_smiles.py
+++ b/matchms/filtering/metadata_processing/derive_inchi_from_smiles.py
@@ -1,7 +1,7 @@
 import logging
-from ..metadata_utils import (convert_smiles_to_inchi, is_valid_inchi,
-                              is_valid_smiles)
-from ..typing import SpectrumType
+from matchms.typing import SpectrumType
+from ...metadata_utils import (convert_smiles_to_inchi, is_valid_inchi,
+                               is_valid_smiles)
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/derive_inchikey_from_inchi.py b/matchms/filtering/metadata_processing/derive_inchikey_from_inchi.py
similarity index 82%
rename from matchms/filtering/derive_inchikey_from_inchi.py
rename to matchms/filtering/metadata_processing/derive_inchikey_from_inchi.py
index 1cc8694a..7234694b 100644
--- a/matchms/filtering/derive_inchikey_from_inchi.py
+++ b/matchms/filtering/metadata_processing/derive_inchikey_from_inchi.py
@@ -1,7 +1,7 @@
 import logging
-from ..metadata_utils import (convert_inchi_to_inchikey, is_valid_inchi,
-                              is_valid_inchikey)
-from ..typing import SpectrumType
+from matchms.typing import SpectrumType
+from ...metadata_utils import (convert_inchi_to_inchikey, is_valid_inchi,
+                               is_valid_inchikey)
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/derive_ionmode.py b/matchms/filtering/metadata_processing/derive_ionmode.py
similarity index 92%
rename from matchms/filtering/derive_ionmode.py
rename to matchms/filtering/metadata_processing/derive_ionmode.py
index 8c58d8a9..e4fe76bc 100644
--- a/matchms/filtering/derive_ionmode.py
+++ b/matchms/filtering/metadata_processing/derive_ionmode.py
@@ -1,6 +1,6 @@
 import logging
-from ..typing import SpectrumType
-from .repair_adduct.clean_adduct import _clean_adduct, load_known_adducts
+from matchms.typing import SpectrumType
+from .clean_adduct import _clean_adduct, load_known_adducts
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/derive_smiles_from_inchi.py b/matchms/filtering/metadata_processing/derive_smiles_from_inchi.py
similarity index 82%
rename from matchms/filtering/derive_smiles_from_inchi.py
rename to matchms/filtering/metadata_processing/derive_smiles_from_inchi.py
index 16300286..de13847f 100644
--- a/matchms/filtering/derive_smiles_from_inchi.py
+++ b/matchms/filtering/metadata_processing/derive_smiles_from_inchi.py
@@ -1,7 +1,7 @@
 import logging
-from ..metadata_utils import (convert_inchi_to_smiles, is_valid_inchi,
-                              is_valid_smiles)
-from ..typing import SpectrumType
+from matchms.typing import SpectrumType
+from ...metadata_utils import (convert_inchi_to_smiles, is_valid_inchi,
+                               is_valid_smiles)
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/harmonize_undefined_inchi.py b/matchms/filtering/metadata_processing/harmonize_undefined_inchi.py
similarity index 96%
rename from matchms/filtering/harmonize_undefined_inchi.py
rename to matchms/filtering/metadata_processing/harmonize_undefined_inchi.py
index e43b1fe3..7c8ad04a 100644
--- a/matchms/filtering/harmonize_undefined_inchi.py
+++ b/matchms/filtering/metadata_processing/harmonize_undefined_inchi.py
@@ -1,5 +1,5 @@
 from typing import List
-from ..typing import SpectrumType
+from matchms.typing import SpectrumType
 
 
 def harmonize_undefined_inchi(spectrum_in: SpectrumType, undefined: str = "",
diff --git a/matchms/filtering/harmonize_undefined_inchikey.py b/matchms/filtering/metadata_processing/harmonize_undefined_inchikey.py
similarity index 96%
rename from matchms/filtering/harmonize_undefined_inchikey.py
rename to matchms/filtering/metadata_processing/harmonize_undefined_inchikey.py
index 55542006..08463df8 100644
--- a/matchms/filtering/harmonize_undefined_inchikey.py
+++ b/matchms/filtering/metadata_processing/harmonize_undefined_inchikey.py
@@ -1,5 +1,5 @@
 from typing import List
-from ..typing import SpectrumType
+from matchms.typing import SpectrumType
 
 
 def harmonize_undefined_inchikey(spectrum_in: SpectrumType, undefined: str = "",
diff --git a/matchms/filtering/harmonize_undefined_smiles.py b/matchms/filtering/metadata_processing/harmonize_undefined_smiles.py
similarity index 96%
rename from matchms/filtering/harmonize_undefined_smiles.py
rename to matchms/filtering/metadata_processing/harmonize_undefined_smiles.py
index 377d9b97..3eebee7d 100644
--- a/matchms/filtering/harmonize_undefined_smiles.py
+++ b/matchms/filtering/metadata_processing/harmonize_undefined_smiles.py
@@ -1,5 +1,5 @@
 from typing import List
-from ..typing import SpectrumType
+from matchms.typing import SpectrumType
 
 
 def harmonize_undefined_smiles(spectrum_in: SpectrumType, undefined: str = "",
diff --git a/matchms/filtering/interpret_pepmass.py b/matchms/filtering/metadata_processing/interpret_pepmass.py
similarity index 98%
rename from matchms/filtering/interpret_pepmass.py
rename to matchms/filtering/metadata_processing/interpret_pepmass.py
index d0cb1faa..80a0466b 100644
--- a/matchms/filtering/interpret_pepmass.py
+++ b/matchms/filtering/metadata_processing/interpret_pepmass.py
@@ -1,5 +1,5 @@
 import logging
-from ..filtering.make_charge_int import _convert_charge_to_int
+from .make_charge_int import _convert_charge_to_int
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/make_charge_int.py b/matchms/filtering/metadata_processing/make_charge_int.py
similarity index 96%
rename from matchms/filtering/make_charge_int.py
rename to matchms/filtering/metadata_processing/make_charge_int.py
index 06ea61c0..2c888406 100644
--- a/matchms/filtering/make_charge_int.py
+++ b/matchms/filtering/metadata_processing/make_charge_int.py
@@ -1,5 +1,5 @@
 import logging
-from ..typing import SpectrumType
+from matchms.typing import SpectrumType
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/make_charge_scalar.py b/matchms/filtering/metadata_processing/make_charge_scalar.py
similarity index 90%
rename from matchms/filtering/make_charge_scalar.py
rename to matchms/filtering/metadata_processing/make_charge_scalar.py
index 15419236..04ebfea6 100644
--- a/matchms/filtering/make_charge_scalar.py
+++ b/matchms/filtering/metadata_processing/make_charge_scalar.py
@@ -1,5 +1,5 @@
 from deprecated.sphinx import deprecated
-from ..typing import SpectrumType
+from matchms.typing import SpectrumType
 from .make_charge_int import make_charge_int
 
 
diff --git a/matchms/filtering/repair_adduct/repair_adduct_based_on_smiles.py b/matchms/filtering/metadata_processing/repair_adduct_based_on_smiles.py
similarity index 77%
rename from matchms/filtering/repair_adduct/repair_adduct_based_on_smiles.py
rename to matchms/filtering/metadata_processing/repair_adduct_based_on_smiles.py
index af94a42b..02ee445c 100644
--- a/matchms/filtering/repair_adduct/repair_adduct_based_on_smiles.py
+++ b/matchms/filtering/metadata_processing/repair_adduct_based_on_smiles.py
@@ -2,9 +2,9 @@ import logging
 from matchms import Spectrum
 from matchms.filtering.filter_utils.get_neutral_mass_from_smiles import \
     get_monoisotopic_neutral_mass
-from matchms.filtering.repair_adduct.clean_adduct import load_known_adducts
-from matchms.filtering.repair_parent_mass_from_smiles.repair_parent_mass_is_mol_wt import \
-    repair_parent_mass_is_mol_wt
+from matchms.filtering.metadata_processing.clean_adduct import \
+    load_known_adducts
+from .repair_parent_mass_is_mol_wt import repair_parent_mass_is_mol_wt
 
 
 logger = logging.getLogger("matchms")
@@ -22,7 +22,8 @@ def repair_adduct_based_on_smiles(spectrum_in: Spectrum,
     precursor_mz = changed_spectrum.get("precursor_mz")
     ion_mode = changed_spectrum.get("ionmode")
     if ion_mode not in ("positive", "negative"):
-        logger.warning(f"Ionmode: {ion_mode} not positive or negative, first run derive_ionmode")
+        logger.warning("Ionmode: %s not positive or negative, first run derive_ionmode",
+                        ion_mode)
         return changed_spectrum
     if precursor_mz is None:
         logger.warning("Precursor_mz is None, first run add_precursor_mz")
@@ -41,11 +42,13 @@ def repair_adduct_based_on_smiles(spectrum_in: Spectrum,
     changed_spectrum.set("parent_mass", parent_mass)
     changed_spectrum.set("adduct", adduct)
     if mass_differences[smalles_mass_index] < mass_tolerance:
-        logger.info(f"Adduct was set from {spectrum_in.get('adduct')} to {adduct}")
+        logger.info("Adduct was set from %s to %s",
+                    spectrum_in.get('adduct'), adduct)
         return changed_spectrum
-    elif accept_parent_mass_is_mol_wt:
+    if accept_parent_mass_is_mol_wt:
         changed_spectrum = repair_parent_mass_is_mol_wt(changed_spectrum, mass_tolerance)
         if abs(changed_spectrum.get("parent_mass") - smiles_mass) < mass_tolerance:
-            logger.info(f"Adduct was set from {spectrum_in.get('adduct')} to {adduct}")
+            logger.info("Adduct was set from %s to %s",
+                        spectrum_in.get('adduct'), adduct)
             return changed_spectrum
     return spectrum_in
diff --git a/matchms/filtering/repair_inchi_inchikey_smiles.py b/matchms/filtering/metadata_processing/repair_inchi_inchikey_smiles.py
similarity index 92%
rename from matchms/filtering/repair_inchi_inchikey_smiles.py
rename to matchms/filtering/metadata_processing/repair_inchi_inchikey_smiles.py
index 4eddc161..2497b082 100644
--- a/matchms/filtering/repair_inchi_inchikey_smiles.py
+++ b/matchms/filtering/metadata_processing/repair_inchi_inchikey_smiles.py
@@ -1,5 +1,5 @@
-from ..typing import SpectrumType
-from .SpeciesString import SpeciesString
+from matchms.filtering.SpeciesString import SpeciesString
+from matchms.typing import SpectrumType
 
 
 def repair_inchi_inchikey_smiles(spectrum_in: SpectrumType) -> SpectrumType:
diff --git a/matchms/filtering/repair_parent_mass_from_smiles/repair_parent_mass_is_mol_wt.py b/matchms/filtering/metadata_processing/repair_parent_mass_is_mol_wt.py
similarity index 88%
rename from matchms/filtering/repair_parent_mass_from_smiles/repair_parent_mass_is_mol_wt.py
rename to matchms/filtering/metadata_processing/repair_parent_mass_is_mol_wt.py
index d5e74f26..747037d8 100644
--- a/matchms/filtering/repair_parent_mass_from_smiles/repair_parent_mass_is_mol_wt.py
+++ b/matchms/filtering/metadata_processing/repair_parent_mass_is_mol_wt.py
@@ -4,8 +4,7 @@ from matchms.filtering.filter_utils.derive_precursor_mz_and_parent_mass import \
     derive_precursor_mz_from_parent_mass
 from matchms.filtering.filter_utils.get_neutral_mass_from_smiles import (
     get_molecular_weight_neutral_mass, get_monoisotopic_neutral_mass)
-from matchms.filtering.repair_parent_mass_from_smiles.require_parent_mass_match_smiles import \
-    require_parent_mass_match_smiles
+from .require_parent_mass_match_smiles import require_parent_mass_match_smiles
 
 
 logger = logging.getLogger("matchms")
@@ -33,7 +32,8 @@ def repair_parent_mass_is_mol_wt(spectrum_in: Spectrum, mass_tolerance: float):
     if abs(mass_difference) < mass_tolerance:
         correct_mass = get_monoisotopic_neutral_mass(smiles)
         spectrum.set("parent_mass", correct_mass)
-        logger.info(f"Parent mass was mol_wt corrected from {parent_mass} to {correct_mass}")
+        logger.info("Parent mass was mol_wt corrected from %s to %s",
+                    parent_mass, correct_mass)
         precursor_mz = derive_precursor_mz_from_parent_mass(spectrum)
         logger.info("Precursor mz was derived from parent mass")
         spectrum.set("precursor_mz", precursor_mz)
diff --git a/matchms/filtering/repair_parent_mass_from_smiles/repair_parent_mass_match_smiles_wrapper.py b/matchms/filtering/metadata_processing/repair_parent_mass_match_smiles_wrapper.py
similarity index 69%
rename from matchms/filtering/repair_parent_mass_from_smiles/repair_parent_mass_match_smiles_wrapper.py
rename to matchms/filtering/metadata_processing/repair_parent_mass_match_smiles_wrapper.py
index 527c9b19..eb209f88 100644
--- a/matchms/filtering/repair_parent_mass_from_smiles/repair_parent_mass_match_smiles_wrapper.py
+++ b/matchms/filtering/metadata_processing/repair_parent_mass_match_smiles_wrapper.py
@@ -1,16 +1,12 @@
 import logging
 from typing import Optional
-from matchms.filtering.repair_adduct.repair_adduct_based_on_smiles import \
+from matchms.filtering.metadata_processing.repair_adduct_based_on_smiles import \
     repair_adduct_based_on_smiles
-from matchms.filtering.repair_parent_mass_from_smiles.repair_parent_mass_is_mol_wt import \
-    repair_parent_mass_is_mol_wt
-from matchms.filtering.repair_parent_mass_from_smiles.repair_precursor_is_parent_mass import \
-    repair_precursor_is_parent_mass
-from matchms.filtering.repair_parent_mass_from_smiles.repair_smiles_of_salts import \
-    repair_smiles_of_salts
-from matchms.filtering.repair_parent_mass_from_smiles.require_parent_mass_match_smiles import \
-    require_parent_mass_match_smiles
 from matchms.typing import SpectrumType
+from .repair_parent_mass_is_mol_wt import repair_parent_mass_is_mol_wt
+from .repair_precursor_is_parent_mass import repair_precursor_is_parent_mass
+from .repair_smiles_of_salts import repair_smiles_of_salts
+from .require_parent_mass_match_smiles import require_parent_mass_match_smiles
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/repair_parent_mass_from_smiles/repair_precursor_is_parent_mass.py b/matchms/filtering/metadata_processing/repair_precursor_is_parent_mass.py
similarity index 92%
rename from matchms/filtering/repair_parent_mass_from_smiles/repair_precursor_is_parent_mass.py
rename to matchms/filtering/metadata_processing/repair_precursor_is_parent_mass.py
index e61ab722..8478a0b2 100644
--- a/matchms/filtering/repair_parent_mass_from_smiles/repair_precursor_is_parent_mass.py
+++ b/matchms/filtering/metadata_processing/repair_precursor_is_parent_mass.py
@@ -4,8 +4,7 @@ from matchms.filtering.filter_utils.derive_precursor_mz_and_parent_mass import \
     derive_precursor_mz_from_parent_mass
 from matchms.filtering.filter_utils.get_neutral_mass_from_smiles import \
     get_monoisotopic_neutral_mass
-from matchms.filtering.repair_parent_mass_from_smiles.require_parent_mass_match_smiles import \
-    require_parent_mass_match_smiles
+from .require_parent_mass_match_smiles import require_parent_mass_match_smiles
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/repair_smiles_from_compound_name.py b/matchms/filtering/metadata_processing/repair_smiles_from_compound_name.py
similarity index 91%
rename from matchms/filtering/repair_smiles_from_compound_name.py
rename to matchms/filtering/metadata_processing/repair_smiles_from_compound_name.py
index 6c58df62..78b58189 100644
--- a/matchms/filtering/repair_smiles_from_compound_name.py
+++ b/matchms/filtering/metadata_processing/repair_smiles_from_compound_name.py
@@ -17,14 +17,17 @@ def repair_smiles_from_compound_name(spectrum_in: Spectrum,
     Based on a table of compound names and smiles matches (stored in a csv file) this function
     adds the new annotations to the input spectrums if the smiles seem consistent with the available
     spectrum metadata (e.g., parent mass).
-    This function can be used with csv files that are returned by the pubchem_lookup.py from matchmextras.
+    This function can be used with csv files that are returned by the pubchem_lookup.py
+    from matchmextras.
+
     Parameters
     ----------
     spectrum_in:
-        The input spectrum
+        The input spectrum.
     annotated_compound_names_file: str
-        A csv file containing the compound names and matching smiles, inchi, inchikey and monoisotopic_mass.
-    mass_tolerance
+        A csv file containing the compound names and matching smiles, inchi, inchikey
+        and monoisotopic_mass.
+    mass_tolerance.
         Acceptable mass difference between query compound and pubchem result.
     """
     annotated_compound_names = load_compond_name_annotations(annotated_compound_names_file)
@@ -61,6 +64,9 @@ def load_compond_name_annotations(annotated_compound_names_file):
 
 
 def check_fully_annotated(spectrum: Spectrum) -> bool:
+    """Combine multiple check functions.
+    Returns False if SMILES, InChIKey, or InChI are missing.
+    """
     if not is_valid_smiles(spectrum.get("smiles")):
         return False
     if not is_valid_inchikey(spectrum.get("inchikey")):
@@ -71,4 +77,5 @@ def check_fully_annotated(spectrum: Spectrum) -> bool:
 
 
 def is_plausible_name(compound_name):
+    """Simple check if it can be a compound name."""
     return isinstance(compound_name, str) and len(compound_name) > 4
diff --git a/matchms/filtering/repair_parent_mass_from_smiles/repair_smiles_of_salts.py b/matchms/filtering/metadata_processing/repair_smiles_of_salts.py
similarity index 91%
rename from matchms/filtering/repair_parent_mass_from_smiles/repair_smiles_of_salts.py
rename to matchms/filtering/metadata_processing/repair_smiles_of_salts.py
index 49355f7c..a1d62898 100644
--- a/matchms/filtering/repair_parent_mass_from_smiles/repair_smiles_of_salts.py
+++ b/matchms/filtering/metadata_processing/repair_smiles_of_salts.py
@@ -30,9 +30,11 @@ def repair_smiles_of_salts(spectrum_in,
             spectrum_with_ions = spectrum.clone()
             spectrum_with_ions.set("smiles", ion)
             spectrum_with_ions.set("salt_ions", not_used_ions)
-            logger.info(f"Removed salt ions: {not_used_ions} from {smiles} to match parent mass")
+            logger.info("Removed salt ions: %s from %s to match parent mass",
+                        not_used_ions, smiles)
             return spectrum_with_ions
-    logger.warning("None of the parts of the smile %s match the parent mass: %s", smiles, parent_mass)
+    logger.warning("None of the parts of the smile %s match the parent mass: %s",
+                   smiles, parent_mass)
     return spectrum
 
 
diff --git a/matchms/filtering/metadata_processing/require_correct_ionmode.py b/matchms/filtering/metadata_processing/require_correct_ionmode.py
new file mode 100644
index 00000000..9a92f666
--- /dev/null
+++ b/matchms/filtering/metadata_processing/require_correct_ionmode.py
@@ -0,0 +1,45 @@
+import logging
+from typing import Optional
+from matchms.typing import SpectrumType
+
+
+logger = logging.getLogger("matchms")
+
+
+def require_correct_ionmode(spectrum_in: SpectrumType,
+                            ion_mode_to_keep) -> Optional[SpectrumType]:
+    """
+    Validates the ion mode of a given spectrum. If the spectrum's ion mode 
+    doesn't match the `ion_mode_to_keep`, it will be removed and a log message 
+    will be generated.
+
+    Parameters
+    ----------
+    spectrum_in: Spectrum
+        The input spectrum to be validated. If `None`, the function will return `None`.
+
+    ion_mode_to_keep: str
+        Desired ion mode ('positive', 'negative', or 'both'). If not one of these, 
+        a `ValueError` is raised.
+
+    Returns
+    -------
+    Spectrum or None
+        The validated spectrum if its ion mode matches the desired one, or `None` otherwise.
+    """
+    if spectrum_in is None:
+        return None
+    spectrum = spectrum_in.clone()
+    if ion_mode_to_keep not in {"positive", "negative", "both"}:
+        raise ValueError("ion_mode_to_keep should be 'positive', 'negative' or 'both'")
+    ion_mode = spectrum.get("ionmode")
+    if ion_mode_to_keep == "both":
+        if ion_mode in ("positive", "negative"):
+            return spectrum
+
+        logger.info("Spectrum was removed since ionmode was: %s which does not match positive or negative", ion_mode)
+        return None
+    if ion_mode == ion_mode_to_keep:
+        return spectrum
+    logger.info("Spectrum was removed since ionmode was: %s which does not match %s", ion_mode, ion_mode_to_keep)
+    return None
diff --git a/matchms/filtering/metadata_processing/require_parent_mass_match_smiles.py b/matchms/filtering/metadata_processing/require_parent_mass_match_smiles.py
new file mode 100644
index 00000000..12e7ce1e
--- /dev/null
+++ b/matchms/filtering/metadata_processing/require_parent_mass_match_smiles.py
@@ -0,0 +1,39 @@
+from typing import Optional
+from matchms.filtering.filter_utils.get_neutral_mass_from_smiles import \
+    get_monoisotopic_neutral_mass
+from matchms.typing import SpectrumType
+
+
+def require_parent_mass_match_smiles(spectrum_in: SpectrumType,
+                                     mass_tolerance) -> Optional[SpectrumType]:
+    """
+    Validates if the parent mass of the given spectrum matches the mass calculated
+    from its associated SMILES string within a specified tolerance.
+
+    Parameters
+    ----------
+    spectrum_in: Spectrum
+        The input spectrum to be validated. If `None`, the function will return `None`.
+
+    mass_tolerance: float
+        The tolerance for the mass difference between the spectrum's parent mass and
+        the mass calculated from its SMILES string.
+
+    Returns
+    -------
+    Spectrum or None
+        The validated spectrum if its parent mass matches the SMILES mass within the
+        specified tolerance, or `None` otherwise.
+    """
+    if spectrum_in is None:
+        return None
+
+    spectrum = spectrum_in.clone()
+    # Check if parent mass matches the smiles mass
+    parent_mass = spectrum.get("parent_mass")
+    smiles = spectrum.get("smiles")
+    smiles_mass = get_monoisotopic_neutral_mass(smiles)
+    mass_difference = parent_mass - smiles_mass
+    if abs(mass_difference) < mass_tolerance:
+        return spectrum
+    return None
diff --git a/matchms/filtering/require_precursor_below_mz.py b/matchms/filtering/metadata_processing/require_precursor_below_mz.py
similarity index 96%
rename from matchms/filtering/require_precursor_below_mz.py
rename to matchms/filtering/metadata_processing/require_precursor_below_mz.py
index 934a1467..12974c94 100644
--- a/matchms/filtering/require_precursor_below_mz.py
+++ b/matchms/filtering/metadata_processing/require_precursor_below_mz.py
@@ -1,5 +1,5 @@
 import logging
-from ..typing import SpectrumType
+from matchms.typing import SpectrumType
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/require_precursor_mz.py b/matchms/filtering/metadata_processing/require_precursor_mz.py
similarity index 96%
rename from matchms/filtering/require_precursor_mz.py
rename to matchms/filtering/metadata_processing/require_precursor_mz.py
index cf91c3f8..0c134ab3 100644
--- a/matchms/filtering/require_precursor_mz.py
+++ b/matchms/filtering/metadata_processing/require_precursor_mz.py
@@ -1,6 +1,6 @@
 import logging
 from typing import Union
-from ..typing import SpectrumType
+from matchms.typing import SpectrumType
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/require_valid_annotation.py b/matchms/filtering/metadata_processing/require_valid_annotation.py
similarity index 100%
rename from matchms/filtering/require_valid_annotation.py
rename to matchms/filtering/metadata_processing/require_valid_annotation.py
diff --git a/matchms/filtering/peak_processing/__init__.py b/matchms/filtering/peak_processing/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/matchms/filtering/add_losses.py b/matchms/filtering/peak_processing/add_losses.py
similarity index 94%
rename from matchms/filtering/add_losses.py
rename to matchms/filtering/peak_processing/add_losses.py
index 610ece25..1c699d56 100644
--- a/matchms/filtering/add_losses.py
+++ b/matchms/filtering/peak_processing/add_losses.py
@@ -1,7 +1,7 @@
 import logging
 import numpy as np
-from ..Fragments import Fragments
-from ..typing import SpectrumType
+from matchms.Fragments import Fragments
+from matchms.typing import SpectrumType
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/normalize_intensities.py b/matchms/filtering/peak_processing/normalize_intensities.py
similarity index 97%
rename from matchms/filtering/normalize_intensities.py
rename to matchms/filtering/peak_processing/normalize_intensities.py
index ffd15337..5c612cd3 100644
--- a/matchms/filtering/normalize_intensities.py
+++ b/matchms/filtering/peak_processing/normalize_intensities.py
@@ -1,7 +1,7 @@
 import logging
 import numpy as np
 from matchms.typing import SpectrumType
-from ..Fragments import Fragments
+from ...Fragments import Fragments
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/reduce_to_number_of_peaks.py b/matchms/filtering/peak_processing/reduce_to_number_of_peaks.py
similarity index 96%
rename from matchms/filtering/reduce_to_number_of_peaks.py
rename to matchms/filtering/peak_processing/reduce_to_number_of_peaks.py
index 476c7644..216c64e6 100644
--- a/matchms/filtering/reduce_to_number_of_peaks.py
+++ b/matchms/filtering/peak_processing/reduce_to_number_of_peaks.py
@@ -2,8 +2,8 @@ import logging
 from math import ceil
 from typing import Optional
 import numpy as np
-from ..Fragments import Fragments
-from ..typing import SpectrumType
+from matchms.Fragments import Fragments
+from matchms.typing import SpectrumType
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/remove_peaks_around_precursor_mz.py b/matchms/filtering/peak_processing/remove_peaks_around_precursor_mz.py
similarity index 94%
rename from matchms/filtering/remove_peaks_around_precursor_mz.py
rename to matchms/filtering/peak_processing/remove_peaks_around_precursor_mz.py
index cb0fe0e5..7d29af5c 100644
--- a/matchms/filtering/remove_peaks_around_precursor_mz.py
+++ b/matchms/filtering/peak_processing/remove_peaks_around_precursor_mz.py
@@ -1,6 +1,6 @@
 import numpy as np
-from ..Fragments import Fragments
-from ..typing import SpectrumType
+from matchms.Fragments import Fragments
+from matchms.typing import SpectrumType
 
 
 def remove_peaks_around_precursor_mz(spectrum_in: SpectrumType, mz_tolerance: float = 17) -> SpectrumType:
diff --git a/matchms/filtering/remove_peaks_outside_top_k.py b/matchms/filtering/peak_processing/remove_peaks_outside_top_k.py
similarity index 94%
rename from matchms/filtering/remove_peaks_outside_top_k.py
rename to matchms/filtering/peak_processing/remove_peaks_outside_top_k.py
index c15bc659..467197a4 100644
--- a/matchms/filtering/remove_peaks_outside_top_k.py
+++ b/matchms/filtering/peak_processing/remove_peaks_outside_top_k.py
@@ -1,6 +1,6 @@
 import numpy as np
-from ..Fragments import Fragments
-from ..typing import SpectrumType
+from matchms.Fragments import Fragments
+from matchms.typing import SpectrumType
 
 
 def remove_peaks_outside_top_k(spectrum_in: SpectrumType, k: int = 6,
diff --git a/matchms/filtering/require_minimum_number_of_peaks.py b/matchms/filtering/peak_processing/require_minimum_number_of_peaks.py
similarity index 96%
rename from matchms/filtering/require_minimum_number_of_peaks.py
rename to matchms/filtering/peak_processing/require_minimum_number_of_peaks.py
index 3c87f377..872a6258 100644
--- a/matchms/filtering/require_minimum_number_of_peaks.py
+++ b/matchms/filtering/peak_processing/require_minimum_number_of_peaks.py
@@ -1,7 +1,7 @@
 import logging
 from math import ceil
 from typing import Optional
-from ..typing import SpectrumType
+from matchms.typing import SpectrumType
 
 
 logger = logging.getLogger("matchms")
diff --git a/matchms/filtering/require_minimum_of_high_peaks.py b/matchms/filtering/peak_processing/require_minimum_of_high_peaks.py
similarity index 97%
rename from matchms/filtering/require_minimum_of_high_peaks.py
rename to matchms/filtering/peak_processing/require_minimum_of_high_peaks.py
index 299d60a5..e4d33625 100644
--- a/matchms/filtering/require_minimum_of_high_peaks.py
+++ b/matchms/filtering/peak_processing/require_minimum_of_high_peaks.py
@@ -1,5 +1,5 @@
 import logging
-from ..typing import SpectrumType
+from matchms.typing import SpectrumType
 from .select_by_relative_intensity import select_by_relative_intensity
 
 
diff --git a/matchms/filtering/select_by_intensity.py b/matchms/filtering/peak_processing/select_by_intensity.py
similarity index 93%
rename from matchms/filtering/select_by_intensity.py
rename to matchms/filtering/peak_processing/select_by_intensity.py
index 7805ec5e..ce77a356 100644
--- a/matchms/filtering/select_by_intensity.py
+++ b/matchms/filtering/peak_processing/select_by_intensity.py
@@ -1,6 +1,6 @@
 import numpy as np
-from ..Fragments import Fragments
-from ..typing import SpectrumType
+from matchms.Fragments import Fragments
+from matchms.typing import SpectrumType
 
 
 def select_by_intensity(spectrum_in: SpectrumType, intensity_from: float = 10.0,
diff --git a/matchms/filtering/select_by_mz.py b/matchms/filtering/peak_processing/select_by_mz.py
similarity index 91%
rename from matchms/filtering/select_by_mz.py
rename to matchms/filtering/peak_processing/select_by_mz.py
index 5867d131..3617963a 100644
--- a/matchms/filtering/select_by_mz.py
+++ b/matchms/filtering/peak_processing/select_by_mz.py
@@ -1,6 +1,6 @@
 import numpy as np
-from ..Fragments import Fragments
-from ..typing import SpectrumType
+from matchms.Fragments import Fragments
+from matchms.typing import SpectrumType
 
 
 def select_by_mz(spectrum_in: SpectrumType, mz_from: float = 0.0,
diff --git a/matchms/filtering/select_by_relative_intensity.py b/matchms/filtering/peak_processing/select_by_relative_intensity.py
similarity index 94%
rename from matchms/filtering/select_by_relative_intensity.py
rename to matchms/filtering/peak_processing/select_by_relative_intensity.py
index 4b7b971a..55ccbc39 100644
--- a/matchms/filtering/select_by_relative_intensity.py
+++ b/matchms/filtering/peak_processing/select_by_relative_intensity.py
@@ -1,6 +1,6 @@
 import numpy as np
-from ..Fragments import Fragments
-from ..typing import SpectrumType
+from matchms.Fragments import Fragments
+from matchms.typing import SpectrumType
 
 
 def select_by_relative_intensity(spectrum_in: SpectrumType, intensity_from: float = 0.0,
diff --git a/matchms/filtering/repair_parent_mass_from_smiles/require_parent_mass_match_smiles.py b/matchms/filtering/repair_parent_mass_from_smiles/require_parent_mass_match_smiles.py
deleted file mode 100644
index 155ffee6..00000000
--- a/matchms/filtering/repair_parent_mass_from_smiles/require_parent_mass_match_smiles.py
+++ /dev/null
@@ -1,18 +0,0 @@
-from matchms import Spectrum
-from matchms.filtering.filter_utils.get_neutral_mass_from_smiles import \
-    get_monoisotopic_neutral_mass
-
-
-def require_parent_mass_match_smiles(spectrum_in: Spectrum,
-                                     mass_tolerance):
-    if spectrum_in is None:
-        return None
-
-    spectrum = spectrum_in.clone()
-    # Check if parent mass matches the smiles mass
-    parent_mass = spectrum.get("parent_mass")
-    smiles = spectrum.get("smiles")
-    smiles_mass = get_monoisotopic_neutral_mass(smiles)
-    mass_difference = parent_mass - smiles_mass
-    if abs(mass_difference) < mass_tolerance:
-        return spectrum
diff --git a/matchms/filtering/require_correct_ionmode.py b/matchms/filtering/require_correct_ionmode.py
deleted file mode 100644
index 2a0ca306..00000000
--- a/matchms/filtering/require_correct_ionmode.py
+++ /dev/null
@@ -1,26 +0,0 @@
-import logging
-from matchms import Spectrum
-
-
-logger = logging.getLogger("matchms")
-
-
-def require_correct_ionmode(spectrum_in: Spectrum,
-                            ion_mode_to_keep):
-    """Removes spectra that are not in the correct ionmode"""
-    if spectrum_in is None:
-        return None
-    spectrum = spectrum_in.clone()
-    if ion_mode_to_keep not in {"positive", "negative", "both"}:
-        raise ValueError("ion_mode_to_keep should be 'positive', 'negative' or 'both'")
-    ion_mode = spectrum.get("ionmode")
-    if ion_mode_to_keep == "both":
-        if ion_mode in ("positive", "negative"):
-            return spectrum
-
-        logger.info("Spectrum was removed since ionmode was: %s which does not match positive or negative", ion_mode)
-        return None
-    if ion_mode == ion_mode_to_keep:
-        return spectrum
-    logger.info("Spectrum was removed since ionmode was: %s which does not match %s", ion_mode, ion_mode_to_keep)
-    return None
diff --git a/matchms/filtering/set_ionmode_na_when_missing.py b/matchms/filtering/set_ionmode_na_when_missing.py
deleted file mode 100644
index b8794d2c..00000000
--- a/matchms/filtering/set_ionmode_na_when_missing.py
+++ /dev/null
@@ -1,15 +0,0 @@
-from ..typing import SpectrumType
-
-
-def set_ionmode_na_when_missing(spectrum_in: SpectrumType) -> SpectrumType:
-    """Create "ionmode" entry of "n/a" if field does not yet exist in metadata."""
-    if spectrum_in is None:
-        return None
-
-    spectrum = spectrum_in.clone()
-
-    # Set ionmode to "n/a" when ionmode is missing from the metadata
-    if spectrum.get("ionmode") is None:
-        spectrum.set("ionmode", "n/a")
-
-    return spectrum
diff --git a/matchms/similarity/ModifiedCosine.py b/matchms/similarity/ModifiedCosine.py
index ff0a42dd..cd4001a7 100644
--- a/matchms/similarity/ModifiedCosine.py
+++ b/matchms/similarity/ModifiedCosine.py
@@ -1,7 +1,8 @@
 import logging
 from typing import Tuple
 import numpy as np
-from matchms.filtering.add_precursor_mz import _convert_precursor_mz
+from matchms.filtering.metadata_processing.add_precursor_mz import \
+    _convert_precursor_mz
 from matchms.typing import SpectrumType
 from .BaseSimilarity import BaseSimilarity
 from .spectrum_similarity_functions import (collect_peak_pairs,
diff --git a/matchms/similarity/NeutralLossesCosine.py b/matchms/similarity/NeutralLossesCosine.py
index bedd2417..b013b0b7 100644
--- a/matchms/similarity/NeutralLossesCosine.py
+++ b/matchms/similarity/NeutralLossesCosine.py
@@ -1,7 +1,8 @@
 import logging
 from typing import Tuple
 import numpy as np
-from matchms.filtering.add_precursor_mz import _convert_precursor_mz
+from matchms.filtering.metadata_processing.add_precursor_mz import \
+    _convert_precursor_mz
 from matchms.typing import SpectrumType
 from .BaseSimilarity import BaseSimilarity
 from .spectrum_similarity_functions import (collect_peak_pairs,


Test patch:
diff --git a/tests/filtering/test_derive_adduct_from_name.py b/tests/filtering/test_derive_adduct_from_name.py
index 4f69554e..72bb13f7 100644
--- a/tests/filtering/test_derive_adduct_from_name.py
+++ b/tests/filtering/test_derive_adduct_from_name.py
@@ -1,7 +1,8 @@
 import pytest
 from testfixtures import LogCapture
 from matchms.filtering import derive_adduct_from_name
-from matchms.filtering.derive_adduct_from_name import looks_like_adduct
+from matchms.filtering.metadata_processing.derive_adduct_from_name import \
+    looks_like_adduct
 from matchms.logging_functions import (reset_matchms_logger,
                                        set_matchms_logger_level)
 from ..builder_Spectrum import SpectrumBuilder
diff --git a/tests/filtering/test_filter_utils/test_interpret_unknown_adduct.py b/tests/filtering/test_filter_utils/test_interpret_unknown_adduct.py
index 2187a3b5..b76b75b8 100644
--- a/tests/filtering/test_filter_utils/test_interpret_unknown_adduct.py
+++ b/tests/filtering/test_filter_utils/test_interpret_unknown_adduct.py
@@ -1,7 +1,8 @@
 import pytest
 from matchms.filtering.filter_utils.interpret_unknown_adduct import \
     get_multiplier_and_mass_from_adduct
-from matchms.filtering.repair_adduct.clean_adduct import load_known_adducts
+from matchms.filtering.metadata_processing.clean_adduct import \
+    load_known_adducts
 
 
 def test_get_multiplier_and_mass():
diff --git a/tests/filtering/test_load_adducts.py b/tests/filtering/test_load_adducts.py
index 3ff26b55..8fe7414b 100644
--- a/tests/filtering/test_load_adducts.py
+++ b/tests/filtering/test_load_adducts.py
@@ -1,6 +1,6 @@
 import numpy as np
 import pandas as pd
-from matchms.filtering.repair_adduct.clean_adduct import (
+from matchms.filtering.metadata_processing.clean_adduct import (
     load_known_adduct_conversions, load_known_adducts)
 
 
diff --git a/tests/filtering/test_repair_adduct/test_clean_adduct.py b/tests/filtering/test_repair_adduct/test_clean_adduct.py
index 3b4080d1..672b789c 100644
--- a/tests/filtering/test_repair_adduct/test_clean_adduct.py
+++ b/tests/filtering/test_repair_adduct/test_clean_adduct.py
@@ -1,5 +1,5 @@
 import pytest
-from matchms.filtering.repair_adduct.clean_adduct import clean_adduct
+from matchms.filtering.metadata_processing.clean_adduct import clean_adduct
 from tests.builder_Spectrum import SpectrumBuilder
 
 
diff --git a/tests/filtering/test_repair_adduct/test_repair_adduct_based_on_smiles.py b/tests/filtering/test_repair_adduct/test_repair_adduct_based_on_smiles.py
index 265cb0a8..d213fe52 100644
--- a/tests/filtering/test_repair_adduct/test_repair_adduct_based_on_smiles.py
+++ b/tests/filtering/test_repair_adduct/test_repair_adduct_based_on_smiles.py
@@ -1,5 +1,5 @@
 import pytest
-from matchms.filtering.repair_adduct.repair_adduct_based_on_smiles import \
+from matchms.filtering.metadata_processing.repair_adduct_based_on_smiles import \
     repair_adduct_based_on_smiles
 from tests.builder_Spectrum import SpectrumBuilder
 
diff --git a/tests/filtering/test_require_precursor_mz.py b/tests/filtering/test_require_precursor_mz.py
index e6efb74c..8d6c001e 100644
--- a/tests/filtering/test_require_precursor_mz.py
+++ b/tests/filtering/test_require_precursor_mz.py
@@ -1,7 +1,8 @@
 import numpy as np
 import pytest
 from testfixtures import LogCapture
-from matchms.filtering.require_precursor_mz import require_precursor_mz
+from matchms.filtering.metadata_processing.require_precursor_mz import \
+    require_precursor_mz
 from matchms.logging_functions import (reset_matchms_logger,
                                        set_matchms_logger_level)
 from ..builder_Spectrum import SpectrumBuilder
diff --git a/tests/test_fragments.py b/tests/test_fragments.py
index f2cf7b3f..d17b19f7 100644
--- a/tests/test_fragments.py
+++ b/tests/test_fragments.py
@@ -1,6 +1,6 @@
 import numpy as np
 import pytest
-from matchms import Fragments
+from matchms.Fragments import Fragments
 
 
 def test_fragments_init():