dclab 0.64.0__cp311-cp311-win_amd64.whl → 0.64.1__cp311-cp311-win_amd64.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,13 +1,13 @@
1
1
  dclab/__init__.py,sha256=kSr6VI0UI-beS9beOEpERTUAV1NINHx_G6u1VmBm9D8,1624
2
- dclab/_version.py,sha256=0j6jwYqVbZkAlg02f-8H_THxmeCYIPDxuOyC8QfwGHg,534
2
+ dclab/_version.py,sha256=mXVRd4XXSvubXnCvvibtN_3CiyIT4FFBF_TNPrxM6fk,534
3
3
  dclab/cached.py,sha256=t01BYTf43VEsBYa0c-bMxgceF5vKoGV73b42UlLH6Lo,3014
4
- dclab/downsampling.cp311-win_amd64.pyd,sha256=Tq1VQF3-aAuQbSio1tpjr8JjCZ8EvNscl-YMJYnrVM4,169984
4
+ dclab/downsampling.cp311-win_amd64.pyd,sha256=1zkkvDZVFA-MarNlbVazghDgze7d5S9uXTL2mp3GDKA,170496
5
5
  dclab/downsampling.pyx,sha256=Ez6MbNbzCUzs2IXXKtAYsjtYqP22kI8hdA1IE-3mqvY,7488
6
6
  dclab/http_utils.py,sha256=aIW4ATmyk02AjQmoTm7mAWdsaQD1siEPLx47IlEcYls,11234
7
7
  dclab/kde_contours.py,sha256=cYeBtvbBqLHCz5W8AiEAAd9O3yLsSBbLcRVj1WZ1pRo,288
8
8
  dclab/kde_methods.py,sha256=tY82WQsX2_5_Szb7zma9yQD-HxCg2fAkMvNs-K05jMQ,376
9
9
  dclab/polygon_filter.py,sha256=C4uBvK8zzT8irUOIgITvASlCtc0EEMM5edp4dFx-9jw,13878
10
- dclab/statistics.py,sha256=6saNuiXCcYmI8_cmb8Tb7E34BbsxHzTvNNlbKeNoDIw,6558
10
+ dclab/statistics.py,sha256=nluuzl9h-RokxpsYLFLTAx6gnt6ArBhmQJffZbeIlac,7824
11
11
  dclab/util.py,sha256=X9LqxrEJNClzPSko49MMsz2MlybLwkButqqQmxfnj44,6036
12
12
  dclab/warn.py,sha256=pv_W9cKBJg-mUn-_6O4xBwRmwI9QaEIW9EBEIiyL0iU,538
13
13
  dclab/cli/__init__.py,sha256=IB33_cscv866CAwXnP1ZO9tlBpOldB0UQuR5P87FmSQ,493
@@ -35,14 +35,14 @@ dclab/external/packaging/version.py,sha256=NgEgv7me4UCvFMyiNYD-nc_28b9UHUvBVh8RD
35
35
  dclab/external/skimage/LICENSE,sha256=Tdv08zzxYV32WRdYnco9P3nVyS5w17OTxIAFeRSd1wc,1480
36
36
  dclab/external/skimage/__init__.py,sha256=icOIlThkyn_hxmnM_i7OpbU7fhvqYWNpGdNGD38qthU,74
37
37
  dclab/external/skimage/_find_contours.py,sha256=auRMNfZg7B73DX7kPXxgD8gMXXB3Lk9QDWt4wlQnUWg,9556
38
- dclab/external/skimage/_find_contours_cy.cp311-win_amd64.pyd,sha256=yWP17yqiQHy8_mhH9vFxZltRF_8uM5x-Lo0UeFyAKEk,130560
38
+ dclab/external/skimage/_find_contours_cy.cp311-win_amd64.pyd,sha256=RNLFzsG6KBMS3XehjxaFj-s4OFa6D4gRCUa7P__oNX8,131072
39
39
  dclab/external/skimage/_find_contours_cy.pyx,sha256=c-EobLhKjZNCpuqWxmvrcH35uAY_Bu-_hZiUHbXODms,7349
40
- dclab/external/skimage/_pnpoly.cp311-win_amd64.pyd,sha256=JNYo9E6tHmdJUgHXqKY49uXr96AeZ3Ds_RmgjHsh0cs,144384
40
+ dclab/external/skimage/_pnpoly.cp311-win_amd64.pyd,sha256=ttMj3Jk-h6NDRCD3ngRGPjDOU51Q-EFuU5XD1wR3o6I,144896
41
41
  dclab/external/skimage/_pnpoly.pyx,sha256=eHV3DlIGcBhAQ12-Y58EYq8xcq0Sibyc4xTxzX9NJsk,2603
42
42
  dclab/external/skimage/measure.py,sha256=rzyI0HCr9O9GJNieVW8pcqDjTGRAdSehDUawD8QkIAE,254
43
43
  dclab/external/skimage/pnpoly.py,sha256=zB4rSxjHJyY1OsGZ7QfFQqxIEDLGK8CWPehwutoFqm4,1400
44
44
  dclab/external/skimage/_shared/__init__.py,sha256=q29esTsNh0HfQxcd2EuwdYNbEBJwo_qY4dfv7RihzoA,38
45
- dclab/external/skimage/_shared/geometry.cp311-win_amd64.pyd,sha256=BrdRvUc9AJWt39wkohryFuclAI7MIdBhZNWIQUOfz6o,19456
45
+ dclab/external/skimage/_shared/geometry.cp311-win_amd64.pyd,sha256=_qenxbnbWLM2ll3e5ZW0HLJnRvn3WLx_xEFAB5-CU0U,19456
46
46
  dclab/external/skimage/_shared/geometry.pxd,sha256=3gJ7fbXXsxJunSN4biE0dzEbZpX9ZqzR4cUDDN0JnAU,352
47
47
  dclab/external/skimage/_shared/geometry.pyx,sha256=b6hADE8chse63haO1Kdt13_oQ54J9tkBf7dVA22-s-M,1722
48
48
  dclab/external/statsmodels/LICENSE,sha256=8D7nwukc6YgsZCdN9mG0psM3I9j-z8fuUgFyVhnMXpU,1672
@@ -76,7 +76,7 @@ dclab/isoelastics/iso_LE-2D-FEM-19-area_um-deform.txt,sha256=lcTjUUnIwj_bVBrG2T2
76
76
  dclab/isoelastics/iso_LE-2D-FEM-19-volume-deform.txt,sha256=vTcazOlOXo3BQ0NQtGB_IdHKA0neOLXZ_d3JuMU--RE,83358
77
77
  dclab/isoelastics/iso_LE-2D-ana-18-area_um-deform.txt,sha256=KD2RkhCfkrna20pLJ3UzNZZapMkhQydMYz0iKdMtRRE,46805
78
78
  dclab/kde/__init__.py,sha256=A7GXfOI-6HNxD1ljkmnU9NjkFhoT2_WxlPmJa29PLm0,56
79
- dclab/kde/base.py,sha256=ZfCIWzWg4LH-B7k0q1uWleH0zbBJv0olnF2evynQZ2c,13337
79
+ dclab/kde/base.py,sha256=mp3xnPCqA5hP1aD3Owa9U3SxfrnTGTk_hKPuuBlFtw8,16655
80
80
  dclab/kde/contours.py,sha256=vWx34Zxe9CuKd255Lje67pYEYZsLrCVPNopf_dHanL8,6964
81
81
  dclab/kde/methods.py,sha256=diRNGM7U91UHEGMaee2PcxSegQ9OGUPVt6McI7DhCFM,9751
82
82
  dclab/lme4/__init__.py,sha256=85rlF3G9ZblRue7SB2DrMqSfVPVyE37ujr55Oy7OZaI,277
@@ -134,9 +134,9 @@ dclab/rtdc_dataset/fmt_tdms/event_mask.py,sha256=cW-Tw2PIe6X1Hc4UZJ22-mI_qFaIMWA
134
134
  dclab/rtdc_dataset/fmt_tdms/event_trace.py,sha256=ktWnXfMir1v5Wfeo7tOd0txSOe1bgsXotf9Ul5T5-B4,5361
135
135
  dclab/rtdc_dataset/fmt_tdms/exc.py,sha256=FfxUY4LGIMPGJTYmGITmEm7X5iu8GBsj7OfZR8Zb-IE,850
136
136
  dclab/rtdc_dataset/fmt_tdms/naming.py,sha256=SFeWiwIN7sg0qNe0Aya2bZshN1Zbw4YcOKunZ6kfIGM,5524
137
- dclab-0.64.0.dist-info/licenses/LICENSE,sha256=Aq3cYb2xLk3Y_aIOhaoZxi8FlVeMVs3-3FMEBvAEixM,15643
138
- dclab-0.64.0.dist-info/METADATA,sha256=5nq9U2WWCWAlhgIEJLU4bA512Ycrly7A2Hmqa9y6fSM,4902
139
- dclab-0.64.0.dist-info/WHEEL,sha256=qxRMWkcfC6EPKglFaripnDVKofxBh0a8FNl-gKWx4zc,101
140
- dclab-0.64.0.dist-info/entry_points.txt,sha256=eOpjgznu-eW-9utUpLU-77O5098YyUEgGF3ksGMdtec,273
141
- dclab-0.64.0.dist-info/top_level.txt,sha256=irvwZMgs1edY1Zj60ZFk7Almb9Zhk4k6E6aC4YPFnnM,6
142
- dclab-0.64.0.dist-info/RECORD,,
137
+ dclab-0.64.1.dist-info/licenses/LICENSE,sha256=Aq3cYb2xLk3Y_aIOhaoZxi8FlVeMVs3-3FMEBvAEixM,15643
138
+ dclab-0.64.1.dist-info/METADATA,sha256=g2ygLFICqk7MKmTDzdSZIdHfR4YVuCpqytG8HSy69qo,4913
139
+ dclab-0.64.1.dist-info/WHEEL,sha256=JLOMsP7F5qtkAkINx5UnzbFguf8CqZeraV8o04b0I8I,101
140
+ dclab-0.64.1.dist-info/entry_points.txt,sha256=eOpjgznu-eW-9utUpLU-77O5098YyUEgGF3ksGMdtec,273
141
+ dclab-0.64.1.dist-info/top_level.txt,sha256=irvwZMgs1edY1Zj60ZFk7Almb9Zhk4k6E6aC4YPFnnM,6
142
+ dclab-0.64.1.dist-info/RECORD,,
@@ -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-win_amd64
5
5