bactoscoop 0.1.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Bart Steemans
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,179 @@
1
+ Metadata-Version: 2.4
2
+ Name: bactoscoop
3
+ Version: 0.1.0
4
+ Summary: Single-cell feature extraction from multichannel bacterial microscopy images
5
+ Author: Bart Steemans
6
+ License-Expression: MIT
7
+ Project-URL: Documentation, https://bart-steemans.github.io/bactoscoop/
8
+ Project-URL: Changelog, https://github.com/Bart-Steemans/bactoscoop/releases
9
+ Project-URL: Homepage, https://github.com/Bart-Steemans/bactoscoop
10
+ Project-URL: Repository, https://github.com/Bart-Steemans/bactoscoop
11
+ Project-URL: Issues, https://github.com/Bart-Steemans/bactoscoop/issues
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
18
+ Requires-Python: <3.11,>=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: numpy<2,>=1.24
22
+ Requires-Dist: scipy<1.12,>=1.11.4
23
+ Requires-Dist: setuptools<81,>=77.0.3
24
+ Requires-Dist: pandas<3,>=2.1.3
25
+ Requires-Dist: tifffile>=2024.2.12
26
+ Requires-Dist: natsort>=8.4
27
+ Requires-Dist: shapely>=2.0.1
28
+ Requires-Dist: scikit-image>=0.22
29
+ Requires-Dist: opencv-python-headless<4.12,>=4.9
30
+ Requires-Dist: networkx>=3.2
31
+ Requires-Dist: matplotlib>=3.8
32
+ Requires-Dist: tqdm>=4.66
33
+ Requires-Dist: omnipose==1.0.6
34
+ Requires-Dist: scikit-learn>=1.3
35
+ Requires-Dist: pyarrow>=14
36
+ Requires-Dist: jupyterlab>=4
37
+ Requires-Dist: ipykernel>=6
38
+ Provides-Extra: dev
39
+ Requires-Dist: pytest>=8; extra == "dev"
40
+ Requires-Dist: build>=1; extra == "dev"
41
+ Dynamic: license-file
42
+
43
+ # BactoScoop
44
+
45
+ <p align="center"><img src="https://raw.githubusercontent.com/Bart-Steemans/bactoscoop/v0.1.0/BactoScoop%20Logo.png" alt="BactoScoop logo" width="310"></p>
46
+
47
+ **BactoScoop enables reproducible high-throughput image-based profiling of individual bacterial cells.** It takes multichannel microscopy images from individual fields through segmentation, cell mesh construction, quality curation, object detection, and feature extraction. The result is a per-cell table that connects morphology with membrane, nucleoid, and other fluorescence measurements. Each stage can be inspected, and saved masks, meshes, and feature tables make an analysis easier to review and repeat.
48
+ [**Read my documentation**](https://bart-steemans.github.io/bactoscoop/) · [Three-channel walkthrough](https://bart-steemans.github.io/bactoscoop/examples/three-channel.html) · [Five-channel walkthrough](https://bart-steemans.github.io/bactoscoop/examples/five-channel.html)
49
+
50
+ ## Install BactoScoop
51
+
52
+ I use **Python 3.10** for the analysis package. Choose either Conda or uv; both install the same package and its dependencies. The segmentation stack includes Omnipose 1.0.6 and NumPy below 2. The documentation build uses a separate Python 3.11 environment.
53
+
54
+ The PyPI commands below apply after the [release publishing workflow](https://github.com/Bart-Steemans/bactoscoop/actions/workflows/release.yml) succeeds. The tagged GitHub installation below provides the same release directly, including before PyPI publication.
55
+
56
+ ### Conda
57
+
58
+ Install [Miniconda](https://docs.conda.io/projects/miniconda/en/latest/) if needed, then run in Anaconda Prompt or Anaconda PowerShell Prompt:
59
+
60
+ ```powershell
61
+ conda create -n bactoscoop python=3.10 pip -y
62
+ conda activate bactoscoop
63
+ python -m pip install bactoscoop==0.1.0
64
+ python -m pip check
65
+ python -c "import bactoscoop; from importlib.metadata import version; print(version('bactoscoop'))"
66
+ jupyter lab
67
+ ```
68
+
69
+ ### uv
70
+
71
+ Install [uv](https://docs.astral.sh/uv/getting-started/installation/), open PowerShell in a folder for your analysis, then run:
72
+
73
+ ```powershell
74
+ uv venv --python 3.10 .venv
75
+ uv pip install --python .venv bactoscoop==0.1.0
76
+ uv pip check --python .venv
77
+ .\.venv\Scripts\python.exe -c "import bactoscoop; from importlib.metadata import version; print(version('bactoscoop'))"
78
+ .\.venv\Scripts\jupyter.exe lab
79
+ ```
80
+
81
+ uv can download Python 3.10 if needed. On macOS/Linux, use `.venv/bin/python` and `.venv/bin/jupyter` for the last two commands.
82
+
83
+ ### Stable release, GitHub release, or development checkout
84
+
85
+ The stable PyPI installation above pins the version for reproducibility. To upgrade to the newest stable PyPI release, use `python -m pip install --upgrade bactoscoop` (Conda) or `uv pip install --python .venv --upgrade bactoscoop` (uv).
86
+
87
+ The corresponding [GitHub release](https://github.com/Bart-Steemans/bactoscoop/releases/latest) can also be installed directly when Git is installed:
88
+
89
+ ```powershell
90
+ python -m pip install "bactoscoop @ git+https://github.com/Bart-Steemans/bactoscoop.git@v0.1.0"
91
+ ```
92
+
93
+ For uv, use `uv pip install --python .venv "bactoscoop @ git+https://github.com/Bart-Steemans/bactoscoop.git@v0.1.0"`. Select the tag shown in Releases when a newer release is available. To work on the development code instead:
94
+
95
+ ```powershell
96
+ git clone https://github.com/Bart-Steemans/bactoscoop.git
97
+ cd bactoscoop
98
+ python -m pip install -e .
99
+ ```
100
+
101
+ An editable development install follows changes in your checkout. It may differ from the stable release. All installation commands must use your Python 3.10 analysis environment. Select that environment's kernel in JupyterLab.
102
+
103
+ ## Run a walkthrough
104
+
105
+ The wheel contains the Python package; the large TIFFs, masks, SVM models, and notebooks are supplied separately. Download and extract the [v0.1.0 example archive](https://github.com/Bart-Steemans/bactoscoop/archive/refs/tags/v0.1.0.zip), or use the `examples/` folder in a cloned checkout.
106
+
107
+ Open `examples/3_channel_example_walkthrough.ipynb` or `examples/5_channel_example_walkthrough.ipynb` in JupyterLab. Run cells from top to bottom. The first cell locates the downloaded examples and copies the selected dataset into a fresh folder under `~/bactoscoop_runs/`; the supplied images, masks, and saved reference outputs stay intact. If you open the notebook elsewhere, set the `BACTOSCOOP_EXAMPLES_DIR` environment variable to the downloaded `examples` folder before starting JupyterLab.
108
+
109
+ The examples reuse the supplied masks by default. Set `RUN_SEGMENTATION = True` for fresh Omnipose inference; the first inference may download model weights. Set `PIXEL_SIZE_UM` to your microscope calibration. The first cell prints the working output folder. Meshes, curated meshes, and feature tables are saved there. The example-specific SVM models are copied with their datasets; inspect their predictions before using those models on different images.
110
+
111
+ ## Segmentation on CPU or GPU
112
+
113
+ Segmentation **automatically runs on the CPU** when a usable CUDA GPU is unavailable. No additional configuration is required for the standard installation.
114
+
115
+ If CUDA-enabled PyTorch and a compatible NVIDIA GPU are available, Omnipose can use GPU acceleration. The walkthroughs include a check to verify whether PyTorch detects CUDA.
116
+
117
+ ### Optional GPU acceleration
118
+
119
+ To enable GPU acceleration, first install BactoScoop following the standard installation instructions. Then:
120
+
121
+ 1. **Check GPU compatibility:** Consult the [Omnipose documentation](https://omnipose.readthedocs.io/installation.html) for GPU support, requirements, and Python compatibility.
122
+
123
+ 2. **Install CUDA-enabled PyTorch:** Use the [official PyTorch installer](https://pytorch.org/get-started/locally/) to select an appropriate CUDA-enabled build for your GPU and NVIDIA driver. Install the corresponding PyTorch and torchvision versions in your BactoScoop environment.
124
+
125
+ For reference, we have successfully tested segmentation on Windows with Python 3.10, an NVIDIA RTX A6000, PyTorch 2.7.1+cu118, and torchvision 0.22.1+cu118, installed using:
126
+
127
+ ```powershell
128
+ python -m pip install --upgrade torch==2.7.1 torchvision==0.22.1 --index-url https://download.pytorch.org/whl/cu118
129
+ ```
130
+
131
+ This is an example of a working configuration, not a requirement. Other supported versions can be found in the [PyTorch previous versions documentation](https://pytorch.org/get-started/previous-versions/).
132
+
133
+ 3. **Verify CUDA availability:** Run the following command in the same environment:
134
+
135
+ ```powershell
136
+ python -c "import torch; print('CUDA available:', torch.cuda.is_available())"
137
+ ```
138
+
139
+ If the output is `CUDA available: True`, PyTorch can access CUDA. If it returns `False`, segmentation will still run on the CPU.
140
+
141
+ **Important:** Restart your Jupyter kernel after installing or updating PyTorch.
142
+
143
+ ## Expected input images (and masks)
144
+
145
+ Place one 2D TIFF per channel and field in the same folder. The shared name before `_C1`, `_C2`, and so on identifies a field. `C1` is the phase image in the examples.
146
+
147
+ ```text
148
+ your_images/
149
+ sample_XY1_C1.tiff
150
+ sample_XY1_C2.tiff
151
+ sample_XY1_C3.tiff
152
+ sample_XY2_C1.tiff
153
+ sample_XY2_C2.tiff
154
+ sample_XY2_C3.tiff
155
+ masks/
156
+ sample_XY1_C1_cp_masks.tif
157
+ sample_XY2_C1_cp_masks.tif
158
+ ```
159
+
160
+ Channels and masks for one field must have the same height and width. BactoScoop can segment the phase image with Omnipose or use masks made by another program. Masks must be 2D integer images with background **0** and distinct cells labeled consecutively **1 through N**. Check mask outlines before building meshes. Set the correct pixel size in µm/pixel and verify channel registration when measuring signals across channels.
161
+
162
+ ## Walkthroughs and the analysis stages
163
+
164
+ | Walkthrough | Channels | Main example |
165
+ | --- | --- | --- |
166
+ | [Three-channel](https://github.com/Bart-Steemans/bactoscoop/blob/v0.1.0/examples/3_channel_example_walkthrough.ipynb) | `C1` phase; `C2` DAPI, showing DNA/nucleoid morphology; `C3` GFP-DnaN, showing replication-associated puncta. | Detect intracellular objects such as the nucleoid and DnaN foci and extract morphology and object related features. The supplied SVM is `DnaN_Timecourse.pkl`. |
167
+ | [Five-channel](https://github.com/Bart-Steemans/bactoscoop/blob/v0.1.0/examples/5_channel_example_walkthrough.ipynb) | `C1` phase; `C2` outer membrane; `C3` inner membrane; `C4` RNA; `C5` DAPI/nucleoid. | This tutorial performs BactoScoop on a 5 channel set and includes additional extraction of membrane features. The supplied SVM is `keio_collection_stationary.pkl`. |
168
+
169
+ An example script of how we used BactoScoop to screen thousands of bacterial samples is also available in the example folder (named "BactoScoop Parallel Processing.py").
170
+
171
+ ## Update this documentation
172
+
173
+ I edit the original notebooks in `examples/`. Their markdown, code, and saved PNG outputs feed the documentation directly. Re-execute and save a notebook when I want updated figures, then run:
174
+
175
+ ```powershell
176
+ .\update_docs.cmd
177
+ ```
178
+
179
+ This creates a separate documentation environment if needed, rebuilds the website, and refreshes `docs/` for GitHub Pages. Use `.\update_docs.cmd --serve` to rebuild and open the local website. Building documentation does not run the scientific notebooks. See [documentation/README.md](https://github.com/Bart-Steemans/bactoscoop/blob/v0.1.0/documentation/README.md) for details and other platforms.
@@ -0,0 +1,137 @@
1
+ # BactoScoop
2
+
3
+ <p align="center"><img src="https://raw.githubusercontent.com/Bart-Steemans/bactoscoop/v0.1.0/BactoScoop%20Logo.png" alt="BactoScoop logo" width="310"></p>
4
+
5
+ **BactoScoop enables reproducible high-throughput image-based profiling of individual bacterial cells.** It takes multichannel microscopy images from individual fields through segmentation, cell mesh construction, quality curation, object detection, and feature extraction. The result is a per-cell table that connects morphology with membrane, nucleoid, and other fluorescence measurements. Each stage can be inspected, and saved masks, meshes, and feature tables make an analysis easier to review and repeat.
6
+ [**Read my documentation**](https://bart-steemans.github.io/bactoscoop/) · [Three-channel walkthrough](https://bart-steemans.github.io/bactoscoop/examples/three-channel.html) · [Five-channel walkthrough](https://bart-steemans.github.io/bactoscoop/examples/five-channel.html)
7
+
8
+ ## Install BactoScoop
9
+
10
+ I use **Python 3.10** for the analysis package. Choose either Conda or uv; both install the same package and its dependencies. The segmentation stack includes Omnipose 1.0.6 and NumPy below 2. The documentation build uses a separate Python 3.11 environment.
11
+
12
+ The PyPI commands below apply after the [release publishing workflow](https://github.com/Bart-Steemans/bactoscoop/actions/workflows/release.yml) succeeds. The tagged GitHub installation below provides the same release directly, including before PyPI publication.
13
+
14
+ ### Conda
15
+
16
+ Install [Miniconda](https://docs.conda.io/projects/miniconda/en/latest/) if needed, then run in Anaconda Prompt or Anaconda PowerShell Prompt:
17
+
18
+ ```powershell
19
+ conda create -n bactoscoop python=3.10 pip -y
20
+ conda activate bactoscoop
21
+ python -m pip install bactoscoop==0.1.0
22
+ python -m pip check
23
+ python -c "import bactoscoop; from importlib.metadata import version; print(version('bactoscoop'))"
24
+ jupyter lab
25
+ ```
26
+
27
+ ### uv
28
+
29
+ Install [uv](https://docs.astral.sh/uv/getting-started/installation/), open PowerShell in a folder for your analysis, then run:
30
+
31
+ ```powershell
32
+ uv venv --python 3.10 .venv
33
+ uv pip install --python .venv bactoscoop==0.1.0
34
+ uv pip check --python .venv
35
+ .\.venv\Scripts\python.exe -c "import bactoscoop; from importlib.metadata import version; print(version('bactoscoop'))"
36
+ .\.venv\Scripts\jupyter.exe lab
37
+ ```
38
+
39
+ uv can download Python 3.10 if needed. On macOS/Linux, use `.venv/bin/python` and `.venv/bin/jupyter` for the last two commands.
40
+
41
+ ### Stable release, GitHub release, or development checkout
42
+
43
+ The stable PyPI installation above pins the version for reproducibility. To upgrade to the newest stable PyPI release, use `python -m pip install --upgrade bactoscoop` (Conda) or `uv pip install --python .venv --upgrade bactoscoop` (uv).
44
+
45
+ The corresponding [GitHub release](https://github.com/Bart-Steemans/bactoscoop/releases/latest) can also be installed directly when Git is installed:
46
+
47
+ ```powershell
48
+ python -m pip install "bactoscoop @ git+https://github.com/Bart-Steemans/bactoscoop.git@v0.1.0"
49
+ ```
50
+
51
+ For uv, use `uv pip install --python .venv "bactoscoop @ git+https://github.com/Bart-Steemans/bactoscoop.git@v0.1.0"`. Select the tag shown in Releases when a newer release is available. To work on the development code instead:
52
+
53
+ ```powershell
54
+ git clone https://github.com/Bart-Steemans/bactoscoop.git
55
+ cd bactoscoop
56
+ python -m pip install -e .
57
+ ```
58
+
59
+ An editable development install follows changes in your checkout. It may differ from the stable release. All installation commands must use your Python 3.10 analysis environment. Select that environment's kernel in JupyterLab.
60
+
61
+ ## Run a walkthrough
62
+
63
+ The wheel contains the Python package; the large TIFFs, masks, SVM models, and notebooks are supplied separately. Download and extract the [v0.1.0 example archive](https://github.com/Bart-Steemans/bactoscoop/archive/refs/tags/v0.1.0.zip), or use the `examples/` folder in a cloned checkout.
64
+
65
+ Open `examples/3_channel_example_walkthrough.ipynb` or `examples/5_channel_example_walkthrough.ipynb` in JupyterLab. Run cells from top to bottom. The first cell locates the downloaded examples and copies the selected dataset into a fresh folder under `~/bactoscoop_runs/`; the supplied images, masks, and saved reference outputs stay intact. If you open the notebook elsewhere, set the `BACTOSCOOP_EXAMPLES_DIR` environment variable to the downloaded `examples` folder before starting JupyterLab.
66
+
67
+ The examples reuse the supplied masks by default. Set `RUN_SEGMENTATION = True` for fresh Omnipose inference; the first inference may download model weights. Set `PIXEL_SIZE_UM` to your microscope calibration. The first cell prints the working output folder. Meshes, curated meshes, and feature tables are saved there. The example-specific SVM models are copied with their datasets; inspect their predictions before using those models on different images.
68
+
69
+ ## Segmentation on CPU or GPU
70
+
71
+ Segmentation **automatically runs on the CPU** when a usable CUDA GPU is unavailable. No additional configuration is required for the standard installation.
72
+
73
+ If CUDA-enabled PyTorch and a compatible NVIDIA GPU are available, Omnipose can use GPU acceleration. The walkthroughs include a check to verify whether PyTorch detects CUDA.
74
+
75
+ ### Optional GPU acceleration
76
+
77
+ To enable GPU acceleration, first install BactoScoop following the standard installation instructions. Then:
78
+
79
+ 1. **Check GPU compatibility:** Consult the [Omnipose documentation](https://omnipose.readthedocs.io/installation.html) for GPU support, requirements, and Python compatibility.
80
+
81
+ 2. **Install CUDA-enabled PyTorch:** Use the [official PyTorch installer](https://pytorch.org/get-started/locally/) to select an appropriate CUDA-enabled build for your GPU and NVIDIA driver. Install the corresponding PyTorch and torchvision versions in your BactoScoop environment.
82
+
83
+ For reference, we have successfully tested segmentation on Windows with Python 3.10, an NVIDIA RTX A6000, PyTorch 2.7.1+cu118, and torchvision 0.22.1+cu118, installed using:
84
+
85
+ ```powershell
86
+ python -m pip install --upgrade torch==2.7.1 torchvision==0.22.1 --index-url https://download.pytorch.org/whl/cu118
87
+ ```
88
+
89
+ This is an example of a working configuration, not a requirement. Other supported versions can be found in the [PyTorch previous versions documentation](https://pytorch.org/get-started/previous-versions/).
90
+
91
+ 3. **Verify CUDA availability:** Run the following command in the same environment:
92
+
93
+ ```powershell
94
+ python -c "import torch; print('CUDA available:', torch.cuda.is_available())"
95
+ ```
96
+
97
+ If the output is `CUDA available: True`, PyTorch can access CUDA. If it returns `False`, segmentation will still run on the CPU.
98
+
99
+ **Important:** Restart your Jupyter kernel after installing or updating PyTorch.
100
+
101
+ ## Expected input images (and masks)
102
+
103
+ Place one 2D TIFF per channel and field in the same folder. The shared name before `_C1`, `_C2`, and so on identifies a field. `C1` is the phase image in the examples.
104
+
105
+ ```text
106
+ your_images/
107
+ sample_XY1_C1.tiff
108
+ sample_XY1_C2.tiff
109
+ sample_XY1_C3.tiff
110
+ sample_XY2_C1.tiff
111
+ sample_XY2_C2.tiff
112
+ sample_XY2_C3.tiff
113
+ masks/
114
+ sample_XY1_C1_cp_masks.tif
115
+ sample_XY2_C1_cp_masks.tif
116
+ ```
117
+
118
+ Channels and masks for one field must have the same height and width. BactoScoop can segment the phase image with Omnipose or use masks made by another program. Masks must be 2D integer images with background **0** and distinct cells labeled consecutively **1 through N**. Check mask outlines before building meshes. Set the correct pixel size in µm/pixel and verify channel registration when measuring signals across channels.
119
+
120
+ ## Walkthroughs and the analysis stages
121
+
122
+ | Walkthrough | Channels | Main example |
123
+ | --- | --- | --- |
124
+ | [Three-channel](https://github.com/Bart-Steemans/bactoscoop/blob/v0.1.0/examples/3_channel_example_walkthrough.ipynb) | `C1` phase; `C2` DAPI, showing DNA/nucleoid morphology; `C3` GFP-DnaN, showing replication-associated puncta. | Detect intracellular objects such as the nucleoid and DnaN foci and extract morphology and object related features. The supplied SVM is `DnaN_Timecourse.pkl`. |
125
+ | [Five-channel](https://github.com/Bart-Steemans/bactoscoop/blob/v0.1.0/examples/5_channel_example_walkthrough.ipynb) | `C1` phase; `C2` outer membrane; `C3` inner membrane; `C4` RNA; `C5` DAPI/nucleoid. | This tutorial performs BactoScoop on a 5 channel set and includes additional extraction of membrane features. The supplied SVM is `keio_collection_stationary.pkl`. |
126
+
127
+ An example script of how we used BactoScoop to screen thousands of bacterial samples is also available in the example folder (named "BactoScoop Parallel Processing.py").
128
+
129
+ ## Update this documentation
130
+
131
+ I edit the original notebooks in `examples/`. Their markdown, code, and saved PNG outputs feed the documentation directly. Re-execute and save a notebook when I want updated figures, then run:
132
+
133
+ ```powershell
134
+ .\update_docs.cmd
135
+ ```
136
+
137
+ This creates a separate documentation environment if needed, rebuilds the website, and refreshes `docs/` for GitHub Pages. Use `.\update_docs.cmd --serve` to rebuild and open the local website. Building documentation does not run the scientific notebooks. See [documentation/README.md](https://github.com/Bart-Steemans/bactoscoop/blob/v0.1.0/documentation/README.md) for details and other platforms.
@@ -0,0 +1,137 @@
1
+ # BactoScoop
2
+
3
+ <p align="center"><img src="BactoScoop Logo.png" alt="BactoScoop logo" width="310"></p>
4
+
5
+ **BactoScoop enables reproducible high-throughput image-based profiling of individual bacterial cells.** It takes multichannel microscopy images from individual fields through segmentation, cell mesh construction, quality curation, object detection, and feature extraction. The result is a per-cell table that connects morphology with membrane, nucleoid, and other fluorescence measurements. Each stage can be inspected, and saved masks, meshes, and feature tables make an analysis easier to review and repeat.
6
+ [**Read my documentation**](https://bart-steemans.github.io/bactoscoop/) · [Three-channel walkthrough](https://bart-steemans.github.io/bactoscoop/examples/three-channel.html) · [Five-channel walkthrough](https://bart-steemans.github.io/bactoscoop/examples/five-channel.html)
7
+
8
+ ## Install BactoScoop
9
+
10
+ I use **Python 3.10** for the analysis package. Choose either Conda or uv; both install the same package and its dependencies. The segmentation stack includes Omnipose 1.0.6 and NumPy below 2. The documentation build uses a separate Python 3.11 environment.
11
+
12
+ The PyPI commands below apply after the [release publishing workflow](https://github.com/Bart-Steemans/bactoscoop/actions/workflows/release.yml) succeeds. The tagged GitHub installation below provides the same release directly, including before PyPI publication.
13
+
14
+ ### Conda
15
+
16
+ Install [Miniconda](https://docs.conda.io/projects/miniconda/en/latest/) if needed, then run in Anaconda Prompt or Anaconda PowerShell Prompt:
17
+
18
+ ```powershell
19
+ conda create -n bactoscoop python=3.10 pip -y
20
+ conda activate bactoscoop
21
+ python -m pip install bactoscoop==0.1.0
22
+ python -m pip check
23
+ python -c "import bactoscoop; from importlib.metadata import version; print(version('bactoscoop'))"
24
+ jupyter lab
25
+ ```
26
+
27
+ ### uv
28
+
29
+ Install [uv](https://docs.astral.sh/uv/getting-started/installation/), open PowerShell in a folder for your analysis, then run:
30
+
31
+ ```powershell
32
+ uv venv --python 3.10 .venv
33
+ uv pip install --python .venv bactoscoop==0.1.0
34
+ uv pip check --python .venv
35
+ .\.venv\Scripts\python.exe -c "import bactoscoop; from importlib.metadata import version; print(version('bactoscoop'))"
36
+ .\.venv\Scripts\jupyter.exe lab
37
+ ```
38
+
39
+ uv can download Python 3.10 if needed. On macOS/Linux, use `.venv/bin/python` and `.venv/bin/jupyter` for the last two commands.
40
+
41
+ ### Stable release, GitHub release, or development checkout
42
+
43
+ The stable PyPI installation above pins the version for reproducibility. To upgrade to the newest stable PyPI release, use `python -m pip install --upgrade bactoscoop` (Conda) or `uv pip install --python .venv --upgrade bactoscoop` (uv).
44
+
45
+ The corresponding [GitHub release](https://github.com/Bart-Steemans/bactoscoop/releases/latest) can also be installed directly when Git is installed:
46
+
47
+ ```powershell
48
+ python -m pip install "bactoscoop @ git+https://github.com/Bart-Steemans/bactoscoop.git@v0.1.0"
49
+ ```
50
+
51
+ For uv, use `uv pip install --python .venv "bactoscoop @ git+https://github.com/Bart-Steemans/bactoscoop.git@v0.1.0"`. Select the tag shown in Releases when a newer release is available. To work on the development code instead:
52
+
53
+ ```powershell
54
+ git clone https://github.com/Bart-Steemans/bactoscoop.git
55
+ cd bactoscoop
56
+ python -m pip install -e .
57
+ ```
58
+
59
+ An editable development install follows changes in your checkout. It may differ from the stable release. All installation commands must use your Python 3.10 analysis environment. Select that environment's kernel in JupyterLab.
60
+
61
+ ## Run a walkthrough
62
+
63
+ The wheel contains the Python package; the large TIFFs, masks, SVM models, and notebooks are supplied separately. Download and extract the [v0.1.0 example archive](https://github.com/Bart-Steemans/bactoscoop/archive/refs/tags/v0.1.0.zip), or use the `examples/` folder in a cloned checkout.
64
+
65
+ Open `examples/3_channel_example_walkthrough.ipynb` or `examples/5_channel_example_walkthrough.ipynb` in JupyterLab. Run cells from top to bottom. The first cell locates the downloaded examples and copies the selected dataset into a fresh folder under `~/bactoscoop_runs/`; the supplied images, masks, and saved reference outputs stay intact. If you open the notebook elsewhere, set the `BACTOSCOOP_EXAMPLES_DIR` environment variable to the downloaded `examples` folder before starting JupyterLab.
66
+
67
+ The examples reuse the supplied masks by default. Set `RUN_SEGMENTATION = True` for fresh Omnipose inference; the first inference may download model weights. Set `PIXEL_SIZE_UM` to your microscope calibration. The first cell prints the working output folder. Meshes, curated meshes, and feature tables are saved there. The example-specific SVM models are copied with their datasets; inspect their predictions before using those models on different images.
68
+
69
+ ## Segmentation on CPU or GPU
70
+
71
+ Segmentation **automatically runs on the CPU** when a usable CUDA GPU is unavailable. No additional configuration is required for the standard installation.
72
+
73
+ If CUDA-enabled PyTorch and a compatible NVIDIA GPU are available, Omnipose can use GPU acceleration. The walkthroughs include a check to verify whether PyTorch detects CUDA.
74
+
75
+ ### Optional GPU acceleration
76
+
77
+ To enable GPU acceleration, first install BactoScoop following the standard installation instructions. Then:
78
+
79
+ 1. **Check GPU compatibility:** Consult the [Omnipose documentation](https://omnipose.readthedocs.io/installation.html) for GPU support, requirements, and Python compatibility.
80
+
81
+ 2. **Install CUDA-enabled PyTorch:** Use the [official PyTorch installer](https://pytorch.org/get-started/locally/) to select an appropriate CUDA-enabled build for your GPU and NVIDIA driver. Install the corresponding PyTorch and torchvision versions in your BactoScoop environment.
82
+
83
+ For reference, we have successfully tested segmentation on Windows with Python 3.10, an NVIDIA RTX A6000, PyTorch 2.7.1+cu118, and torchvision 0.22.1+cu118, installed using:
84
+
85
+ ```powershell
86
+ python -m pip install --upgrade torch==2.7.1 torchvision==0.22.1 --index-url https://download.pytorch.org/whl/cu118
87
+ ```
88
+
89
+ This is an example of a working configuration, not a requirement. Other supported versions can be found in the [PyTorch previous versions documentation](https://pytorch.org/get-started/previous-versions/).
90
+
91
+ 3. **Verify CUDA availability:** Run the following command in the same environment:
92
+
93
+ ```powershell
94
+ python -c "import torch; print('CUDA available:', torch.cuda.is_available())"
95
+ ```
96
+
97
+ If the output is `CUDA available: True`, PyTorch can access CUDA. If it returns `False`, segmentation will still run on the CPU.
98
+
99
+ **Important:** Restart your Jupyter kernel after installing or updating PyTorch.
100
+
101
+ ## Expected input images (and masks)
102
+
103
+ Place one 2D TIFF per channel and field in the same folder. The shared name before `_C1`, `_C2`, and so on identifies a field. `C1` is the phase image in the examples.
104
+
105
+ ```text
106
+ your_images/
107
+ sample_XY1_C1.tiff
108
+ sample_XY1_C2.tiff
109
+ sample_XY1_C3.tiff
110
+ sample_XY2_C1.tiff
111
+ sample_XY2_C2.tiff
112
+ sample_XY2_C3.tiff
113
+ masks/
114
+ sample_XY1_C1_cp_masks.tif
115
+ sample_XY2_C1_cp_masks.tif
116
+ ```
117
+
118
+ Channels and masks for one field must have the same height and width. BactoScoop can segment the phase image with Omnipose or use masks made by another program. Masks must be 2D integer images with background **0** and distinct cells labeled consecutively **1 through N**. Check mask outlines before building meshes. Set the correct pixel size in µm/pixel and verify channel registration when measuring signals across channels.
119
+
120
+ ## Walkthroughs and the analysis stages
121
+
122
+ | Walkthrough | Channels | Main example |
123
+ | --- | --- | --- |
124
+ | [Three-channel](examples/3_channel_example_walkthrough.ipynb) | `C1` phase; `C2` DAPI, showing DNA/nucleoid morphology; `C3` GFP-DnaN, showing replication-associated puncta. | Detect intracellular objects such as the nucleoid and DnaN foci and extract morphology and object related features. The supplied SVM is `DnaN_Timecourse.pkl`. |
125
+ | [Five-channel](examples/5_channel_example_walkthrough.ipynb) | `C1` phase; `C2` outer membrane; `C3` inner membrane; `C4` RNA; `C5` DAPI/nucleoid. | This tutorial performs BactoScoop on a 5 channel set and includes additional extraction of membrane features. The supplied SVM is `keio_collection_stationary.pkl`. |
126
+
127
+ An example script of how we used BactoScoop to screen thousands of bacterial samples is also available in the example folder (named "BactoScoop Parallel Processing.py").
128
+
129
+ ## Update this documentation
130
+
131
+ I edit the original notebooks in `examples/`. Their markdown, code, and saved PNG outputs feed the documentation directly. Re-execute and save a notebook when I want updated figures, then run:
132
+
133
+ ```powershell
134
+ .\update_docs.cmd
135
+ ```
136
+
137
+ This creates a separate documentation environment if needed, rebuilds the website, and refreshes `docs/` for GitHub Pages. Use `.\update_docs.cmd --serve` to rebuild and open the local website. Building documentation does not run the scientific notebooks. See [documentation/README.md](documentation/README.md) for details and other platforms.
@@ -0,0 +1,19 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Wed Apr 5 10:49:33 2023
4
+
5
+ @author: Bart Steeman. Govers Lab.
6
+ """
7
+ #from . import plot
8
+ from .imagecollection import ImageCollection
9
+ from .logging_utils import configure_bactoscoop_logging
10
+
11
+ __all__ = ["ImageCollection", "Curation", "configure_bactoscoop_logging"]
12
+
13
+
14
+ def __getattr__(name):
15
+ if name == "Curation":
16
+ from .curation import Curation
17
+
18
+ return Curation
19
+ raise AttributeError(f"module '{__name__}' has no attribute '{name}'")