dclab 0.64.0__cp311-cp311-macosx_10_9_x86_64.whl → 0.64.1__cp311-cp311-macosx_10_9_x86_64.whl

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.

Potentially problematic release.


This version of dclab might be problematic. Click here for more details.

dclab/_version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.64.0'
21
- __version_tuple__ = version_tuple = (0, 64, 0)
20
+ __version__ = version = '0.64.1'
21
+ __version_tuple__ = version_tuple = (0, 64, 1)
Binary file
dclab/kde/base.py CHANGED
@@ -1,6 +1,7 @@
1
1
  import warnings
2
2
 
3
3
  import numpy as np
4
+ from scipy.interpolate import RegularGridInterpolator as RGI
4
5
 
5
6
  from .methods import bin_width_doane_div5, get_bad_vals, methods
6
7
  from .contours import find_contours_level, get_quantile_levels
@@ -316,6 +317,8 @@ class KernelDensityEstimator:
316
317
  yscale="linear"):
317
318
  """Evaluate the kernel density estimate for scatter plots
318
319
 
320
+ The KDE is evaluated with the `kde_type` function for every point.
321
+
319
322
  Parameters
320
323
  ----------
321
324
  xax: str
@@ -332,7 +335,7 @@ class KernelDensityEstimator:
332
335
  Additional keyword arguments to the KDE method
333
336
  xscale: str
334
337
  If set to "log", take the logarithm of the x-values before
335
- computing the KDE. This is useful when data are are
338
+ computing the KDE. This is useful when data are
336
339
  displayed on a log-scale. Defaults to "linear".
337
340
  yscale: str
338
341
  See `xscale`.
@@ -374,3 +377,83 @@ class KernelDensityEstimator:
374
377
  density = np.array([])
375
378
 
376
379
  return density
380
+
381
+ def get_at(self, xax="area_um", yax="deform", positions=None,
382
+ kde_type="histogram", kde_kwargs=None, xscale="linear",
383
+ yscale="linear"):
384
+ """Evaluate the kernel density estimate for specific events
385
+
386
+ The KDE is computed via linear interpolation from the output
387
+ of `get_raster`.
388
+
389
+ Parameters
390
+ ----------
391
+ xax: str
392
+ Identifier for X axis (e.g. "area_um", "aspect", "deform")
393
+ yax: str
394
+ Identifier for Y axis
395
+ positions: list of two 1d ndarrays or ndarray of shape (2, N)
396
+ The positions where the KDE will be computed. Note that
397
+ the KDE estimate is computed from the points that
398
+ are set in `self.rtdc_ds.filter.all`.
399
+ kde_type: str
400
+ The KDE method to use, see :const:`.kde_methods.methods`
401
+ kde_kwargs: dict
402
+ Additional keyword arguments to the KDE method
403
+ xscale: str
404
+ If set to "log", take the logarithm of the x-values before
405
+ computing the KDE. This is useful when data are
406
+ displayed on a log-scale. Defaults to "linear".
407
+ yscale: str
408
+ See `xscale`.
409
+
410
+ Returns
411
+ -------
412
+ density : 1d ndarray
413
+ The kernel density evaluated for the filtered events.
414
+ """
415
+ if kde_kwargs is None:
416
+ kde_kwargs = {}
417
+ xax = xax.lower()
418
+ yax = yax.lower()
419
+ kde_type = kde_type.lower()
420
+ if kde_type not in methods:
421
+ raise ValueError(f"Not a valid kde type: {kde_type}!")
422
+
423
+ # Get data
424
+ x = self.rtdc_ds[xax][self.rtdc_ds.filter.all]
425
+ y = self.rtdc_ds[yax][self.rtdc_ds.filter.all]
426
+
427
+ # Apply scale (no change for linear scale)
428
+ xs = self.apply_scale(x, xscale, xax)
429
+ ys = self.apply_scale(y, yscale, yax)
430
+
431
+ if positions:
432
+ xs = self.apply_scale(positions[0], xscale, xax)
433
+ ys = self.apply_scale(positions[1], yscale, yax)
434
+
435
+ if len(x):
436
+ xr, yr, density_grid = self.get_raster(xax=xax,
437
+ yax=yax,
438
+ kde_type=kde_type,
439
+ kde_kwargs=kde_kwargs,
440
+ xscale=xscale,
441
+ yscale=yscale)
442
+
443
+ # Apply scale (no change for linear scale)
444
+ xrs = self.apply_scale(xr, xscale, xax)
445
+ yrs = self.apply_scale(yr, yscale, yax)
446
+
447
+ # 'scipy.interp2d' has been removed in SciPy 1.14.0
448
+ # https://scipy.github.io/devdocs/tutorial/interpolate/interp_transition_guide.html
449
+ interp_func = RGI((xrs[:, 0], yrs[0, :]),
450
+ density_grid,
451
+ method="linear",
452
+ bounds_error=False,
453
+ fill_value=np.nan)
454
+ density = interp_func((xs, ys))
455
+
456
+ else:
457
+ density = np.array([])
458
+
459
+ return density
dclab/statistics.py CHANGED
@@ -86,7 +86,7 @@ def flow_rate(ds):
86
86
  return np.nan
87
87
 
88
88
 
89
- def get_statistics(ds, methods=None, features=None):
89
+ def get_statistics(ds, methods=None, features=None, ret_dict=False):
90
90
  """Compute statistics for an RT-DC dataset
91
91
 
92
92
  Parameters
@@ -96,13 +96,16 @@ def get_statistics(ds, methods=None, features=None):
96
96
  methods: list of str or None
97
97
  The methods wih which to compute the statistics.
98
98
  The list of available methods is given with
99
- `dclab.statistics.Statistics.available_methods.keys()`
99
+ :func:`.available_methods.keys`
100
100
  If set to `None`, statistics for all methods are computed.
101
101
  features: list of str
102
102
  Feature name identifiers are defined by
103
- `dclab.definitions.feature_exists`.
103
+ :func:`dclab.definitions.feature_exists`.
104
104
  If set to `None`, statistics for all scalar features
105
105
  available are computed.
106
+ ret_dict: bool
107
+ Instead of returning ``(header, values)``, return a dictionary
108
+ with headers as keys.
106
109
 
107
110
  Returns
108
111
  -------
@@ -148,7 +151,10 @@ def get_statistics(ds, methods=None, features=None):
148
151
  label = dfn.get_feature_label(ft, rtdc_ds=ds)
149
152
  header.append(" ".join([mt, label]))
150
153
 
151
- return header, values
154
+ if ret_dict:
155
+ return dict(zip(header, values))
156
+ else:
157
+ return header, values
152
158
 
153
159
 
154
160
  def mode(data):
@@ -191,7 +197,24 @@ def mode(data):
191
197
  # Register all the methods
192
198
  # Methods that require an axis
193
199
  Statistics(name="Mean", req_feature=True, method=np.average)
200
+ # Premature-Optimization warning: `np.percentile` also accepts an array
201
+ # of percentiles as the `q` argument, which I would expect to yield better
202
+ # performance than computing percentiles individually. Implementing this
203
+ # would break the way we are defining statistical methods here (One
204
+ # `Statistics` instance per method) and thus requires a considerable
205
+ # amount of work (much more work than writing this text here). It would
206
+ # also make understanding the code more difficult. In addition, computing
207
+ # statistics is not done often and is extremely fast anyway for a few
208
+ # millions of events. Don't optimize this!
209
+ Statistics(name="10th Percentile", req_feature=True,
210
+ method=lambda data: np.percentile(data, 10))
211
+ Statistics(name="25th Percentile", req_feature=True,
212
+ method=lambda data: np.percentile(data, 25))
194
213
  Statistics(name="Median", req_feature=True, method=np.median)
214
+ Statistics(name="75th Percentile", req_feature=True,
215
+ method=lambda data: np.percentile(data, 75))
216
+ Statistics(name="90th Percentile", req_feature=True,
217
+ method=lambda data: np.percentile(data, 90))
195
218
  Statistics(name="Mode", req_feature=True, method=mode)
196
219
  Statistics(name="SD", req_feature=True, method=np.std)
197
220
  # Methods that work on RTDCBase
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dclab
3
- Version: 0.64.0
3
+ Version: 0.64.1
4
4
  Summary: Library for real-time deformability cytometry (RT-DC)
5
5
  Author: Benedikt Hartmann, Eoghan O'Connell, Maik Herbig, Maximilian Schlögel, Nadia Sbaa, Paul Müller, Philipp Rosendahl, Raghava Alajangi
6
6
  Maintainer-email: Paul Müller <dev@craban.de>
7
- License: GPL-2.0-or-later
7
+ License-Expression: GPL-2.0-or-later
8
8
  Project-URL: source, https://github.com/DC-Analysis/dclab
9
9
  Project-URL: tracker, https://github.com/DC-Analysis/dclab/issues
10
10
  Project-URL: documentation, https://dclab.readthedocs.io/en/stable/
@@ -1,6 +1,6 @@
1
1
  dclab/kde_methods.py,sha256=f0-zDN7ETintvGB3gSzxwgBb53YtT9jZtzI70EAX50g,365
2
- dclab/downsampling.cpython-311-darwin.so,sha256=SPJAWHzksA12gLjp9SiomYxybLPvjXeIukCZPvJjRso,236984
3
- dclab/_version.py,sha256=zVb-mNfv7Q80VP6gLIonMXNXR1BAme5zhf4Ww25kC90,513
2
+ dclab/downsampling.cpython-311-darwin.so,sha256=uKkV17PIwJz0sJRNAIPJVoko5vfiwOffs8peakr4k60,237616
3
+ dclab/_version.py,sha256=9r4reeZylDKkIG06-4LPXZLfHirJkjSSEYOAOeaEme8,513
4
4
  dclab/util.py,sha256=HFT5ZQV6AW8GIIruVMldukbVVdlMyKH50GUfOogAcxI,5860
5
5
  dclab/downsampling.pyx,sha256=OK7zbgGLl5gVyoU8ZBHo9EWwb8C9ChavmLNEvQvC9T0,7258
6
6
  dclab/__init__.py,sha256=wyJWhElQRPcq09vUqUnuquTU_KHgHxv6wQxuxQ988Iw,1583
@@ -8,7 +8,7 @@ dclab/warn.py,sha256=MjJvyQeuvIXFQ2-fHDzbmXJ0scnHqqRJlIxfuLI_utE,523
8
8
  dclab/cached.py,sha256=eWTYBiI-HQM7JuPH-oxa5LLnhAX32GpRwlYg2kQ3sTA,2917
9
9
  dclab/http_utils.py,sha256=XHicbHQts5LY3zSNmYqNgAZpKTktotEiwQgJ8d2sBlk,10912
10
10
  dclab/polygon_filter.py,sha256=qexmo-rXe06CUPZhN6EMJy4y4B5gXZeqejdvIB2arOE,13480
11
- dclab/statistics.py,sha256=tJDqPlY_Jw2Hhl-s7ugMBSZAxcRuPu4LQuBAZBXz7t8,6355
11
+ dclab/statistics.py,sha256=DWBG_Kj7cn89b_s5mqWYDCMGB881jHcCRFY-KAOBnhE,7598
12
12
  dclab/kde_contours.py,sha256=UlU64lrzMQUZH11oZndW7xf7NFCzwP3FcVujwuqXDCI,278
13
13
  dclab/isoelastics/iso_LE-2D-FEM-19-volume-deform.txt,sha256=vTcazOlOXo3BQ0NQtGB_IdHKA0neOLXZ_d3JuMU--RE,83358
14
14
  dclab/isoelastics/iso_HE-3D-FEM-22-area_um-deform.txt,sha256=IjULG1KO-hClaYPoJJnwPbF2TkS9i9jxF1tbhhQTClY,71350
@@ -50,7 +50,7 @@ dclab/cli/task_compress.py,sha256=LH3j41aKq5regAH-ZFdOgnXImf5DrReDJ7ITwUObUSQ,41
50
50
  dclab/kde/contours.py,sha256=WoRqBj_xK-23FZjtaYly7E2Q8sGZ16q2ILq-DmrlmC8,6742
51
51
  dclab/kde/methods.py,sha256=8g4lYUKYqt2pdA9efHVRBDCUUzmePmWPp6rljtJ0XD8,9438
52
52
  dclab/kde/__init__.py,sha256=_WSLPMfxE2su6tmO5mJxUE_9ON16-pqQUQCUlzRtyKI,55
53
- dclab/kde/base.py,sha256=KuV_9_AJ4Sn14C4WAH4eF63URAVYCnaFOcLgsVCaAjo,12961
53
+ dclab/kde/base.py,sha256=w0or7ix8hnK-xqtGSyhyn48YUo55WnEEPsBjWrJna9s,16196
54
54
  dclab/external/__init__.py,sha256=gb0UdzoMymEURPsTXRqVTT1ZJedJ2ubH3jApBIRkwjk,93
55
55
  dclab/external/packaging/version.py,sha256=9MLL6_EYHvGA1yCGndwL5ZmmDA_wqQsW15GyKrI6siQ,14685
56
56
  dclab/external/packaging/LICENSE,sha256=ytHvW9NA1z4HS6YU0m996spceUDD2MNIUuZcSQlobEg,197
@@ -70,11 +70,11 @@ dclab/external/skimage/pnpoly.py,sha256=r8hFNiTz5XlUoNZjosqA0iyv1FPn0l7ewbplgFgk
70
70
  dclab/external/skimage/_find_contours.py,sha256=16v5eeTZBmevG8SSuXtJ6yUpVPhwfSmtc8pDD0nuuOU,9340
71
71
  dclab/external/skimage/__init__.py,sha256=-B2QUKHAFzQuBWuuKvPDC5JIl0Zb-x3OGmbwPaE9VwQ,72
72
72
  dclab/external/skimage/_pnpoly.pyx,sha256=Qdn6xPazDschBqbr46DzB75MB2MnqvdnoTSBMK7kUGE,2504
73
- dclab/external/skimage/_find_contours_cy.cpython-311-darwin.so,sha256=KXnlFOHj_uQ__xskIdI1YnEsvUXi_NsmtMIlcVul9kc,188720
73
+ dclab/external/skimage/_find_contours_cy.cpython-311-darwin.so,sha256=FpittJbhwCXhLudTVAzi45uM1yMeharQzYgBoT4E8l4,189352
74
74
  dclab/external/skimage/_find_contours_cy.pyx,sha256=pZJOBhMHzYEMkcz4WQVyjn7jDNrdjCfet47FU1hRAxk,7161
75
- dclab/external/skimage/_pnpoly.cpython-311-darwin.so,sha256=mwAi1m2UnUKjJxPcBu2OdKz7jNU3jegRtLjzzlNGEho,194192
75
+ dclab/external/skimage/_pnpoly.cpython-311-darwin.so,sha256=-XGCpbXeNzPxQrHmoIT_-aSV3I1tE_oH47zgDMrbspU,194824
76
76
  dclab/external/skimage/_shared/geometry.pxd,sha256=kRsu9ifv_rL3kbRIgSLf86p0hn2oTMp6s013lZ9bBZM,346
77
- dclab/external/skimage/_shared/geometry.cpython-311-darwin.so,sha256=mN7l27MiiDAEssQ4PDOCGYwFZnsxE12AgfomAjVWgZg,38320
77
+ dclab/external/skimage/_shared/geometry.cpython-311-darwin.so,sha256=W3HYe3Ri6ZRPsQqOyilrLlem965_nbRvnpH0DjQ1Ycw,38320
78
78
  dclab/external/skimage/_shared/__init__.py,sha256=2sHZwTtJSlMTa3Q2YSvQW7jrPLMUSqDJQa-ROe5zfcw,37
79
79
  dclab/external/skimage/_shared/geometry.pyx,sha256=miCHUh6mBDbRRIoaF_0xAER1MRzsCAzFdlYQZhV7RmE,1667
80
80
  dclab/definitions/feat_logic.py,sha256=SXsSlAusgtE3uXcPu84dQwYZ07zxmV37DmPednA3_dM,5823
@@ -134,9 +134,9 @@ dclab/rtdc_dataset/fmt_tdms/event_image.py,sha256=-jp7Z-N91e4ieumYQ1huMicj7PMJqw
134
134
  dclab/rtdc_dataset/fmt_tdms/event_trace.py,sha256=Vkym0QKSw2mq1XZl5n8wDkgHXmaZwQGiMAV5AuRSJkE,5215
135
135
  dclab/rtdc_dataset/fmt_tdms/exc.py,sha256=WzrMqnyrzp8gsT8Pf7JKqGGv43ewx7d_qgtirURppRI,813
136
136
  dclab/rtdc_dataset/fmt_tdms/event_contour.py,sha256=kjo0wJx9F0gmmOOyR0NoLw6VEtSl3h63WXXkcbfnoS8,9627
137
- dclab-0.64.0.dist-info/RECORD,,
138
- dclab-0.64.0.dist-info/WHEEL,sha256=osp_SOLYJPdNJIHZoUXoIdnwmLNnAVt6RayTuFLQ60s,137
139
- dclab-0.64.0.dist-info/entry_points.txt,sha256=eOpjgznu-eW-9utUpLU-77O5098YyUEgGF3ksGMdtec,273
140
- dclab-0.64.0.dist-info/top_level.txt,sha256=irvwZMgs1edY1Zj60ZFk7Almb9Zhk4k6E6aC4YPFnnM,6
141
- dclab-0.64.0.dist-info/METADATA,sha256=zfrjZaLGPiE_ZPYkVtoUGvGI-CPkjgY-eiKJshd-3bo,4755
142
- dclab-0.64.0.dist-info/licenses/LICENSE,sha256=gLDaVZWRrlnLdyfOrR0qfWjLbOVcjvoJ-kCLUK0fyXA,15360
137
+ dclab-0.64.1.dist-info/RECORD,,
138
+ dclab-0.64.1.dist-info/WHEEL,sha256=TY6wS7uh4kKn2hb4-XnLjkub5JFV8id422w1jhyVjcQ,137
139
+ dclab-0.64.1.dist-info/entry_points.txt,sha256=eOpjgznu-eW-9utUpLU-77O5098YyUEgGF3ksGMdtec,273
140
+ dclab-0.64.1.dist-info/top_level.txt,sha256=irvwZMgs1edY1Zj60ZFk7Almb9Zhk4k6E6aC4YPFnnM,6
141
+ dclab-0.64.1.dist-info/METADATA,sha256=WoNkTGPhcp_6fJpJQ2r9HPAJoxE_lRtwE4mQGj56tCE,4766
142
+ dclab-0.64.1.dist-info/licenses/LICENSE,sha256=gLDaVZWRrlnLdyfOrR0qfWjLbOVcjvoJ-kCLUK0fyXA,15360
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.7.1)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp311-cp311-macosx_10_9_x86_64
5
5
  Generator: delocate 0.13.0