thyra 2.0.2__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.
- {thyra-2.0.2 → thyra-2.0.4}/PKG-INFO +1 -1
- {thyra-2.0.2 → thyra-2.0.4}/pyproject.toml +1 -1
- {thyra-2.0.2 → thyra-2.0.4}/thyra/__init__.py +1 -1
- {thyra-2.0.2 → thyra-2.0.4}/thyra/converters/spatialdata/base_spatialdata_converter.py +7 -2
- {thyra-2.0.2 → thyra-2.0.4}/thyra/converters/spatialdata/streaming_converter.py +15 -4
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/strategies/nearest_neighbor.py +21 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/types.py +12 -3
- {thyra-2.0.2 → thyra-2.0.4}/LICENSE +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/README.md +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/__main__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/alignment/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/alignment/affine.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/alignment/teaching_points.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/config.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/convert.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/converters/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/converters/spatialdata/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/converters/spatialdata/_chunking.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/converters/spatialdata/converter.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/converters/spatialdata/spatialdata_2d_converter.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/converters/spatialdata/spatialdata_3d_converter.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/core/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/core/base_converter.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/core/base_extractor.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/core/base_reader.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/core/registry.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/metadata/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/metadata/extractors/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/metadata/extractors/bruker_extractor.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/metadata/extractors/imzml_extractor.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/metadata/extractors/waters_extractor.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/metadata/ontology/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/metadata/ontology/_ims.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/metadata/ontology/_ms.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/metadata/ontology/_uo.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/metadata/ontology/cache.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/metadata/types.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/metadata/validator.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/preview.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/base_bruker_reader.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/folder_structure.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/mis_parser.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/rapiflex/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/rapiflex/rapiflex_reader.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/timstof/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/timstof/sdk/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/timstof/sdk/dll/LICENCE-BRUKER.txt +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/timstof/sdk/dll/README.md +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/timstof/sdk/dll/timsdata.dll +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/timstof/sdk/dll/timsdata.so +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/timstof/sdk/dll_manager.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/timstof/sdk/platform_detector.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/timstof/sdk/sdk_functions.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/timstof/timstof_reader.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/timstof/utils/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/timstof/utils/batch_processor.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/timstof/utils/coordinate_cache.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/timstof/utils/mass_axis_builder.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/bruker/timstof/utils/memory_manager.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/imzml/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/imzml/imzml_reader.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/waters/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/waters/imaging_grid.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/waters/lib/MLReader.dll +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/waters/lib/MassLynxRaw.dll +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/waters/lib/libMLReader.so +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/waters/lib/libMassLynxRaw.so +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/waters/masslynx_lib.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/readers/waters/waters_reader.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/common_axis.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/constants.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/data_characteristics.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/decision_tree.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/instrument_detectors.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/mass_axis/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/mass_axis/base_generator.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/mass_axis/fticr_generator.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/mass_axis/linear_generator.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/mass_axis/linear_tof_generator.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/mass_axis/orbitrap_generator.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/mass_axis/reflector_tof_generator.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/strategies/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/strategies/base.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/strategies/tic_preserving.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/resampling/tic.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/tools/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/tools/check_ontology.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/tools/make_example_data.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/utils/__init__.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/utils/bruker_exceptions.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/utils/logging_config.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/utils/windows_paths.py +0 -0
- {thyra-2.0.2 → thyra-2.0.4}/thyra/utils/zarr_atomic_write.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "thyra"
|
|
7
|
-
version = "2.0.
|
|
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>"]
|
|
@@ -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
|
-
|
|
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
|
|
|
@@ -129,10 +129,21 @@ class StreamingSpatialDataConverter(BaseSpatialDataConverter):
|
|
|
129
129
|
n_x, n_y, n_z = metadata.dimensions
|
|
130
130
|
n_pixels = n_x * n_y * n_z
|
|
131
131
|
|
|
132
|
-
#
|
|
133
|
-
#
|
|
134
|
-
#
|
|
135
|
-
|
|
132
|
+
# Prefer the axis that was actually built. ``convert()`` runs
|
|
133
|
+
# ``_initialize_conversion()`` -- and so ``_setup_mass_axis()`` --
|
|
134
|
+
# before it asks which method to use, so by the time this gate is
|
|
135
|
+
# evaluated the real bin count is known and there is nothing to
|
|
136
|
+
# estimate. That matters most on the raw-axis path, where the
|
|
137
|
+
# fallback below assumes a 10 mDa spacing that the data need not
|
|
138
|
+
# have: a continuous file carrying 4,000 points over 250-1200 m/z
|
|
139
|
+
# was scored as though it had 95,000, and a processed file whose
|
|
140
|
+
# spectra share no m/z values was scored far too low, which routed
|
|
141
|
+
# the largest datasets to the method that holds the most in memory.
|
|
142
|
+
if self._common_mass_axis is not None:
|
|
143
|
+
n_mz_bins = len(self._common_mass_axis)
|
|
144
|
+
elif self._resampling_config:
|
|
145
|
+
# Same resolution path the axis builder will use, so the gate
|
|
146
|
+
# against PCS_SIZE_THRESHOLD_GB sees the real bin count.
|
|
136
147
|
_, _, _, n_mz_bins = self._resolve_resampling_plan()
|
|
137
148
|
else:
|
|
138
149
|
min_mass, max_mass = metadata.mass_range
|
|
@@ -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
|
-
"""
|
|
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
|
-
|
|
95
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|