Skip to content
Snippets Groups Projects
Commit 31fba17b authored by fima's avatar fima :beers:
Browse files

Merge branch 'v1-prep_itk-vtk' into 'main'

Change of structure for v1

See merge request !141
parents 96edafd6 8efe6842
No related branches found
No related tags found
1 merge request!141Change of structure for v1
...@@ -159,20 +159,12 @@ def main(): ...@@ -159,20 +159,12 @@ def main():
elif args.subcommand == "viz": elif args.subcommand == "viz":
if args.method == "itk-vtk": if args.method == "itk-vtk":
try:
# We need the full path to the file for the viewer # We need the full path to the file for the viewer
current_dir = os.getcwd() current_dir = os.getcwd()
full_path = os.path.normpath(os.path.join(current_dir, args.source)) full_path = os.path.normpath(os.path.join(current_dir, args.source))
qim3d.viz.itk_vtk(full_path, open_browser=not args.no_browser) qim3d.viz.itk_vtk(full_path, open_browser = not args.no_browser)
except qim3d.viz.NotInstalledError as err:
print(err)
message = "Itk-vtk-viewer is not installed or qim3d can not find it.\nYou can either:\n\to Use 'qim3d viz SOURCE -m k3d' to display data using different method\n\to Install itk-vtk-viewer yourself following https://kitware.github.io/itk-vtk-viewer/docs/cli.html#Installation\n\to Let qim3D install itk-vtk-viewer now (it will also install node.js in qim3d library)\nDo you want qim3D to install itk-vtk-viewer now?"
print(message)
answer = input("[Y/n]:")
if answer in "Yy":
qim3d.viz.Installer().install()
qim3d.viz.itk_vtk(full_path)
elif args.method == "k3d": elif args.method == "k3d":
volume = qim3d.io.load(str(args.source)) volume = qim3d.io.load(str(args.source))
......
...@@ -9,7 +9,7 @@ from ._data_exploration import ( ...@@ -9,7 +9,7 @@ from ._data_exploration import (
chunks, chunks,
histogram, histogram,
) )
from .itk_vtk_viewer import itk_vtk, Installer, NotInstalledError from .itk_vtk_viewer import itk_vtk
from ._k3d import volumetric, mesh from ._k3d import volumetric, mesh
from ._local_thickness import local_thickness from ._local_thickness import local_thickness
from ._structure_tensor import vectors from ._structure_tensor import vectors
......
from .installation import Installer
from .run import itk_vtk from .run import itk_vtk
from .helpers import NotInstalledError
\ No newline at end of file
import subprocess import subprocess
import platform
from pathlib import Path from pathlib import Path
import os import os
import webbrowser
import threading
import time
import qim3d.utils import qim3d.utils
from qim3d.utils._logger import log from qim3d.utils._logger import log
# from .helpers import get_qim_dir, get_nvm_dir, get_viewer_binaries, get_viewer_dir, get_node_binaries_dir, NotInstalledError, SOURCE_FNM
from .helpers import * from .helpers import *
import webbrowser from .installation import Installer
import threading
import time
# Start viewer # Start viewer
...@@ -73,7 +74,7 @@ def run_within_qim_dir(port=3000): ...@@ -73,7 +74,7 @@ def run_within_qim_dir(port=3000):
) )
def itk_vtk( def try_opening_itk_vtk(
filename: str = None, filename: str = None,
open_browser: bool = True, open_browser: bool = True,
file_server_port: int = 8042, file_server_port: int = 8042,
...@@ -120,8 +121,8 @@ def itk_vtk( ...@@ -120,8 +121,8 @@ def itk_vtk(
1.85GB [00:17, 111MB/s] 1.85GB [00:17, 111MB/s]
Loading Okinawa_Foram_1.tif Loading Okinawa_Foram_1.tif
Loading: 100% Loading: 100%
1.85GB/1.85GB [00:02<00:00, 762MB/s] 1.85GB/1.85GB [00:02<00:00, 762MB/s]
Loaded shape: (995, 1014, 984) Loaded shape: (995, 1014, 984)
Using virtual stack Using virtual stack
Exporting data to OME-Zarr format at Okinawa_Foram_1.zarr Exporting data to OME-Zarr format at Okinawa_Foram_1.zarr
...@@ -207,3 +208,34 @@ def itk_vtk( ...@@ -207,3 +208,34 @@ def itk_vtk(
# If we still get an error, it is not installed in location we expect it to be installed and have to raise an error # If we still get an error, it is not installed in location we expect it to be installed and have to raise an error
# which will be caught in the command line and it will ask for installation # which will be caught in the command line and it will ask for installation
raise NotInstalledError raise NotInstalledError
def itk_vtk(
filename: str = None,
open_browser: bool = True,
file_server_port: int = 8042,
viewer_port: int = 3000
):
"""
Command to run in cli/__init__.py. Tries to run the vizualization,
if that fails, asks the user to install it. This function is needed
here so we don't have to import NotInstalledError and Installer,
which exposes these to user.
"""
try:
try_opening_itk_vtk(filename,
open_browser=open_browser,
file_server_port = file_server_port,
viewer_port = viewer_port)
except NotInstalledError:
message = "Itk-vtk-viewer is not installed or qim3d can not find it.\nYou can either:\n\to Use 'qim3d viz SOURCE -m k3d' to display data using different method\n\to Install itk-vtk-viewer yourself following https://kitware.github.io/itk-vtk-viewer/docs/cli.html#Installation\n\to Let qim3D install itk-vtk-viewer now (it will also install node.js in qim3d library)\nDo you want qim3D to install itk-vtk-viewer now?"
print(message)
answer = input("[Y/n]:")
if answer in "Yy":
Installer().install()
try_opening_itk_vtk(filename,
open_browser=open_browser,
file_server_port = file_server_port,
viewer_port = viewer_port)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment