dcnum 0.18.0__py3-none-any.whl → 0.19.1__py3-none-any.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 dcnum might be problematic. Click here for more details.
- dcnum/_version.py +2 -2
- dcnum/feat/feat_background/bg_roll_median.py +3 -2
- dcnum/logic/ctrl.py +12 -19
- dcnum/read/hdf5_data.py +44 -2
- dcnum/read/mapped.py +1 -3
- {dcnum-0.18.0.dist-info → dcnum-0.19.1.dist-info}/METADATA +1 -1
- {dcnum-0.18.0.dist-info → dcnum-0.19.1.dist-info}/RECORD +10 -10
- {dcnum-0.18.0.dist-info → dcnum-0.19.1.dist-info}/LICENSE +0 -0
- {dcnum-0.18.0.dist-info → dcnum-0.19.1.dist-info}/WHEEL +0 -0
- {dcnum-0.18.0.dist-info → dcnum-0.19.1.dist-info}/top_level.txt +0 -0
dcnum/_version.py
CHANGED
|
@@ -119,7 +119,7 @@ class BackgroundRollMed(Background):
|
|
|
119
119
|
"""Check user-defined properties of this class
|
|
120
120
|
|
|
121
121
|
This method primarily exists so that the CLI knows which
|
|
122
|
-
keyword
|
|
122
|
+
keyword arguments can be passed to this class.
|
|
123
123
|
|
|
124
124
|
Parameters
|
|
125
125
|
----------
|
|
@@ -132,7 +132,8 @@ class BackgroundRollMed(Background):
|
|
|
132
132
|
`kernel_size` will not increase computation speed. Larger
|
|
133
133
|
values lead to a higher memory consumption.
|
|
134
134
|
"""
|
|
135
|
-
assert kernel_size > 0
|
|
135
|
+
assert kernel_size > 0, "kernel size must be positive number"
|
|
136
|
+
assert kernel_size % 2 == 0, "kernel size must be even number"
|
|
136
137
|
assert batch_size > kernel_size
|
|
137
138
|
|
|
138
139
|
def get_slices_for_batch(self, batch_index=0):
|
dcnum/logic/ctrl.py
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import collections
|
|
2
2
|
import datetime
|
|
3
|
-
import hashlib
|
|
4
3
|
import json
|
|
5
4
|
import logging
|
|
6
5
|
from logging.handlers import QueueListener
|
|
7
6
|
import multiprocessing as mp
|
|
8
|
-
import numbers
|
|
9
7
|
import os
|
|
10
8
|
import pathlib
|
|
11
9
|
import platform
|
|
@@ -16,7 +14,6 @@ import traceback
|
|
|
16
14
|
import uuid
|
|
17
15
|
|
|
18
16
|
import h5py
|
|
19
|
-
import numpy as np
|
|
20
17
|
|
|
21
18
|
from ..feat.feat_background.base import get_available_background_methods
|
|
22
19
|
from ..feat.queue_event_extractor import QueueEventExtractor
|
|
@@ -313,7 +310,17 @@ class DCNumJobRunner(threading.Thread):
|
|
|
313
310
|
# Whether pipeline hash is invalid.
|
|
314
311
|
ppid.compute_pipeline_hash(**datdict) != dathash
|
|
315
312
|
# Whether the input file is the original output of the pipeline.
|
|
316
|
-
or len(self.draw) != evyield
|
|
313
|
+
or len(self.draw) != evyield
|
|
314
|
+
# If index mapping is defined, then we always redo the pipeline.
|
|
315
|
+
# If the pipeline hashes are identical and index mapping is not
|
|
316
|
+
# None, then both pipelines were done with index mapping.
|
|
317
|
+
# But applying the same pipeline with index mapping in series
|
|
318
|
+
# will lead to a different result in the second run (e.g. 1st
|
|
319
|
+
# pipeline run: take every 2nd event; 2nd pipeline run: take
|
|
320
|
+
# every second event -> results in every 4th event in output of
|
|
321
|
+
# second pipeline run).
|
|
322
|
+
or self.draw.index_mapping is not None
|
|
323
|
+
)
|
|
317
324
|
# Do we have to recompute the background data? In addition to the
|
|
318
325
|
# hash sanity check above, check the generation, input data,
|
|
319
326
|
# and background pipeline identifiers.
|
|
@@ -387,21 +394,7 @@ class DCNumJobRunner(threading.Thread):
|
|
|
387
394
|
hw.h5.attrs["pipeline:dcnum yield"] = self.event_count
|
|
388
395
|
# index mapping information
|
|
389
396
|
im = self.job.kwargs["data_kwargs"].get("index_mapping", None)
|
|
390
|
-
|
|
391
|
-
dim = "0"
|
|
392
|
-
elif isinstance(im, numbers.Number):
|
|
393
|
-
dim = f"{im}"
|
|
394
|
-
elif isinstance(im, slice):
|
|
395
|
-
dim = (f"{im.start if im.start is not None else 'n'}"
|
|
396
|
-
+ f"-{im.stop if im.stop is not None else 'n'}"
|
|
397
|
-
+ f"-{im.step if im.step is not None else 'n'}"
|
|
398
|
-
)
|
|
399
|
-
elif isinstance(im, (list, np.ndarray)):
|
|
400
|
-
idhash = hashlib.md5(
|
|
401
|
-
np.array(im, dtype=np.uint32).tobytes()).hexdigest()
|
|
402
|
-
dim = f"h-{idhash[:8]}"
|
|
403
|
-
else:
|
|
404
|
-
dim = "unknown"
|
|
397
|
+
dim = HDF5Data.get_ppid_index_mapping(im)
|
|
405
398
|
hw.h5.attrs["pipeline:dcnum mapping"] = dim
|
|
406
399
|
# regular metadata
|
|
407
400
|
hw.h5.attrs["experiment:event count"] = self.event_count
|
dcnum/read/hdf5_data.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import hashlib
|
|
3
4
|
import io
|
|
4
5
|
import json
|
|
6
|
+
import numbers
|
|
5
7
|
import pathlib
|
|
6
8
|
import tempfile
|
|
7
9
|
from typing import Dict, BinaryIO, List
|
|
@@ -293,7 +295,9 @@ class HDF5Data:
|
|
|
293
295
|
self.h5.close()
|
|
294
296
|
|
|
295
297
|
def get_ppid(self):
|
|
296
|
-
return self.get_ppid_from_ppkw(
|
|
298
|
+
return self.get_ppid_from_ppkw(
|
|
299
|
+
{"pixel_size": self.pixel_size,
|
|
300
|
+
"index_mapping": self.index_mapping})
|
|
297
301
|
|
|
298
302
|
@classmethod
|
|
299
303
|
def get_ppid_code(cls):
|
|
@@ -304,10 +308,34 @@ class HDF5Data:
|
|
|
304
308
|
# Data does not really fit into the PPID scheme we use for the rest
|
|
305
309
|
# of the pipeline. This implementation here is custom.
|
|
306
310
|
code = cls.get_ppid_code()
|
|
311
|
+
# pixel size
|
|
307
312
|
ppid_ps = f"{kwargs['pixel_size']:.8f}".rstrip("0")
|
|
308
|
-
|
|
313
|
+
# index mapping
|
|
314
|
+
ppid_im = cls.get_ppid_index_mapping(kwargs.get("index_mapping", None))
|
|
315
|
+
kwid = "^".join([f"p={ppid_ps}", f"i={ppid_im}"])
|
|
309
316
|
return ":".join([code, kwid])
|
|
310
317
|
|
|
318
|
+
@staticmethod
|
|
319
|
+
def get_ppid_index_mapping(index_mapping):
|
|
320
|
+
"""Return the pipeline identifier part for index mapping"""
|
|
321
|
+
im = index_mapping
|
|
322
|
+
if im is None:
|
|
323
|
+
dim = "0"
|
|
324
|
+
elif isinstance(im, numbers.Integral):
|
|
325
|
+
dim = f"{im}"
|
|
326
|
+
elif isinstance(im, slice):
|
|
327
|
+
dim = (f"{im.start if im.start is not None else 'n'}"
|
|
328
|
+
+ f"-{im.stop if im.stop is not None else 'n'}"
|
|
329
|
+
+ f"-{im.step if im.step is not None else 'n'}"
|
|
330
|
+
)
|
|
331
|
+
elif isinstance(im, (list, np.ndarray)):
|
|
332
|
+
idhash = hashlib.md5(
|
|
333
|
+
np.array(im, dtype=np.uint32).tobytes()).hexdigest()
|
|
334
|
+
dim = f"h-{idhash[:8]}"
|
|
335
|
+
else:
|
|
336
|
+
dim = "unknown"
|
|
337
|
+
return dim
|
|
338
|
+
|
|
311
339
|
@staticmethod
|
|
312
340
|
def get_ppkw_from_ppid(dat_ppid):
|
|
313
341
|
# Data does not fit in the PPID scheme we use, but we still
|
|
@@ -321,6 +349,20 @@ class HDF5Data:
|
|
|
321
349
|
var, val = item.split("=")
|
|
322
350
|
if var == "p":
|
|
323
351
|
kwargs["pixel_size"] = float(val)
|
|
352
|
+
elif var == "i":
|
|
353
|
+
if val.startswith("h-") or val == "unknown":
|
|
354
|
+
raise ValueError(f"Cannot invert index mapping {val}")
|
|
355
|
+
elif val == "0":
|
|
356
|
+
kwargs["index_mapping"] = None
|
|
357
|
+
elif val.count("-"):
|
|
358
|
+
start, stop, step = val.split("-")
|
|
359
|
+
kwargs["index_mapping"] = slice(
|
|
360
|
+
None if start == "n" else int(start),
|
|
361
|
+
None if stop == "n" else int(stop),
|
|
362
|
+
None if step == "n" else int(step)
|
|
363
|
+
)
|
|
364
|
+
else:
|
|
365
|
+
kwargs["index_mapping"] = int(val)
|
|
324
366
|
else:
|
|
325
367
|
raise ValueError(f"Invalid parameter '{var}'!")
|
|
326
368
|
return kwargs
|
dcnum/read/mapped.py
CHANGED
|
@@ -54,12 +54,10 @@ def _get_mapping_indices_cached(
|
|
|
54
54
|
return np.arange(index_mapping)
|
|
55
55
|
elif isinstance(index_mapping, tuple):
|
|
56
56
|
im_slice = slice(*index_mapping)
|
|
57
|
-
if im_slice.step is not None:
|
|
58
|
-
raise NotImplementedError("Slices with step not implemented yet")
|
|
59
57
|
if im_slice.stop is None or im_slice.start is None:
|
|
60
58
|
raise NotImplementedError(
|
|
61
59
|
"Slices must have start and stop defined")
|
|
62
|
-
return np.arange(im_slice.start, im_slice.stop)
|
|
60
|
+
return np.arange(im_slice.start, im_slice.stop, im_slice.step)
|
|
63
61
|
elif isinstance(index_mapping, list):
|
|
64
62
|
return np.array(index_mapping, dtype=np.uint32)
|
|
65
63
|
else:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
dcnum/__init__.py,sha256=hcawIKS7utYiOyVhOAX9t7K3xYzP1b9862VV0b6qSrQ,74
|
|
2
|
-
dcnum/_version.py,sha256=
|
|
2
|
+
dcnum/_version.py,sha256=wOLHPF5OO0ubEMjzvaXg4CVhVL1uy5Ci-sH1WTZH0Dg,413
|
|
3
3
|
dcnum/feat/__init__.py,sha256=jUJYWTD3VIoDNKrmryXbjHb1rGwYtK4b7VPWihYgUoo,325
|
|
4
4
|
dcnum/feat/event_extractor_manager_thread.py,sha256=Ocid_t1awH6pOmurCmKYkC51XsXB0-DoN3fzjFDgE4c,7129
|
|
5
5
|
dcnum/feat/gate.py,sha256=svbObmqpYdqPawpfrsEjTiUPJXf24GrNi8PXTKT-z44,7225
|
|
@@ -7,7 +7,7 @@ dcnum/feat/queue_event_extractor.py,sha256=XhA930QVQ1Z4saisbcGTrEut-fSgwTyfDn6b9
|
|
|
7
7
|
dcnum/feat/feat_background/__init__.py,sha256=OTmMuazHNaSrZb2XW4cnJ6PlgJLbKrPbaidpEixYa0A,341
|
|
8
8
|
dcnum/feat/feat_background/base.py,sha256=IYBFfsGXBfmFnZfD9QrmfrXbJtFSfVOS-v-u-uxSThs,7985
|
|
9
9
|
dcnum/feat/feat_background/bg_copy.py,sha256=muU-6eTUf3HTA2K2asrLWcR_hbRMjdygZROmjNXCm7Q,923
|
|
10
|
-
dcnum/feat/feat_background/bg_roll_median.py,sha256=
|
|
10
|
+
dcnum/feat/feat_background/bg_roll_median.py,sha256=j3seExcWkk6IeFIOO4zkj-LIA7ryig9bmGYYj_dDgoM,13173
|
|
11
11
|
dcnum/feat/feat_background/bg_sparse_median.py,sha256=-CShs4UAuZd00rACaXTZj3dccKevhcSGRsILFgMPLWo,20705
|
|
12
12
|
dcnum/feat/feat_brightness/__init__.py,sha256=o6AebVlmydwNgVF5kW6ITqJyFreoKrU3Ki_3EC8If-s,155
|
|
13
13
|
dcnum/feat/feat_brightness/bright_all.py,sha256=vf8xaYBdKD24hHUXdkI0_S7nbr7m49KW6gvuWvbHDVg,4545
|
|
@@ -20,7 +20,7 @@ dcnum/feat/feat_texture/__init__.py,sha256=6StM9S540UVtdFFR3bHa7nfCTomeVdoo7Uy9C
|
|
|
20
20
|
dcnum/feat/feat_texture/common.py,sha256=COXHpXS-7DMouGu3WF83I76L02Sr7P9re4lxajh6g0E,439
|
|
21
21
|
dcnum/feat/feat_texture/tex_all.py,sha256=eGjjNfPpfZw7FA_VNFCIMiU38KD0qcGbxLciYy-tCiA,4097
|
|
22
22
|
dcnum/logic/__init__.py,sha256=7J3GrwJInNQbrLk61HRIV7X7p69TAIbMYpR34hh6u14,177
|
|
23
|
-
dcnum/logic/ctrl.py,sha256=
|
|
23
|
+
dcnum/logic/ctrl.py,sha256=FvVXbrP7WqgYeDznep0KyfMck3cbCO8Yoli8P6clRPc,27956
|
|
24
24
|
dcnum/logic/job.py,sha256=M0Q-Rfcm-zkTXTQc79W6YSNUjUlgmRPG0Ikbdn1aOpY,4608
|
|
25
25
|
dcnum/logic/json_encoder.py,sha256=cxMnqisbKEVf-rVcw6rK2BBAb6iz_hKFaGl81kK36lQ,571
|
|
26
26
|
dcnum/meta/__init__.py,sha256=AVqRgyKXO1orKnE305h88IBvoZ1oz6X11HN1WP5nGvg,60
|
|
@@ -29,8 +29,8 @@ dcnum/meta/ppid.py,sha256=Q3jg8lZt5tlGIby_-7rBqTANesMjJrmxASXZhsvBD_Y,7706
|
|
|
29
29
|
dcnum/read/__init__.py,sha256=8uGj4YN7pDP4FO9TkZWXrpScwTLVWSEZexFq-TS9vsA,215
|
|
30
30
|
dcnum/read/cache.py,sha256=kC2Y9hXA92ARQ2Vgm1kBFCU-s6TPE1tPYvpzWI0aPow,5619
|
|
31
31
|
dcnum/read/const.py,sha256=8ih8rlWM7ntp8phrr9dh22hXXb210igSCatOSI9Ou30,463
|
|
32
|
-
dcnum/read/hdf5_data.py,sha256=
|
|
33
|
-
dcnum/read/mapped.py,sha256=
|
|
32
|
+
dcnum/read/hdf5_data.py,sha256=psMN2CGorU4uFO1nlGcpUxKFLZ9HaKCReTi7tVx50tg,22291
|
|
33
|
+
dcnum/read/mapped.py,sha256=Oh1jH2yVqWBPomEf8vlGvsGOMc02ldapAAjgNo-bS7g,2676
|
|
34
34
|
dcnum/segm/__init__.py,sha256=iiq_1A9DU5wMUcKnsZ53E7NyzCkbZCJeUDimzunE-OM,247
|
|
35
35
|
dcnum/segm/segm_thresh.py,sha256=lMf-lso_O_5Q5lJiiIQdYkM3zlj4uwNz9cNvLxVMeXc,1396
|
|
36
36
|
dcnum/segm/segmenter.py,sha256=gVzmP6CuwI9Qfk8GN_xWGu_xbtVTOhxIOWn-2yr_H1Y,12220
|
|
@@ -41,8 +41,8 @@ dcnum/write/__init__.py,sha256=Cpn3LqL18hh8OScUnGp_AnNfpWPpKW-oAJZH6ot7aRA,241
|
|
|
41
41
|
dcnum/write/deque_writer_thread.py,sha256=KpJ6po8JPlM696MITN-bhNnWQcy9E-qlhg9g-uzoPZg,1710
|
|
42
42
|
dcnum/write/queue_collector_thread.py,sha256=YQ6pvKNmCDf1C6HVx6gOA-q-FBoI6nkhOo-tAVYnyag,11906
|
|
43
43
|
dcnum/write/writer.py,sha256=nlJfQCPoW2Wze72y_256G4qmgYMdh5mL0vpvqg7lSaU,11728
|
|
44
|
-
dcnum-0.
|
|
45
|
-
dcnum-0.
|
|
46
|
-
dcnum-0.
|
|
47
|
-
dcnum-0.
|
|
48
|
-
dcnum-0.
|
|
44
|
+
dcnum-0.19.1.dist-info/LICENSE,sha256=YRChA1C8A2E-amJbudwMcbTCZy_HzmeY0hMIvduh1MM,1089
|
|
45
|
+
dcnum-0.19.1.dist-info/METADATA,sha256=tWMwpFt4Nn8vs1H0aRTBWDmH3pej-O3gWHJ6ESkbvSw,2194
|
|
46
|
+
dcnum-0.19.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
47
|
+
dcnum-0.19.1.dist-info/top_level.txt,sha256=Hmh38rgG_MFTVDpUDGuO2HWTSq80P585Het4COQzFTg,6
|
|
48
|
+
dcnum-0.19.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|