Skip to content

Commit f96da00

Browse files
committed
Update the info about macOS interactive mode
To reflect the fact that it now works in IPython/Jupyter notebooks.
1 parent 2c315d8 commit f96da00

File tree

6 files changed

+14
-20
lines changed

6 files changed

+14
-20
lines changed

doc/01-Starting-PyImageJ.ipynb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959
"| With Fiji plugins (specific version) | `ij = imagej.init('sc.fiji:fiji:2.14.0')` | YES |\n",
6060
"| From a local installation | `ij = imagej.init('/Applications/Fiji.app')` | DEPENDS |\n",
6161
"\n",
62-
"*: _`mode='interactive'` is unavailalbe on macOS. Instead use `mode='gui'`. When set to `gui` mode the Python interpeter is blocked and no longer interactive. Check out the [initialization](Initialization.md) documentation for more information._\n",
63-
"\n",
6462
"<sup>1</sup> pyimagej uses [`jgo`](https://github.com/scijava/jgo) internally to call up ImageJ, so all of these initializations are tied to the usage of `jgo`. You can read up on the [usage of `jgo`](https://github.com/scijava/jgo#usage) to find out more about this initialization.\n",
6563
"\n",
6664
"<sup>2</sup> ___Reproducible___ means code is stable, executing the same today, tomorrow, and in years to come. While it is convenient and elegant to depend on the newest version of a program, behavior may change when new versions are released—for the better if bugs are fixed; for the worse if bugs are introduced—and people executing your notebook at a later time may encounter broken cells, unexpected results, or other more subtle behavioral differences. You can help avoid this pitfall by pinning to a specific version of the software. The British Ecological Society published [Guide to Better Science: Reproducible Code](https://www.britishecologicalsociety.org/wp-content/uploads/2018/12/BES-Reproducible-Code.pdf) diving into the relevant challenges in more detail, including an [R](https://www.r-project.org/)-centric illustration of best practices. A web search for `reproducible python` also yields several detailed articles."

doc/06-Working-with-Images.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@
414414
"\n",
415415
"<table><tr><td>\n",
416416
"\n",
417-
"This section does not currently work on macOS. See [imagej/pyimagej#197](https://github.com/imagej/pyimagej/issues/197) for details.\n",
417+
"This section may not currently work on macOS. See [imagej/pyimagej#197](https://github.com/imagej/pyimagej/issues/197) for details.\n",
418418
"\n",
419419
"</td></tr></table>\n",
420420
"\n",

doc/Cellpose-StarDist-Segmentation.ipynb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,6 @@
393393
" print(nuc_roi_tree.children().get(i).data())"
394394
]
395395
},
396-
{
397-
"cell_type": "markdown",
398-
"metadata": {},
399-
"source": [
400-
"⚠️**Warning**: The following section requires an [interactive](Initialization.md#ways-to-initialize) PyImageJ session. Unfortnately macOS does not support PyImageJ's interactive mode, thus this notebook can only be run in `headless` mode on macOS. Visit the [interactive mode on macOS](Troubleshooting.md#non-blocking-interactive-mode-on-macos) section in the PyImageJ troubleshooting documentation for more information."
401-
]
402-
},
403396
{
404397
"cell_type": "code",
405398
"execution_count": 11,

doc/Initialization.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ This mode returns immediately after initializing ImageJ2, allowing you to
118118
"mix and match" operations performed via Python code with operations
119119
performed via GUI interactions.
120120

121-
_**Note:** This mode does not work on macOS,
122-
due to a limitation in the macOS threading model._
121+
_**Note:** This mode does not work on macOS from plain Python, due to a
122+
limitation in the macOS threading model. It does work in IPython/Jupyter, as
123+
well as via the [Jaunch](https://github.com/apposed/jaunch#readme) launcher._
123124

124125
### Support for the original ImageJ
125126

doc/Troubleshooting.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ you want to register or update.
6565

6666
### Non-blocking INTERACTIVE mode on macOS
6767

68-
On macOS, the Cocoa event loop needs to be started from the main thread before
69-
any Java-AWT-specific functions can work. And doing so blocks the main thread.
70-
For this reason, PyImageJ includes two graphical modes, `GUI` and
71-
`INTERACTIVE`, with `GUI` blocking the `imagej.init` invocation, and
72-
`INTERACTIVE` returning immediately... but `INTERACTIVE` cannot work on macOS
73-
and is therefore not available, due to this OS-specific limitation.
68+
On macOS, the CoreFoundation/AppKit event loop needs to be started from the
69+
main thread before any Java-AWT-specific functions can work. And doing so
70+
blocks the main thread. For this reason, PyImageJ includes two graphical modes,
71+
`GUI` and `INTERACTIVE`, with `GUI` blocking the `imagej.init` invocation, and
72+
`INTERACTIVE` returning immediately... but `INTERACTIVE` can only work on macOS
73+
in certain scenarios. PyImageJ makes a best effort to check your environment
74+
and report when interactive cannot work, and how you might go about fixing it.
7475

7576
### Old versions of ImageJ2
7677

src/imagej/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,8 +1179,9 @@ def init(
11791179
Start ImageJ2 with GUI support, but *not* displaying the GUI
11801180
automatically, Does not block. To display the GUI in this mode,
11811181
call ij.ui().showUI().
1182-
NB: This mode is not available on macOS, due to its application
1183-
threading model.
1182+
NB: On macOS, this mode only works in some scenarios. It will
1183+
not work from plain Python, but it works in IPython/Jupyter,
1184+
as well as when launching Python via the Jaunch launcher.
11841185
NB: In this mode with add_legacy=True, the JVM and Python will
11851186
both terminate when ImageJ closes!
11861187

0 commit comments

Comments
 (0)