PyOPIA 1.1.4__tar.gz → 1.1.6__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.
Potentially problematic release.
This version of PyOPIA might be problematic. Click here for more details.
- {pyopia-1.1.4 → pyopia-1.1.6}/PKG-INFO +21 -15
- {pyopia-1.1.4 → pyopia-1.1.6}/README.md +20 -14
- pyopia-1.1.6/pyopia/__init__.py +1 -0
- {pyopia-1.1.4 → pyopia-1.1.6}/pyopia/background.py +1 -6
- {pyopia-1.1.4 → pyopia-1.1.6}/pyopia/instrument/holo.py +1 -1
- {pyopia-1.1.4 → pyopia-1.1.6}/pyopia/instrument/silcam.py +5 -3
- {pyopia-1.1.4 → pyopia-1.1.6}/pyopia/process.py +11 -6
- {pyopia-1.1.4 → pyopia-1.1.6}/pyopia/statistics.py +7 -3
- pyopia-1.1.4/pyopia/__init__.py +0 -1
- {pyopia-1.1.4 → pyopia-1.1.6}/LICENSE +0 -0
- {pyopia-1.1.4 → pyopia-1.1.6}/pyopia/classify.py +0 -0
- {pyopia-1.1.4 → pyopia-1.1.6}/pyopia/cli.py +0 -0
- {pyopia-1.1.4 → pyopia-1.1.6}/pyopia/instrument/__init__.py +0 -0
- {pyopia-1.1.4 → pyopia-1.1.6}/pyopia/io.py +0 -0
- {pyopia-1.1.4 → pyopia-1.1.6}/pyopia/pipeline.py +0 -0
- {pyopia-1.1.4 → pyopia-1.1.6}/pyopia/plotting.py +0 -0
- {pyopia-1.1.4 → pyopia-1.1.6}/pyopia/tests/__init__.py +0 -0
- {pyopia-1.1.4 → pyopia-1.1.6}/pyopia/tests/test_pipeline.py +0 -0
- {pyopia-1.1.4 → pyopia-1.1.6}/pyopia/tests/testdata.py +0 -0
- {pyopia-1.1.4 → pyopia-1.1.6}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyOPIA
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.6
|
|
4
4
|
Summary: A Python Ocean Particle Image Analysis toolbox.
|
|
5
5
|
Home-page: https://github.com/sintef/pyopia
|
|
6
6
|
Keywords: Ocean,Particles,Imaging,Measurement,Size distribution
|
|
@@ -60,18 +60,6 @@ A Python Ocean Particle Image Analysis toolbox
|
|
|
60
60
|
|
|
61
61
|
- Under development. See/regester issues, [here](https://github.com/SINTEF/pyopia/issues)
|
|
62
62
|
|
|
63
|
-
----
|
|
64
|
-
|
|
65
|
-
# Installing for users
|
|
66
|
-
|
|
67
|
-
Users are expected to be familiar with Python, and have [Python](https://github.com/conda-forge/miniforge/#download), [pip](https://pypi.org/project/pip/). You can then install Pyopia like this:
|
|
68
|
-
|
|
69
|
-
```
|
|
70
|
-
pip install pyopia
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
We would usually recommend installing within a virtual python environment, which you can read more about [here](https://jni.github.io/using-python-for-science/intro-to-environments.html).
|
|
74
|
-
|
|
75
63
|
----
|
|
76
64
|
# Development targets for PyOpia:
|
|
77
65
|
|
|
@@ -101,9 +89,15 @@ We welcome additions and improvements to the code! We request that you follow a
|
|
|
101
89
|
4. All pull requests must be reviewed by a person. The benefits from code review are plenty, but we like to emphasise that code reviews help spreading the awarenes of code changes. Please note that code reviews should be a pleasant experience, so be plesant, polite and remember that there is a human being with good intentions on the other side of the screen.
|
|
102
90
|
5. All contributions are linted with flake8. We recommend that you run flake8 on your code while developing to fix any issues as you go. We recommend using autopep8 to autoformat your Python code (but please check the code behaviour is not affected by autoformatting before pushing). This makes flake8 happy, and makes it easier for us all to maintain a consistent and readable code base.
|
|
103
91
|
|
|
104
|
-
|
|
92
|
+
# Installing
|
|
93
|
+
|
|
94
|
+
## For users
|
|
95
|
+
|
|
96
|
+
Users are expected to be familiar with Python. Please refer to the recommended installation instructions provided on the documentation pages, [here](https://pyopia.readthedocs.io/en/latest/intro.html#installing)
|
|
105
97
|
|
|
106
|
-
|
|
98
|
+
## For developers from source
|
|
99
|
+
|
|
100
|
+
Install [Python](https://github.com/conda-forge/miniforge/#download) version 3.10.
|
|
107
101
|
|
|
108
102
|
A prompt such as is provided by the [miniforge installation](https://github.com/conda-forge/miniforge/#download) may be used for the following:
|
|
109
103
|
|
|
@@ -142,6 +136,18 @@ conda activate pyopia
|
|
|
142
136
|
poetry install
|
|
143
137
|
```
|
|
144
138
|
|
|
139
|
+
Optional dependecies (for classification), can be installed like this:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
poetry install --extras "classification"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
or for arm/silicon systems:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
poetry install --extras "classification-arm64"
|
|
149
|
+
```
|
|
150
|
+
|
|
145
151
|
3. (optional) Run local tests:
|
|
146
152
|
|
|
147
153
|
```bash
|
|
@@ -12,18 +12,6 @@ A Python Ocean Particle Image Analysis toolbox
|
|
|
12
12
|
|
|
13
13
|
- Under development. See/regester issues, [here](https://github.com/SINTEF/pyopia/issues)
|
|
14
14
|
|
|
15
|
-
----
|
|
16
|
-
|
|
17
|
-
# Installing for users
|
|
18
|
-
|
|
19
|
-
Users are expected to be familiar with Python, and have [Python](https://github.com/conda-forge/miniforge/#download), [pip](https://pypi.org/project/pip/). You can then install Pyopia like this:
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
pip install pyopia
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
We would usually recommend installing within a virtual python environment, which you can read more about [here](https://jni.github.io/using-python-for-science/intro-to-environments.html).
|
|
26
|
-
|
|
27
15
|
----
|
|
28
16
|
# Development targets for PyOpia:
|
|
29
17
|
|
|
@@ -53,9 +41,15 @@ We welcome additions and improvements to the code! We request that you follow a
|
|
|
53
41
|
4. All pull requests must be reviewed by a person. The benefits from code review are plenty, but we like to emphasise that code reviews help spreading the awarenes of code changes. Please note that code reviews should be a pleasant experience, so be plesant, polite and remember that there is a human being with good intentions on the other side of the screen.
|
|
54
42
|
5. All contributions are linted with flake8. We recommend that you run flake8 on your code while developing to fix any issues as you go. We recommend using autopep8 to autoformat your Python code (but please check the code behaviour is not affected by autoformatting before pushing). This makes flake8 happy, and makes it easier for us all to maintain a consistent and readable code base.
|
|
55
43
|
|
|
56
|
-
|
|
44
|
+
# Installing
|
|
45
|
+
|
|
46
|
+
## For users
|
|
47
|
+
|
|
48
|
+
Users are expected to be familiar with Python. Please refer to the recommended installation instructions provided on the documentation pages, [here](https://pyopia.readthedocs.io/en/latest/intro.html#installing)
|
|
57
49
|
|
|
58
|
-
|
|
50
|
+
## For developers from source
|
|
51
|
+
|
|
52
|
+
Install [Python](https://github.com/conda-forge/miniforge/#download) version 3.10.
|
|
59
53
|
|
|
60
54
|
A prompt such as is provided by the [miniforge installation](https://github.com/conda-forge/miniforge/#download) may be used for the following:
|
|
61
55
|
|
|
@@ -94,6 +88,18 @@ conda activate pyopia
|
|
|
94
88
|
poetry install
|
|
95
89
|
```
|
|
96
90
|
|
|
91
|
+
Optional dependecies (for classification), can be installed like this:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
poetry install --extras "classification"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
or for arm/silicon systems:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
poetry install --extras "classification-arm64"
|
|
101
|
+
```
|
|
102
|
+
|
|
97
103
|
3. (optional) Run local tests:
|
|
98
104
|
|
|
99
105
|
```bash
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '1.1.6'
|
|
@@ -94,12 +94,7 @@ def correct_im_accurate(imbg, imraw):
|
|
|
94
94
|
'''
|
|
95
95
|
|
|
96
96
|
imc = np.float64(imraw) - np.float64(imbg)
|
|
97
|
-
|
|
98
|
-
imc[:, :, 0] += (255 / 2 - np.percentile(imc[:, :, 0], 50))
|
|
99
|
-
imc[:, :, 1] += (255 / 2 - np.percentile(imc[:, :, 1], 50))
|
|
100
|
-
imc[:, :, 2] += (255 / 2 - np.percentile(imc[:, :, 2], 50))
|
|
101
|
-
else:
|
|
102
|
-
imc += (255 / 2 - np.percentile(imc, 50))
|
|
97
|
+
imc += (255 / 2 - np.percentile(imc, 50))
|
|
103
98
|
|
|
104
99
|
imc += 255 - imc.max()
|
|
105
100
|
|
|
@@ -242,7 +242,7 @@ def create_kernel(im, pixel_size, wavelength, n, offset, minZ, maxZ, stepZ):
|
|
|
242
242
|
|
|
243
243
|
f = (np.pi / (pixel_size / 1e6)) * (f1**2 + f2**2)**0.5
|
|
244
244
|
|
|
245
|
-
z = (np.arange(minZ * 1e-3, maxZ * 1e-3, stepZ * 1e-3) / n) + (offset * 1e-3)
|
|
245
|
+
z = (np.arange(minZ * 1e-3, (maxZ + stepZ) * 1e-3, stepZ * 1e-3) / n) + (offset * 1e-3)
|
|
246
246
|
|
|
247
247
|
wavelength_m = wavelength * 1e-9
|
|
248
248
|
k = 2 * np.pi / wavelength_m
|
|
@@ -3,9 +3,9 @@ Module containing SilCam specific tools to enable compatability with the :mod:`p
|
|
|
3
3
|
'''
|
|
4
4
|
|
|
5
5
|
import os
|
|
6
|
-
|
|
7
6
|
import numpy as np
|
|
8
7
|
import pandas as pd
|
|
8
|
+
from skimage.exposure import rescale_intensity
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
def timestamp_from_filename(filename):
|
|
@@ -36,7 +36,7 @@ def load_image(filename):
|
|
|
36
36
|
array
|
|
37
37
|
raw image
|
|
38
38
|
'''
|
|
39
|
-
img = np.load(filename, allow_pickle=False).astype(np.
|
|
39
|
+
img = np.load(filename, allow_pickle=False).astype(np.uint8)
|
|
40
40
|
return img
|
|
41
41
|
|
|
42
42
|
|
|
@@ -97,9 +97,11 @@ class ImagePrep():
|
|
|
97
97
|
|
|
98
98
|
def __call__(self, data):
|
|
99
99
|
image = data[self.image_level]
|
|
100
|
-
data['imref'] = image
|
|
101
100
|
imc = np.float64(image)
|
|
102
101
|
|
|
102
|
+
image = rescale_intensity(image, out_range=(0, 255))
|
|
103
|
+
data['imref'] = np.uint8(image)
|
|
104
|
+
|
|
103
105
|
# simplify processing by squeezing the image dimensions into a 2D array
|
|
104
106
|
# min is used for squeezing to represent the highest attenuation of all wavelengths
|
|
105
107
|
imc = np.min(imc, axis=2)
|
|
@@ -286,7 +286,7 @@ def extract_particles(imc, timestamp, Classification, region_properties,
|
|
|
286
286
|
|
|
287
287
|
if Classification is not None:
|
|
288
288
|
# run a prediction on what type of particle this might be
|
|
289
|
-
prediction = Classification.proc_predict(roi
|
|
289
|
+
prediction = Classification.proc_predict(roi)
|
|
290
290
|
predictions[int(i), :] = prediction[0]
|
|
291
291
|
|
|
292
292
|
# add the roi to the HDF5 file
|
|
@@ -336,8 +336,7 @@ def measure_particles(imbw, max_particles=5000):
|
|
|
336
336
|
|
|
337
337
|
# if there are too many particles then do no proceed with analysis
|
|
338
338
|
if (iml.max() > max_particles):
|
|
339
|
-
|
|
340
|
-
imbw *= 0 # this is not a good way to handle this condition
|
|
339
|
+
raise RuntimeError('Too many particles. Refer to documentation on max_particles parameter in measure_particles()')
|
|
341
340
|
# @todo handle situation when too many particles are found
|
|
342
341
|
|
|
343
342
|
region_properties = measure.regionprops(iml, cache=False)
|
|
@@ -424,14 +423,14 @@ def statextract(imbw, timestamp, imc,
|
|
|
424
423
|
|
|
425
424
|
# build the stats and export to HDF5
|
|
426
425
|
s = np.shape(imc)
|
|
427
|
-
if
|
|
426
|
+
if len(s) == 2:
|
|
428
427
|
imref = np.copy(imc)
|
|
429
428
|
imc = np.zeros((np.shape(imc)[0], np.shape(imc)[1], 3), dtype=np.uint8)
|
|
430
429
|
# Convert from floats in [0, 1] to ints in [0, 255]
|
|
431
430
|
imc[:, :, 0] = 255 * imref
|
|
432
431
|
imc[:, :, 1] = 255 * imref
|
|
433
432
|
imc[:, :, 2] = 255 * imref
|
|
434
|
-
print('WARNING.
|
|
433
|
+
print('WARNING! Unexpected image dimension. extract_particles modified for 2-d images without color!')
|
|
435
434
|
|
|
436
435
|
stats = extract_particles(imc, timestamp, Classification, region_properties,
|
|
437
436
|
export_outputpath=export_outputpath, min_length=min_length,
|
|
@@ -537,7 +536,13 @@ class CalculateStats():
|
|
|
537
536
|
|
|
538
537
|
def __call__(self, data):
|
|
539
538
|
print('statextract')
|
|
540
|
-
|
|
539
|
+
if 'imref' not in data.keys():
|
|
540
|
+
if data['cl'] is not None:
|
|
541
|
+
print('WARNING. No reference image ("imref") for classifier. Resorting to "imc"')
|
|
542
|
+
imc = data['imc']
|
|
543
|
+
else:
|
|
544
|
+
imc = data['imref']
|
|
545
|
+
stats, saturation = statextract(data['imbw'], data['timestamp'], imc,
|
|
541
546
|
Classification=data['cl'],
|
|
542
547
|
max_coverage=self.max_coverage,
|
|
543
548
|
max_particles=self.max_particles,
|
|
@@ -296,13 +296,14 @@ def vd_from_stats(stats, pix_size):
|
|
|
296
296
|
return dias, vd
|
|
297
297
|
|
|
298
298
|
|
|
299
|
-
def make_montage(
|
|
299
|
+
def make_montage(stats_file_or_df, pixel_size, roidir,
|
|
300
300
|
auto_scaler=500, msize=1024, maxlength=100000, crop_stats=None, brightness=255, eyecandy=True):
|
|
301
301
|
'''
|
|
302
302
|
makes nice looking montage from a directory of extracted particle images
|
|
303
303
|
|
|
304
304
|
Args:
|
|
305
|
-
|
|
305
|
+
stats_file_or_df : either a str specifying the location of the STATS.nc file that comes from processing,
|
|
306
|
+
or a stats dataframe
|
|
306
307
|
pixel_size : pixel size of system defined by settings.PostProcess.pix_size
|
|
307
308
|
roidir : location of roifiles usually defined by settings.ExportParticles.outputpath
|
|
308
309
|
auto_scaler=500 : approximate number of particle that are attempted to be packed into montage
|
|
@@ -318,7 +319,10 @@ def make_montage(stats_file, pixel_size, roidir,
|
|
|
318
319
|
which can be plotted using plotting.montage_plot(montage, settings.PostProcess.pix_size)
|
|
319
320
|
'''
|
|
320
321
|
|
|
321
|
-
|
|
322
|
+
if isinstance(stats_file_or_df, str):
|
|
323
|
+
stats = load_stats_as_dataframe(stats_file_or_df)
|
|
324
|
+
else:
|
|
325
|
+
stats = stats_file_or_df
|
|
322
326
|
|
|
323
327
|
if crop_stats is not None:
|
|
324
328
|
stats = crop_stats(stats, crop_stats)
|
pyopia-1.1.4/pyopia/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '1.1.4'
|
|
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
|