Skip to content

Commit 30c8877

Browse files
authored
Merge pull request #88 from imcf/devel
Final changes for the `imcflibs-1.5.0` release
2 parents f7a619e + f620d97 commit 30c8877

15 files changed

+123
-56
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 🚚🌍 Publish to 🔬☕ SciJava and 🎪 PyPI
1+
name: "Packages: SciJava 🔬☕ + PyPI 🎪"
22

33
on:
44

.github/workflows/dispatch-deploy-pages.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 🚀 Dispatch foreign workflows
1+
name: Dispatch foreign workflows 🚀🌖
22

33
on:
44
workflow_dispatch:

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 🔎 Code Linting ⚡
1+
name: Code Linting 🔎
22

33
on:
44
push:

.github/workflows/pytest-poetry.yml

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
## action file inspired by https://jacobian.org/til/github-actions-poetry/
22

3-
name: 🧪 pytest (via 🎭 Poetry)
3+
name: Pytest-Poetry 🧪🎭
44

55
on:
6+
workflow_dispatch:
67
push:
78
branches:
8-
- master
9+
- master
910
tags:
10-
- run-pytest*
11-
- py3-pytest*
1211
- "*-[0-9]+.*"
1312
pull_request:
1413
branches:
15-
- master
16-
- devel
14+
- master
15+
- devel
1716

1817
jobs:
1918
pytest-poetry:

.github/workflows/pytest-python2.yml

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
name: 🧪 pytest (using 🐍 Python2)
1+
name: Pytest-Python2 🧪🐍
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches:
6-
- master
7+
- master
78
tags:
8-
- run-pytest*
9-
- py2-pytest*
109
- "*-[0-9]+.*"
1110
pull_request:
1211
branches:
13-
- master
14-
- devel
12+
- master
13+
- devel
1514

1615
env:
1716
PY_VERSION: 2.7.18

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# VS Code files
22
*.code-workspace
3-
.vscode/
43

54
# maven / release generated files
65
target/
@@ -9,7 +8,6 @@ pom.xml.releaseBackup
98
# bytecode created when importing directly in Jython:
109
*py.class
1110

12-
1311
*.py[cod]
1412

1513
# C extensions

.vscode/settings.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"markdownlint.config": {
3+
"emphasis-style": {
4+
"style": "asterisk"
5+
},
6+
"line-length": {
7+
"line_length": 80,
8+
"stern": true,
9+
"code_blocks": false,
10+
"tables": false
11+
}
12+
},
13+
}

.vscode/tasks.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "verify",
6+
"type": "shell",
7+
"command": "mvn -B verify",
8+
"group": "build"
9+
},
10+
{
11+
"label": "test",
12+
"type": "shell",
13+
"command": "mvn -B test",
14+
"group": "test"
15+
},
16+
{
17+
"label": "deploy",
18+
"type": "shell",
19+
"command": "mvn -Dscijava.app.directory=/opt/Fiji.app",
20+
"group": {
21+
"kind": "build",
22+
"isDefault": true
23+
},
24+
"problemMatcher": []
25+
}
26+
]
27+
}

CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<!-- markdownlint-disable MD024 (no-duplicate-header) -->
2-
<!-- markdownlint-configure-file { "emphasis-style": { "style": "asterisk" } } -->
32

43
# Changelog 🧾
54

DEVELOPMENT.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ git push origin $RELEASE_TAG
3131
```
3232

3333
**IMPORTANT 2**: in case a **pre-releaes** was created, the last commit needs to
34-
be discarded as the _release-script_ places a wrong version / snapshot
34+
be discarded as the *release-script* places a wrong version / snapshot
3535
combination in the `pom.xml`:
3636

3737
```bash
@@ -43,7 +43,7 @@ git reset --hard HEAD~1
4343
Building and deploying the package can be greatly simplified using "tasks" in
4444
[Visual Studio Code][www_vscode]. By adding the following settings to the
4545
`.vscode/tasks.json` file, you can simply press `Ctrl+Shift+B` in VS Code and
46-
select the _deploy_ task for running Maven and have the resulting JAR file being
46+
select the *deploy* task for running Maven and have the resulting JAR file being
4747
placed in `/opt/fiji-packaging/Fiji.app/jars/` (adjust to your path as
4848
necessary):
4949

@@ -80,7 +80,7 @@ necessary):
8080
## Linting Python 2.7 with VS Code
8181

8282
For being able to lint the old Python code properly, you'll need to set up an
83-
appropriate _virtualenv_ with `pylint` being installed.
83+
appropriate *virtualenv* with `pylint` being installed.
8484

8585
Using [`fish`][www_fish] and [virtualfish][www_vf], this can be done as follows:
8686

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11

22
# IMCFlibs 🐍 ☕ 🔩 🔧 🪛
33

4-
[![Build Status](https://github.com/imcf/python-imcflibs/actions/workflows/build.yml/badge.svg)][build]
54
[![Linting ⚡](https://github.com/imcf/python-imcflibs/actions/workflows/lint.yml/badge.svg)](https://github.com/imcf/python-imcflibs/actions/workflows/lint.yml)
5+
[![Pytest-Python2 🧪🐍](https://github.com/imcf/python-imcflibs/actions/workflows/pytest-python2.yml/badge.svg)](https://github.com/imcf/python-imcflibs/actions/workflows/pytest-python2.yml)
6+
[![Pytest-Poetry 🧪🎭](https://github.com/imcf/python-imcflibs/actions/workflows/pytest-poetry.yml/badge.svg)](https://github.com/imcf/python-imcflibs/actions/workflows/pytest-poetry.yml)
7+
[![codecov](https://codecov.io/github/imcf/python-imcflibs/branch/devel/graph/badge.svg?token=JTDK74OT79)](https://codecov.io/github/imcf/python-imcflibs)
8+
9+
[![Build Status](https://github.com/imcf/python-imcflibs/actions/workflows/build.yml/badge.svg)][build]
610
[![DOI](https://zenodo.org/badge/156891364.svg)][doi]
711

812
This package contains a diverse collection of Python functions dealing with

TESTING.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ be tested via [`pytest`][pytest] up to a certain level, some (most?) of them
77
should even work in a Python 3 environment.
88

99
To perform those tests, the packges otherwise provided by ImageJ need to be
10-
mocked using the `imcf-fiji-mocks` package. For seting up a _venv_ use the steps
10+
mocked using the `imcf-fiji-mocks` package. For seting up a *venv* use the steps
1111
described here:
1212

1313
```bash
@@ -37,7 +37,7 @@ pip install --upgrade \
3737
pip install -e .
3838
```
3939

40-
Using this _venv_, tests can be triggered just the usual way. To run only
40+
Using this *venv*, tests can be triggered just the usual way. To run only
4141
specific tests, use e.g.
4242

4343
```bash
@@ -48,12 +48,12 @@ pytest tests/bdv/test_processingoptions.py
4848

4949
For running [`pytest`][pytest] in a C-Python 2 environment, things are slightly
5050
more complicated than the approach described for Python 3 above as `pip` for
51-
Python 2 cannot install a project in _editable_ mode unless it has a `setup.py`
51+
Python 2 cannot install a project in *editable* mode unless it has a `setup.py`
5252
file (which we don't have and don't want).
5353

5454
Therefore, a wheel needs to be built (e.g. using [`poetry`][poetry]) and
5555
installed (every time) into the corresponding virtualenv when performing the
56-
tests. Assuming you're having a working _poetry_ setup on your machine, you can
56+
tests. Assuming you're having a working *poetry* setup on your machine, you can
5757
simply use the provided `scripts/py2-pytest.sh` wrapper that will create the
5858
virtualenv, build and install the `imcflibs` wheel and launch `pytest` with the
5959
parameters specified, e.g.
@@ -68,35 +68,35 @@ Unfortunately there is nothing like `pytest` available for the parts that are
6868
running exclusively in a ImageJ2 / Fiji context. So in order to provide at least
6969
some basic, semi-interactive tests the following conventions are being used:
7070

71-
* Each _**function**_ in any of the `imcflibs.imagej` submodules should have its
71+
* Each ***function*** in any of the `imcflibs.imagej` submodules should have its
7272
own directory underneath `/tests/interactive-imagej/`, using their fully
7373
qualified name as the path (only skipping the `imcflibs.` prefix). For example
7474
test scripts for `imcflibs.imagej.bioformats.import_image()` will be placed in
7575
the directory `/tests/interactive-imagej/bioformats/import_image/`.
7676
* The scripts inside those directories are intended to be run interactively /
7777
manually in a (freshly started) Fiji instance. Yes, really. Any other
7878
suggestions are highly welcome!
79-
* To facilitate this, a collection of _test images_ (and possibly other input
79+
* To facilitate this, a collection of *test images* (and possibly other input
8080
data) should be cloned to the local file system. Currently this `sample-data`
81-
repository is _NOT_ publicly available due to legal ⚖ uncertainties. A repo
81+
repository is *NOT* publicly available due to legal ⚖ uncertainties. A repo
8282
containing test data 🗞 that can be published should be assembled over time
8383
though!
84-
* Any _interactive_ test script should start with a header similar to the one
85-
described below. Paths to input data _inside_ the test scripts **has** to be
84+
* Any *interactive* test script should start with a header similar to the one
85+
described below. Paths to input data *inside* the test scripts **has** to be
8686
relative to the location of the `sample-data` repository mentioned above. This
8787
will allow for a fairly okayish testing workflow like this:
8888
* Make your changes in VS Code, then trigger a build by pressing `Shift` +
89-
`Ctrl` + `B`. If things are configured as described in the _DEVELOPMENT_
89+
`Ctrl` + `B`. If things are configured as described in the *DEVELOPMENT*
9090
document, the resulting `.jar` file will be automatically placed in Fiji's
9191
`jars/` folder.
9292
* Next, start a fresh instance of the Fiji that received the newly built JAR.
9393
* After Fiji has started, simply drag and drop the desired test script onto
94-
the main window. This will open the _Script Editor_, then press `Ctrl` + `R`
94+
the main window. This will open the *Script Editor*, then press `Ctrl` + `R`
9595
to launch the script.
9696
* Only on the first run on the machine being used you will have to select the
9797
base location of the `sample-data` repository.
98-
* All subsequent runs of _**any**_ test script using the defined _Script
99-
Parameter_ `IMCF_TESTDATA` will remember this selection, so it will be
98+
* All subsequent runs of ***any*** test script using the defined *Script
99+
Parameter* `IMCF_TESTDATA` will remember this selection, so it will be
100100
sufficient to just confirm the dialog by pressing `Enter`.
101101

102102
### Quick Workflow Summary

poetry.lock.md

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+8-14
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ authors = [
33
"Niko Ehrenfeuchter <[email protected]>",
44
"Laurent Guerard <[email protected]>",
55
"Kai Schleicher <[email protected]>",
6-
"Sébastien Herbert <[email protected]>",
7-
"Rohan Girish <[email protected]>",
6+
"Rohan Girish <[email protected]>",
87
]
98
description = "Mostly ImageJ/Fiji-related Python helper functions."
109
documentation = "https://imcf.one/apidocs/imcflibs/imcflibs.html"
@@ -41,22 +40,17 @@ exclude = [
4140
]
4241

4342
select = [
44-
"D",
45-
# summary lines have to be placed on the first physical line of the docstring
46-
"D212",
47-
# imperative mood for all docstrings
48-
"D401",
49-
# summary line has to end in a punctuation mark
50-
"D415",
51-
# require documentation for _all_ function parameters
52-
"D417",
43+
"D", # enable "pydocstyle" rules
44+
"D212", # summary lines must be on the first physical line of the docstring
45+
"D401", # imperative mood for all docstrings
46+
"D415", # summary line has to end in a punctuation mark
47+
"D417", # require documentation for *all* function parameters
48+
5349
]
5450

5551
ignore = [
56-
# no blank lines allowed after function docstring
57-
"D202",
52+
"D202", # no blank lines allowed after function docstring
5853
]
5954

60-
6155
[tool.ruff.lint.pydocstyle]
6256
convention = "numpy"

src/imcflibs/imagej/prefs.py

+40-6
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,35 @@ def debug_mode():
2323
def set_default_ij_options():
2424
"""Configure ImageJ default options for consistency.
2525
26-
Set the following options:
27-
- Ensure ImageJ appearance settings are default values.
26+
Will set the following options to ensure consistent behaviour independent of
27+
how ImageJ is configured on a specific machine.
28+
29+
- Ensure ImageJ appearance settings are the default values.
2830
- Set foreground color to white and background to black.
29-
- Set black background for binary images.
3031
- Set default file saving format to .txt files.
31-
- Ensure images are scaled appropriately when converting between different bit depths.
32+
- Ensure intensities are being scaled when converting between bit depths.
33+
- Options on binary images:
34+
- Set background to black.
35+
- Enable padding to prevent eroding from image edges.
36+
- Enforce defaults on iterations and count for *erosion*, *dilation*,
37+
*opening* and *closing* operations.
38+
39+
References
40+
----------
41+
The ImageJ User Guide is providing detailed explanations of the options
42+
configured by this function:
43+
44+
- [Edit > Options > Appearance][ijo_app]
45+
- [Edit > Options > Colors][ijo_col]
46+
- [Edit > Options > Conversions][ijo_cnv]
47+
- [Edit > Options > Input/Output][ijo_i_o]
48+
- [Process > Binary > Options][ijo_bin]
49+
50+
[ijo_app]: https://imagej.net/ij/docs/guide/146-27.html#sub:Appearance...
51+
[ijo_cnv]: https://imagej.net/ij/docs/guide/146-27.html#sub:Conversions...
52+
[ijo_col]: https://imagej.net/ij/docs/guide/146-27.html#sub:Colors...
53+
[ijo_i_o]: https://imagej.net/ij/docs/guide/146-27.html#sub:Input/Output...
54+
[ijo_bin]: https://imagej.net/ij/docs/guide/146-29.html#sub:BinaryOptions...
3255
"""
3356

3457
# Set all appearance settings to default values (untick all options)
@@ -37,11 +60,22 @@ def set_default_ij_options():
3760
# Set foreground color to be white and background black
3861
IJ.run("Colors...", "foreground=white background=black selection=red")
3962

40-
# Set black background for binary images and set pad edges to true to prevent eroding from image edge
63+
# Options regarding binary images:
64+
# - `black`: set background for binary images to be black.
65+
# - `pad`: enable padding of edges to prevent eroding from image edge.
66+
# - `iterations=1`: number of times erosion (dilation, opening, closing) is
67+
# performed
68+
# - `count=1`: number of adjacent background pixels necessary before a pixel
69+
# is removed from the edge of an object during erosion and the number of
70+
# adjacent foreground pixels necessary before a pixel is added to the edge
71+
# of an object during dilation.
72+
# https://imagej.net/ij/docs/menus/process.html#options
73+
# https://imagej.net/ij/docs/guide/146-29.html#sub:BinaryOptions...
4174
IJ.run("Options...", "iterations=1 count=1 black pad")
4275

4376
# Set default saving format to .txt files
4477
IJ.run("Input/Output...", "file=.txt save_column save_row")
4578

46-
# Scale when converting = checked
79+
# Enable "scale when converting".
80+
# https://imagej.net/ij/docs/menus/edit.html#options
4781
IJ.run("Conversions...", "scale")

0 commit comments

Comments
 (0)