thyra 2.0.3__tar.gz → 2.0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. {thyra-2.0.3 → thyra-2.0.4}/PKG-INFO +1 -1
  2. {thyra-2.0.3 → thyra-2.0.4}/pyproject.toml +1 -1
  3. {thyra-2.0.3 → thyra-2.0.4}/thyra/__init__.py +1 -1
  4. {thyra-2.0.3 → thyra-2.0.4}/thyra/converters/spatialdata/base_spatialdata_converter.py +7 -2
  5. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/strategies/nearest_neighbor.py +21 -0
  6. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/types.py +12 -3
  7. {thyra-2.0.3 → thyra-2.0.4}/LICENSE +0 -0
  8. {thyra-2.0.3 → thyra-2.0.4}/README.md +0 -0
  9. {thyra-2.0.3 → thyra-2.0.4}/thyra/__main__.py +0 -0
  10. {thyra-2.0.3 → thyra-2.0.4}/thyra/alignment/__init__.py +0 -0
  11. {thyra-2.0.3 → thyra-2.0.4}/thyra/alignment/affine.py +0 -0
  12. {thyra-2.0.3 → thyra-2.0.4}/thyra/alignment/teaching_points.py +0 -0
  13. {thyra-2.0.3 → thyra-2.0.4}/thyra/config.py +0 -0
  14. {thyra-2.0.3 → thyra-2.0.4}/thyra/convert.py +0 -0
  15. {thyra-2.0.3 → thyra-2.0.4}/thyra/converters/__init__.py +0 -0
  16. {thyra-2.0.3 → thyra-2.0.4}/thyra/converters/spatialdata/__init__.py +0 -0
  17. {thyra-2.0.3 → thyra-2.0.4}/thyra/converters/spatialdata/_chunking.py +0 -0
  18. {thyra-2.0.3 → thyra-2.0.4}/thyra/converters/spatialdata/converter.py +0 -0
  19. {thyra-2.0.3 → thyra-2.0.4}/thyra/converters/spatialdata/spatialdata_2d_converter.py +0 -0
  20. {thyra-2.0.3 → thyra-2.0.4}/thyra/converters/spatialdata/spatialdata_3d_converter.py +0 -0
  21. {thyra-2.0.3 → thyra-2.0.4}/thyra/converters/spatialdata/streaming_converter.py +0 -0
  22. {thyra-2.0.3 → thyra-2.0.4}/thyra/core/__init__.py +0 -0
  23. {thyra-2.0.3 → thyra-2.0.4}/thyra/core/base_converter.py +0 -0
  24. {thyra-2.0.3 → thyra-2.0.4}/thyra/core/base_extractor.py +0 -0
  25. {thyra-2.0.3 → thyra-2.0.4}/thyra/core/base_reader.py +0 -0
  26. {thyra-2.0.3 → thyra-2.0.4}/thyra/core/registry.py +0 -0
  27. {thyra-2.0.3 → thyra-2.0.4}/thyra/metadata/__init__.py +0 -0
  28. {thyra-2.0.3 → thyra-2.0.4}/thyra/metadata/extractors/__init__.py +0 -0
  29. {thyra-2.0.3 → thyra-2.0.4}/thyra/metadata/extractors/bruker_extractor.py +0 -0
  30. {thyra-2.0.3 → thyra-2.0.4}/thyra/metadata/extractors/imzml_extractor.py +0 -0
  31. {thyra-2.0.3 → thyra-2.0.4}/thyra/metadata/extractors/waters_extractor.py +0 -0
  32. {thyra-2.0.3 → thyra-2.0.4}/thyra/metadata/ontology/__init__.py +0 -0
  33. {thyra-2.0.3 → thyra-2.0.4}/thyra/metadata/ontology/_ims.py +0 -0
  34. {thyra-2.0.3 → thyra-2.0.4}/thyra/metadata/ontology/_ms.py +0 -0
  35. {thyra-2.0.3 → thyra-2.0.4}/thyra/metadata/ontology/_uo.py +0 -0
  36. {thyra-2.0.3 → thyra-2.0.4}/thyra/metadata/ontology/cache.py +0 -0
  37. {thyra-2.0.3 → thyra-2.0.4}/thyra/metadata/types.py +0 -0
  38. {thyra-2.0.3 → thyra-2.0.4}/thyra/metadata/validator.py +0 -0
  39. {thyra-2.0.3 → thyra-2.0.4}/thyra/preview.py +0 -0
  40. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/__init__.py +0 -0
  41. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/__init__.py +0 -0
  42. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/base_bruker_reader.py +0 -0
  43. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/folder_structure.py +0 -0
  44. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/mis_parser.py +0 -0
  45. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/rapiflex/__init__.py +0 -0
  46. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/rapiflex/rapiflex_reader.py +0 -0
  47. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/timstof/__init__.py +0 -0
  48. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/timstof/sdk/__init__.py +0 -0
  49. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/timstof/sdk/dll/LICENCE-BRUKER.txt +0 -0
  50. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/timstof/sdk/dll/README.md +0 -0
  51. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/timstof/sdk/dll/timsdata.dll +0 -0
  52. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/timstof/sdk/dll/timsdata.so +0 -0
  53. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/timstof/sdk/dll_manager.py +0 -0
  54. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/timstof/sdk/platform_detector.py +0 -0
  55. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/timstof/sdk/sdk_functions.py +0 -0
  56. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/timstof/timstof_reader.py +0 -0
  57. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/timstof/utils/__init__.py +0 -0
  58. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/timstof/utils/batch_processor.py +0 -0
  59. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/timstof/utils/coordinate_cache.py +0 -0
  60. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/timstof/utils/mass_axis_builder.py +0 -0
  61. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/bruker/timstof/utils/memory_manager.py +0 -0
  62. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/imzml/__init__.py +0 -0
  63. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/imzml/imzml_reader.py +0 -0
  64. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/waters/__init__.py +0 -0
  65. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/waters/imaging_grid.py +0 -0
  66. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/waters/lib/MLReader.dll +0 -0
  67. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/waters/lib/MassLynxRaw.dll +0 -0
  68. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/waters/lib/libMLReader.so +0 -0
  69. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/waters/lib/libMassLynxRaw.so +0 -0
  70. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/waters/masslynx_lib.py +0 -0
  71. {thyra-2.0.3 → thyra-2.0.4}/thyra/readers/waters/waters_reader.py +0 -0
  72. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/__init__.py +0 -0
  73. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/common_axis.py +0 -0
  74. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/constants.py +0 -0
  75. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/data_characteristics.py +0 -0
  76. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/decision_tree.py +0 -0
  77. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/instrument_detectors.py +0 -0
  78. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/mass_axis/__init__.py +0 -0
  79. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/mass_axis/base_generator.py +0 -0
  80. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/mass_axis/fticr_generator.py +0 -0
  81. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/mass_axis/linear_generator.py +0 -0
  82. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/mass_axis/linear_tof_generator.py +0 -0
  83. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/mass_axis/orbitrap_generator.py +0 -0
  84. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/mass_axis/reflector_tof_generator.py +0 -0
  85. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/strategies/__init__.py +0 -0
  86. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/strategies/base.py +0 -0
  87. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/strategies/tic_preserving.py +0 -0
  88. {thyra-2.0.3 → thyra-2.0.4}/thyra/resampling/tic.py +0 -0
  89. {thyra-2.0.3 → thyra-2.0.4}/thyra/tools/__init__.py +0 -0
  90. {thyra-2.0.3 → thyra-2.0.4}/thyra/tools/check_ontology.py +0 -0
  91. {thyra-2.0.3 → thyra-2.0.4}/thyra/tools/make_example_data.py +0 -0
  92. {thyra-2.0.3 → thyra-2.0.4}/thyra/utils/__init__.py +0 -0
  93. {thyra-2.0.3 → thyra-2.0.4}/thyra/utils/bruker_exceptions.py +0 -0
  94. {thyra-2.0.3 → thyra-2.0.4}/thyra/utils/logging_config.py +0 -0
  95. {thyra-2.0.3 → thyra-2.0.4}/thyra/utils/windows_paths.py +0 -0
  96. {thyra-2.0.3 → thyra-2.0.4}/thyra/utils/zarr_atomic_write.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: thyra
3
- Version: 2.0.3
3
+ Version: 2.0.4
4
4
  Summary: A modern Python library for converting Mass Spectrometry Imaging (MSI) data into SpatialData/Zarr format - your portal to spatial omics
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "thyra"
7
- version = "2.0.3"
7
+ version = "2.0.4"
8
8
  description = "A modern Python library for converting Mass Spectrometry Imaging (MSI) data into SpatialData/Zarr format - your portal to spatial omics"
9
9
  authors = ["Theodoros Visvikis <t.visvikis@maastrichtuniversity.nl>"]
10
10
  maintainers = ["Theodoros Visvikis <t.visvikis@maastrichtuniversity.nl>"]
@@ -36,7 +36,7 @@ warnings.filterwarnings(
36
36
  category=FutureWarning,
37
37
  )
38
38
 
39
- __version__ = "2.0.3"
39
+ __version__ = "2.0.4"
40
40
 
41
41
  # Import key components - avoid wildcard imports
42
42
  try:
@@ -1082,8 +1082,13 @@ class BaseSpatialDataConverter(BaseMSIConverter, ABC):
1082
1082
  # bincount without minlength is fastest
1083
1083
  accumulated = np.bincount(indices_clipped, weights=intensities)
1084
1084
 
1085
- # Extract non-zero bins for sparse representation
1086
- nonzero_mask = accumulated > 0
1085
+ # Extract non-zero bins for sparse representation. The test is
1086
+ # ``!= 0`` rather than ``> 0`` because a bin whose accumulated value is
1087
+ # negative is still a measurement: dropping it silently raises the
1088
+ # stored TIC above the input's. Baseline-subtracted data can carry
1089
+ # negative intensities, though every export seen so far filters them
1090
+ # out upstream.
1091
+ nonzero_mask = accumulated != 0
1087
1092
  nonzero_indices = np.where(nonzero_mask)[0].astype(np.int_)
1088
1093
  nonzero_values = accumulated[nonzero_mask]
1089
1094
 
@@ -2,6 +2,23 @@
2
2
 
3
3
  This strategy is optimal for centroid data (e.g., from timsTOF
4
4
  instruments) where each peak represents a discrete mass value.
5
+
6
+ Not to be confused with the converters' ``_nearest_neighbor_resample``
7
+ (``thyra/converters/spatialdata/base_spatialdata_converter.py``), which is
8
+ what ``ResamplingMethod.NEAREST_NEIGHBOR`` actually selects during a
9
+ conversion. The two share a name and do opposite things with intensity:
10
+
11
+ - This class INTERPOLATES. Each target point takes the intensity of the
12
+ nearest source point, so one source peak is replicated across every
13
+ target point closer to it than to any other. Summed intensity therefore
14
+ scales with how densely the target axis is laid out, and is not
15
+ preserved. That is the defining behaviour of nearest-neighbour
16
+ interpolation, not a defect -- but it means this class is the wrong tool
17
+ if you care about total ion current.
18
+ - The converter's version BINS. Each source peak is accumulated into
19
+ exactly one target bin, so summed intensity is preserved exactly.
20
+
21
+ If you want the conversion pipeline's behaviour, use the converter.
5
22
  """
6
23
 
7
24
  from typing import Any
@@ -24,6 +41,10 @@ class NearestNeighborStrategy(ResamplingStrategy):
24
41
  and assigns its intensity. This preserves the discrete nature
25
42
  of centroid data.
26
43
 
44
+ Does NOT preserve total ion current -- a source peak is repeated
45
+ at every target point nearest to it, so the sum grows with the
46
+ target axis density. See the module docstring.
47
+
27
48
  Parameters
28
49
  ----------
29
50
  spectrum : Spectrum
@@ -70,7 +70,13 @@ class MassAxis:
70
70
  return np.diff(self.mz_values)
71
71
 
72
72
  def resolution_at(self, mz: float) -> float:
73
- """Calculate resolution at given m/z."""
73
+ """Return ``mz`` divided by the local bin width.
74
+
75
+ This is a property of the AXIS, not of the data on it. A finely
76
+ spaced axis reports a large number here whether or not the spectra
77
+ stored on it resolve anything at that scale, so it must not be
78
+ reported to users as the acquisition's resolving power.
79
+ """
74
80
  idx = int(np.searchsorted(self.mz_values, mz))
75
81
  if idx > 0 and idx < len(self.mz_values):
76
82
  delta_mz = float(self.mz_values[idx] - self.mz_values[idx - 1])
@@ -91,8 +97,11 @@ class ResamplingConfig:
91
97
  axis_type: Mass axis spacing model. ``None`` auto-detects from
92
98
  the instrument metadata.
93
99
  target_bins: Number of bins in the resampled axis. ``None``
94
- lets the resampler choose a bin count that preserves the
95
- native resolution.
100
+ derives the count from ``mass_width_da`` at ``reference_mz``
101
+ across the mass range. Note that this is a fixed target
102
+ width, not a measurement: the source spectra's own point
103
+ spacing is never consulted, so the resulting axis can be
104
+ finer or coarser than the data it will hold.
96
105
  mass_width_da: Bin width in Daltons at ``reference_mz``.
97
106
  Alternative to ``target_bins`` -- specify one or the other.
98
107
  reference_mz: Reference m/z for ``mass_width_da``. Default
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes