nanoobjectdetection 2.0.0__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.
- nanoobjectdetection-2.0.0/MANIFEST.in +5 -0
- nanoobjectdetection-2.0.0/PKG-INFO +249 -0
- nanoobjectdetection-2.0.0/README.md +217 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/__init__.py +24 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/__main__.py +6 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/application.py +670 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/auto_parameters.py +177 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/calibration.py +64 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/config.py +202 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/drift.py +47 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/gpu.py +126 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/hindrance.py +56 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/legacy_config.py +157 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/legacy_outputs.py +121 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/localization.py +73 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/msd.py +215 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/pipeline.py +874 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/plotting.py +234 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/preprocessing.py +56 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/progress.py +32 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/quality.py +133 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/statistics.py +59 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/stitching.py +97 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/storage.py +187 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/synthetic.py +28 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/tracking.py +75 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/trajectory_processing.py +81 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection/ultra_uniform.py +52 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection.egg-info/PKG-INFO +249 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection.egg-info/SOURCES.txt +35 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection.egg-info/dependency_links.txt +1 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection.egg-info/entry_points.txt +2 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection.egg-info/requires.txt +11 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection.egg-info/top_level.txt +2 -0
- nanoobjectdetection-2.0.0/nanoobjectdetection_2_0/__init__.py +30 -0
- nanoobjectdetection-2.0.0/pyproject.toml +62 -0
- nanoobjectdetection-2.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nanoobjectdetection
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Particle localization and diffusion analysis for TIFF image stacks
|
|
5
|
+
Author: Tim Stechel, Ronny Förster
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/knobold/NanoObjectDetection
|
|
8
|
+
Project-URL: Repository, https://github.com/knobold/NanoObjectDetection
|
|
9
|
+
Project-URL: Issues, https://github.com/knobold/NanoObjectDetection/issues
|
|
10
|
+
Keywords: nanoparticles,microscopy,diffusion,tracking,stokes-einstein,trackpy,tiff
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Image Processing
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: numpy
|
|
23
|
+
Requires-Dist: pandas
|
|
24
|
+
Requires-Dist: scipy
|
|
25
|
+
Requires-Dist: tifffile
|
|
26
|
+
Requires-Dist: trackpy
|
|
27
|
+
Requires-Dist: tqdm
|
|
28
|
+
Requires-Dist: matplotlib
|
|
29
|
+
Requires-Dist: numba
|
|
30
|
+
Provides-Extra: gpu
|
|
31
|
+
Requires-Dist: cupy-cuda12x; extra == "gpu"
|
|
32
|
+
|
|
33
|
+
# NanoObjectDetection 2.0
|
|
34
|
+
|
|
35
|
+
This is a new Version of Ronny Foersters Package. The old Package had lots of issues with type safety and RAM usage. This new implementation aims to improve RAM usage and enable us to easily develop new features.
|
|
36
|
+
|
|
37
|
+
NanoObjectDetection analyzes TIFF image stacks of diffusing particles. It
|
|
38
|
+
localizes particles, links detections into trajectories, estimates diffusion
|
|
39
|
+
and hydrodynamic diameter, and exports analysis tables and plots. Version 2.0
|
|
40
|
+
keeps compatibility with the 1.0 parameter format and adds blockwise
|
|
41
|
+
processing and optional CUDA acceleration.
|
|
42
|
+
|
|
43
|
+
The source checkout also contains the original 1.0 implementation in
|
|
44
|
+
[`nanoobjectdetection_legacy/`](./nanoobjectdetection_legacy/); the installable
|
|
45
|
+
distribution packages the modern pipeline under the `nanoobjectdetection`
|
|
46
|
+
package. For full parameter descriptions,
|
|
47
|
+
scientific methods, compatibility details, limitations, and output-file
|
|
48
|
+
definitions, see the
|
|
49
|
+
[2.0 documentation](./NANOOBJECTDETECTION_2_0_DOCUMENTATION.md).
|
|
50
|
+
|
|
51
|
+
## Features
|
|
52
|
+
|
|
53
|
+
- TIFF stack input with spatial and frame-range ROI selection.
|
|
54
|
+
- Camera-offset, laser-fluctuation, static-background, and optional SNR
|
|
55
|
+
preprocessing.
|
|
56
|
+
- Trackpy particle localization and trajectory linking, including optional
|
|
57
|
+
stitching for repeatedly lost single-particle detections.
|
|
58
|
+
- Fixed-particle filtering, trajectory quality checks, and global drift
|
|
59
|
+
correction.
|
|
60
|
+
- Mean-squared displacement analysis, diffusion estimation, and
|
|
61
|
+
Stokes-Einstein hydrodynamic diameter calculations.
|
|
62
|
+
- Optional channel hindrance correction, including position-aware correction.
|
|
63
|
+
- Single Particle Tracking using stitched Trajectories
|
|
64
|
+
- RAM saving options: Single-stack and chunked execution modes, plus optional CUDA preprocessing, Optional Conversion of pixels to 8bit depth, 16bit is probably overkill.
|
|
65
|
+
- CSV tables, compatibility output names, run configuration, and plots.
|
|
66
|
+
|
|
67
|
+
## New Features
|
|
68
|
+
|
|
69
|
+
- Try to implement them on your own! AI is powerful and easy too use. You can then try to submit a merge request here.
|
|
70
|
+
|
|
71
|
+
## Issues
|
|
72
|
+
|
|
73
|
+
- 1st Try to solve the issue yourself with AI
|
|
74
|
+
-> if its a bug caused by this repo, not your local installation open an Issue or write me a detailed Bug report on Slack. Paste console logs or anything that helps me solve your issue.
|
|
75
|
+
|
|
76
|
+
## Installation
|
|
77
|
+
|
|
78
|
+
### From PyPI (Recommended)
|
|
79
|
+
|
|
80
|
+
Install the latest release directly via pip:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
python -m pip install --upgrade pip
|
|
84
|
+
python -m pip install nanoobjectdetection
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
For GPU acceleration with CUDA 12.x:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
python -m pip install "nanoobjectdetection[gpu]"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### From Source Checkout
|
|
94
|
+
|
|
95
|
+
Download this repo as a `.zip` file and unpack it, or clone via Git.
|
|
96
|
+
From the repository folder, activate your environment and install:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
python -m pip install --upgrade pip
|
|
100
|
+
python -m pip install .
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
To install an editable development copy instead, use `python -m pip install -e .` from the repository folder.
|
|
104
|
+
|
|
105
|
+
The installation adds the `nanoobjectdetection` CLI command. It can be run from
|
|
106
|
+
any working directory:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
nanoobjectdetection --input-file "path/to/stack.tif" --output-dir "path/to/output"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Python Example & Scripting
|
|
113
|
+
|
|
114
|
+
The recommended way to use the package is to adjust analysis parameters in an example script. Run the included [`example/example.py`](./example/example.py) from any directory:
|
|
115
|
+
|
|
116
|
+
```powershell
|
|
117
|
+
python "example/example.py" `
|
|
118
|
+
--input-file "path/to/my_stack.tif" `
|
|
119
|
+
--output-dir "path/to/my_analysis" `
|
|
120
|
+
--background-stack-storage disk `
|
|
121
|
+
--processing-bit-depth 8 `
|
|
122
|
+
--dimension all
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The script imports `run` directly from the installed package:
|
|
126
|
+
```python
|
|
127
|
+
from nanoobjectdetection import run
|
|
128
|
+
```
|
|
129
|
+
Its `PARAMETERS` dictionary and processing settings near the top of
|
|
130
|
+
`example/example.py` expose the full analysis configuration for editing. Omit
|
|
131
|
+
`--parameter-file` to use those settings; optionally add
|
|
132
|
+
`--parameter-file "path/to/parameter.json"` to use a legacy JSON instead.
|
|
133
|
+
Input/output paths can be configured directly inside the script or passed as CLI options.
|
|
134
|
+
Run `python example/example.py --help` for all options.
|
|
135
|
+
|
|
136
|
+
### Optional GPU preprocessing
|
|
137
|
+
|
|
138
|
+
GPU mode requires a supported NVIDIA GPU, a compatible CUDA runtime, and the
|
|
139
|
+
matching CuPy package. For CUDA 12.x, install the package's GPU extra:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
python -m pip install ".[gpu]"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
If your CUDA version differs, install the CuPy package matching your CUDA
|
|
146
|
+
runtime instead. The pipeline reports an error if GPU mode is requested but a
|
|
147
|
+
usable CUDA device is unavailable. Trackpy localization, linking, and MSD
|
|
148
|
+
fitting remain CPU operations.
|
|
149
|
+
|
|
150
|
+
## Run from an IDE
|
|
151
|
+
|
|
152
|
+
The source `main.py` defaults to the included example TIFF and can be run
|
|
153
|
+
directly from VS Code, PyCharm, or another Python IDE:
|
|
154
|
+
|
|
155
|
+
1. Open the repository folder in your IDE.
|
|
156
|
+
2. Select the Python interpreter from the `.venv` environment created above.
|
|
157
|
+
In VS Code, use **Python: Select Interpreter**; in PyCharm, select the
|
|
158
|
+
project interpreter in the Python interpreter settings.
|
|
159
|
+
3. Run `main.py` with the IDE's **Run Python File** or **Run** action to
|
|
160
|
+
analyze the included example.
|
|
161
|
+
|
|
162
|
+
For your own data, use the installed command with a parameter JSON rather than
|
|
163
|
+
editing `main.py`. Review camera calibration, acquisition rate, temperature,
|
|
164
|
+
viscosity, channel dimensions, ROI, and Trackpy settings in that JSON.
|
|
165
|
+
|
|
166
|
+
## Run from a terminal
|
|
167
|
+
|
|
168
|
+
Run an installed analysis from any folder in PowerShell:
|
|
169
|
+
|
|
170
|
+
```powershell
|
|
171
|
+
nanoobjectdetection `
|
|
172
|
+
--parameter-file "C:\data\parameter.json" `
|
|
173
|
+
--input-file "C:\data\my_stack.tif" `
|
|
174
|
+
--output-dir "C:\data\my_analysis" `
|
|
175
|
+
--processing-mode single_stack `
|
|
176
|
+
--background-stack-storage disk `
|
|
177
|
+
--processing-bit-depth 8
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
To install the package from another folder or drive, use its repository path:
|
|
181
|
+
|
|
182
|
+
```powershell
|
|
183
|
+
python -m pip install "D:\Python\NanoObjectDetection"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
The source script can also be run with options from the repository folder:
|
|
187
|
+
|
|
188
|
+
```powershell
|
|
189
|
+
python .\main.py `
|
|
190
|
+
--input-file "C:\data\my_stack.tif" `
|
|
191
|
+
--output-dir "C:\data\my_analysis" `
|
|
192
|
+
--processing-mode single_stack `
|
|
193
|
+
--dimension 2d `
|
|
194
|
+
--background-stack-storage disk
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
To use a legacy-format parameter file:
|
|
198
|
+
|
|
199
|
+
```powershell
|
|
200
|
+
python .\main.py `
|
|
201
|
+
--parameter-file ".\example\parameter.json" `
|
|
202
|
+
--input-file ".\example\20_6µmKap_50Au_20_7C_100fps_5000fr_700us_V1j.tif" `
|
|
203
|
+
--output-dir ".\example\my_analysis" `
|
|
204
|
+
--processing-mode chunked
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
The input and output command-line paths override the corresponding paths in
|
|
208
|
+
the parameter JSON. If `--parameter-file` is omitted, the analysis settings
|
|
209
|
+
defined in `main.py` are used.
|
|
210
|
+
|
|
211
|
+
Available command-line options:
|
|
212
|
+
|
|
213
|
+
| Option | Purpose |
|
|
214
|
+
|---|---|
|
|
215
|
+
| `--processing-mode single_stack` | Read frames directly from the TIFF; this is the default. |
|
|
216
|
+
| `--processing-mode chunked` | Store/process the selected stack in blocks, useful for large inputs. |
|
|
217
|
+
| `--background-stack-storage memory` | Keep the background stack used for subtraction in RAM (default). |
|
|
218
|
+
| `--background-stack-storage disk` | Use a temporary disk-backed stack; needs free space approximately equal to the selected-depth ROI stack. |
|
|
219
|
+
| `--processing-bit-depth 16` | Preserve the input pixel values (default). |
|
|
220
|
+
| `--processing-bit-depth 8` | For uint16 input, keep the high 8 bits (`value >> 8`) for stored/raw processing data; halves raw/background stack storage but discards low-bit precision. |
|
|
221
|
+
| `--dimension all` | Analyze x, y, and 2d trajectories; this is the default. |
|
|
222
|
+
| `--dimension x`, `--dimension y`, `--dimension 2d` | Calculate only the selected trajectory dimension. |
|
|
223
|
+
| `--gpu` | Enable GPU preprocessing; requires compatible CuPy/CUDA installation. |
|
|
224
|
+
| `--input-file PATH` | Select the TIFF stack to analyze. |
|
|
225
|
+
| `--output-dir PATH` | Select where results are written. |
|
|
226
|
+
| `--parameter-file PATH` | Load analysis settings from a legacy-format JSON file. |
|
|
227
|
+
|
|
228
|
+
Disk-backed background storage preserves the same calculation as memory
|
|
229
|
+
storage at the selected bit depth and removes its temporary stack file after
|
|
230
|
+
localization. It can use more disk I/O and run more slowly than keeping the
|
|
231
|
+
stack in RAM.
|
|
232
|
+
|
|
233
|
+
8-bit processing is opt-in and quantizes uint16 values by shifting right eight
|
|
234
|
+
bits; it is not equivalent to the default 16-bit analysis and can change
|
|
235
|
+
background subtraction and particle detections. It reduces raw and background
|
|
236
|
+
stack storage by about half, but not total process memory because processing
|
|
237
|
+
also uses float32 working arrays. For uint8 TIFF input, this option leaves the
|
|
238
|
+
pixel values unchanged.
|
|
239
|
+
|
|
240
|
+
Chunking reduces localization working-block size, but does not make the exact
|
|
241
|
+
stack-wide static-background calculation bounded-memory. When that
|
|
242
|
+
preprocessing option is enabled, the selected ROI stack must fit in RAM even
|
|
243
|
+
in chunked mode. Reduce the ROI or frame range if memory is insufficient.
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
See the [2.0 documentation](./NANOOBJECTDETECTION_2_0_DOCUMENTATION.md) for
|
|
248
|
+
the complete list of supported settings, generated files, assumptions, and
|
|
249
|
+
known limitations.
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# NanoObjectDetection 2.0
|
|
2
|
+
|
|
3
|
+
This is a new Version of Ronny Foersters Package. The old Package had lots of issues with type safety and RAM usage. This new implementation aims to improve RAM usage and enable us to easily develop new features.
|
|
4
|
+
|
|
5
|
+
NanoObjectDetection analyzes TIFF image stacks of diffusing particles. It
|
|
6
|
+
localizes particles, links detections into trajectories, estimates diffusion
|
|
7
|
+
and hydrodynamic diameter, and exports analysis tables and plots. Version 2.0
|
|
8
|
+
keeps compatibility with the 1.0 parameter format and adds blockwise
|
|
9
|
+
processing and optional CUDA acceleration.
|
|
10
|
+
|
|
11
|
+
The source checkout also contains the original 1.0 implementation in
|
|
12
|
+
[`nanoobjectdetection_legacy/`](./nanoobjectdetection_legacy/); the installable
|
|
13
|
+
distribution packages the modern pipeline under the `nanoobjectdetection`
|
|
14
|
+
package. For full parameter descriptions,
|
|
15
|
+
scientific methods, compatibility details, limitations, and output-file
|
|
16
|
+
definitions, see the
|
|
17
|
+
[2.0 documentation](./NANOOBJECTDETECTION_2_0_DOCUMENTATION.md).
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- TIFF stack input with spatial and frame-range ROI selection.
|
|
22
|
+
- Camera-offset, laser-fluctuation, static-background, and optional SNR
|
|
23
|
+
preprocessing.
|
|
24
|
+
- Trackpy particle localization and trajectory linking, including optional
|
|
25
|
+
stitching for repeatedly lost single-particle detections.
|
|
26
|
+
- Fixed-particle filtering, trajectory quality checks, and global drift
|
|
27
|
+
correction.
|
|
28
|
+
- Mean-squared displacement analysis, diffusion estimation, and
|
|
29
|
+
Stokes-Einstein hydrodynamic diameter calculations.
|
|
30
|
+
- Optional channel hindrance correction, including position-aware correction.
|
|
31
|
+
- Single Particle Tracking using stitched Trajectories
|
|
32
|
+
- RAM saving options: Single-stack and chunked execution modes, plus optional CUDA preprocessing, Optional Conversion of pixels to 8bit depth, 16bit is probably overkill.
|
|
33
|
+
- CSV tables, compatibility output names, run configuration, and plots.
|
|
34
|
+
|
|
35
|
+
## New Features
|
|
36
|
+
|
|
37
|
+
- Try to implement them on your own! AI is powerful and easy too use. You can then try to submit a merge request here.
|
|
38
|
+
|
|
39
|
+
## Issues
|
|
40
|
+
|
|
41
|
+
- 1st Try to solve the issue yourself with AI
|
|
42
|
+
-> if its a bug caused by this repo, not your local installation open an Issue or write me a detailed Bug report on Slack. Paste console logs or anything that helps me solve your issue.
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
### From PyPI (Recommended)
|
|
47
|
+
|
|
48
|
+
Install the latest release directly via pip:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
python -m pip install --upgrade pip
|
|
52
|
+
python -m pip install nanoobjectdetection
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
For GPU acceleration with CUDA 12.x:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
python -m pip install "nanoobjectdetection[gpu]"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### From Source Checkout
|
|
62
|
+
|
|
63
|
+
Download this repo as a `.zip` file and unpack it, or clone via Git.
|
|
64
|
+
From the repository folder, activate your environment and install:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
python -m pip install --upgrade pip
|
|
68
|
+
python -m pip install .
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
To install an editable development copy instead, use `python -m pip install -e .` from the repository folder.
|
|
72
|
+
|
|
73
|
+
The installation adds the `nanoobjectdetection` CLI command. It can be run from
|
|
74
|
+
any working directory:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
nanoobjectdetection --input-file "path/to/stack.tif" --output-dir "path/to/output"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Python Example & Scripting
|
|
81
|
+
|
|
82
|
+
The recommended way to use the package is to adjust analysis parameters in an example script. Run the included [`example/example.py`](./example/example.py) from any directory:
|
|
83
|
+
|
|
84
|
+
```powershell
|
|
85
|
+
python "example/example.py" `
|
|
86
|
+
--input-file "path/to/my_stack.tif" `
|
|
87
|
+
--output-dir "path/to/my_analysis" `
|
|
88
|
+
--background-stack-storage disk `
|
|
89
|
+
--processing-bit-depth 8 `
|
|
90
|
+
--dimension all
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The script imports `run` directly from the installed package:
|
|
94
|
+
```python
|
|
95
|
+
from nanoobjectdetection import run
|
|
96
|
+
```
|
|
97
|
+
Its `PARAMETERS` dictionary and processing settings near the top of
|
|
98
|
+
`example/example.py` expose the full analysis configuration for editing. Omit
|
|
99
|
+
`--parameter-file` to use those settings; optionally add
|
|
100
|
+
`--parameter-file "path/to/parameter.json"` to use a legacy JSON instead.
|
|
101
|
+
Input/output paths can be configured directly inside the script or passed as CLI options.
|
|
102
|
+
Run `python example/example.py --help` for all options.
|
|
103
|
+
|
|
104
|
+
### Optional GPU preprocessing
|
|
105
|
+
|
|
106
|
+
GPU mode requires a supported NVIDIA GPU, a compatible CUDA runtime, and the
|
|
107
|
+
matching CuPy package. For CUDA 12.x, install the package's GPU extra:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
python -m pip install ".[gpu]"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
If your CUDA version differs, install the CuPy package matching your CUDA
|
|
114
|
+
runtime instead. The pipeline reports an error if GPU mode is requested but a
|
|
115
|
+
usable CUDA device is unavailable. Trackpy localization, linking, and MSD
|
|
116
|
+
fitting remain CPU operations.
|
|
117
|
+
|
|
118
|
+
## Run from an IDE
|
|
119
|
+
|
|
120
|
+
The source `main.py` defaults to the included example TIFF and can be run
|
|
121
|
+
directly from VS Code, PyCharm, or another Python IDE:
|
|
122
|
+
|
|
123
|
+
1. Open the repository folder in your IDE.
|
|
124
|
+
2. Select the Python interpreter from the `.venv` environment created above.
|
|
125
|
+
In VS Code, use **Python: Select Interpreter**; in PyCharm, select the
|
|
126
|
+
project interpreter in the Python interpreter settings.
|
|
127
|
+
3. Run `main.py` with the IDE's **Run Python File** or **Run** action to
|
|
128
|
+
analyze the included example.
|
|
129
|
+
|
|
130
|
+
For your own data, use the installed command with a parameter JSON rather than
|
|
131
|
+
editing `main.py`. Review camera calibration, acquisition rate, temperature,
|
|
132
|
+
viscosity, channel dimensions, ROI, and Trackpy settings in that JSON.
|
|
133
|
+
|
|
134
|
+
## Run from a terminal
|
|
135
|
+
|
|
136
|
+
Run an installed analysis from any folder in PowerShell:
|
|
137
|
+
|
|
138
|
+
```powershell
|
|
139
|
+
nanoobjectdetection `
|
|
140
|
+
--parameter-file "C:\data\parameter.json" `
|
|
141
|
+
--input-file "C:\data\my_stack.tif" `
|
|
142
|
+
--output-dir "C:\data\my_analysis" `
|
|
143
|
+
--processing-mode single_stack `
|
|
144
|
+
--background-stack-storage disk `
|
|
145
|
+
--processing-bit-depth 8
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
To install the package from another folder or drive, use its repository path:
|
|
149
|
+
|
|
150
|
+
```powershell
|
|
151
|
+
python -m pip install "D:\Python\NanoObjectDetection"
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The source script can also be run with options from the repository folder:
|
|
155
|
+
|
|
156
|
+
```powershell
|
|
157
|
+
python .\main.py `
|
|
158
|
+
--input-file "C:\data\my_stack.tif" `
|
|
159
|
+
--output-dir "C:\data\my_analysis" `
|
|
160
|
+
--processing-mode single_stack `
|
|
161
|
+
--dimension 2d `
|
|
162
|
+
--background-stack-storage disk
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
To use a legacy-format parameter file:
|
|
166
|
+
|
|
167
|
+
```powershell
|
|
168
|
+
python .\main.py `
|
|
169
|
+
--parameter-file ".\example\parameter.json" `
|
|
170
|
+
--input-file ".\example\20_6µmKap_50Au_20_7C_100fps_5000fr_700us_V1j.tif" `
|
|
171
|
+
--output-dir ".\example\my_analysis" `
|
|
172
|
+
--processing-mode chunked
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The input and output command-line paths override the corresponding paths in
|
|
176
|
+
the parameter JSON. If `--parameter-file` is omitted, the analysis settings
|
|
177
|
+
defined in `main.py` are used.
|
|
178
|
+
|
|
179
|
+
Available command-line options:
|
|
180
|
+
|
|
181
|
+
| Option | Purpose |
|
|
182
|
+
|---|---|
|
|
183
|
+
| `--processing-mode single_stack` | Read frames directly from the TIFF; this is the default. |
|
|
184
|
+
| `--processing-mode chunked` | Store/process the selected stack in blocks, useful for large inputs. |
|
|
185
|
+
| `--background-stack-storage memory` | Keep the background stack used for subtraction in RAM (default). |
|
|
186
|
+
| `--background-stack-storage disk` | Use a temporary disk-backed stack; needs free space approximately equal to the selected-depth ROI stack. |
|
|
187
|
+
| `--processing-bit-depth 16` | Preserve the input pixel values (default). |
|
|
188
|
+
| `--processing-bit-depth 8` | For uint16 input, keep the high 8 bits (`value >> 8`) for stored/raw processing data; halves raw/background stack storage but discards low-bit precision. |
|
|
189
|
+
| `--dimension all` | Analyze x, y, and 2d trajectories; this is the default. |
|
|
190
|
+
| `--dimension x`, `--dimension y`, `--dimension 2d` | Calculate only the selected trajectory dimension. |
|
|
191
|
+
| `--gpu` | Enable GPU preprocessing; requires compatible CuPy/CUDA installation. |
|
|
192
|
+
| `--input-file PATH` | Select the TIFF stack to analyze. |
|
|
193
|
+
| `--output-dir PATH` | Select where results are written. |
|
|
194
|
+
| `--parameter-file PATH` | Load analysis settings from a legacy-format JSON file. |
|
|
195
|
+
|
|
196
|
+
Disk-backed background storage preserves the same calculation as memory
|
|
197
|
+
storage at the selected bit depth and removes its temporary stack file after
|
|
198
|
+
localization. It can use more disk I/O and run more slowly than keeping the
|
|
199
|
+
stack in RAM.
|
|
200
|
+
|
|
201
|
+
8-bit processing is opt-in and quantizes uint16 values by shifting right eight
|
|
202
|
+
bits; it is not equivalent to the default 16-bit analysis and can change
|
|
203
|
+
background subtraction and particle detections. It reduces raw and background
|
|
204
|
+
stack storage by about half, but not total process memory because processing
|
|
205
|
+
also uses float32 working arrays. For uint8 TIFF input, this option leaves the
|
|
206
|
+
pixel values unchanged.
|
|
207
|
+
|
|
208
|
+
Chunking reduces localization working-block size, but does not make the exact
|
|
209
|
+
stack-wide static-background calculation bounded-memory. When that
|
|
210
|
+
preprocessing option is enabled, the selected ROI stack must fit in RAM even
|
|
211
|
+
in chunked mode. Reduce the ROI or frame range if memory is insufficient.
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
See the [2.0 documentation](./NANOOBJECTDETECTION_2_0_DOCUMENTATION.md) for
|
|
216
|
+
the complete list of supported settings, generated files, assumptions, and
|
|
217
|
+
known limitations.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""NanoObjectDetection: particle localization and diffusion analysis for TIFF image stacks."""
|
|
2
|
+
|
|
3
|
+
__version__ = "2.0.0"
|
|
4
|
+
|
|
5
|
+
from .application import run
|
|
6
|
+
from .config import AnalysisConfig
|
|
7
|
+
from .pipeline import AnalysisPipeline
|
|
8
|
+
from .drift import correct_global
|
|
9
|
+
from .hindrance import corrected_diameter_nm, hindrance_factor, local_channel_diameter_nm
|
|
10
|
+
from .msd import calculate_msd, estimate_diffusion
|
|
11
|
+
from .synthetic import brownian_trajectories
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"AnalysisConfig",
|
|
15
|
+
"AnalysisPipeline",
|
|
16
|
+
"brownian_trajectories",
|
|
17
|
+
"calculate_msd",
|
|
18
|
+
"correct_global",
|
|
19
|
+
"corrected_diameter_nm",
|
|
20
|
+
"estimate_diffusion",
|
|
21
|
+
"hindrance_factor",
|
|
22
|
+
"local_channel_diameter_nm",
|
|
23
|
+
"run",
|
|
24
|
+
]
|