Skip to content

Commit

Permalink
Fixes for ImageJ Integration when using released executables (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcoreymv authored Jul 12, 2024
1 parent a1f5097 commit 163b3fc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
5 changes: 5 additions & 0 deletions lumaviewpro.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
from tkinter import filedialog, Tk
from plyer import filechooser

import imagej.doctor
import imagej
imagej.doctor.checkup()
import scyjava

import modules.profiling_utils as profiling_utils
global profiling_helper
profiling_helper = None
Expand Down
18 changes: 18 additions & 0 deletions modules/imagej_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


try:
import imagej.doctor
import imagej
import scyjava
imagej_imported = True
Expand All @@ -33,6 +34,13 @@ def list(cls):
class ImageJHelper:

def __init__(self):
try:
imagej.doctor.checkup()
except Exception as ex:
logger.info(f"[ImageJ Helper] Unable to run ImageJ Doctor Checkup: {ex}")

self._test_dependencies()

if imagej_imported == False:
logger.error(f"[ImageJ Helper] ImageJ module failed to import, unable to use {self.__class__.__name__}")
self._ij = None
Expand All @@ -46,6 +54,16 @@ def __init__(self):
logger.error(f"[ImageJ Helper] Unable to initialize ImageJ: {ex}")


def _test_dependencies(self):
import importlib
for pkg in ('imglyb', 'jgo', 'jpype', 'labeling', 'numpy', 'scyjava', 'xarray'):
try:
mod = importlib.import_module(pkg)
logger.info(f"Imported {mod.__name__}")
except Exception as ex:
logger.error(f"Unable to import {pkg}: {ex}")


def _log_uninitialized(self):
logger.error(f"[ImageJ Helper] ImageJ not initialized")

Expand Down
12 changes: 9 additions & 3 deletions scripts/config/lumaviewpro_win_release.spec
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# -*- mode: python ; coding: utf-8 -*-

from kivy_deps import sdl2, glew
from PyInstaller.utils.hooks import copy_metadata

block_cipher = None
app_name = 'lumaviewpro'
datas = [
('.','.')
]

for pkg in ('numpy','scyjava','imglyb','pyimagej'):
datas.extend(copy_metadata(pkg))


hiddenimports = [
'imagecodecs._imcd',
Expand All @@ -18,9 +26,7 @@ a = Analysis(
['lumaviewpro.py'],
pathex=['.'],
binaries=[],
datas=[
('.','.')
],
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2

0 comments on commit 163b3fc

Please sign in to comment.