diff --git a/setup.cfg b/setup.cfg index 6c188968ad16f8df4d917ca1298185136cc34fcf..1202c94bb515096114a01be817d0a554d11503f1 100755 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = napari-3dtimereg -version = 0.0.7 +version = 0.0.10 description = Registration of 3D movies applied to all channels long_description = file: README.md long_description_content_type = text/markdown @@ -42,6 +42,7 @@ install_requires = itk == 5.3.0 itk-registration itk-elastix + pydantic <= 1.10.14 python_requires = >=3.8 include_package_data = True diff --git a/src/napari_3dtimereg/movieRegistration.py b/src/napari_3dtimereg/movieRegistration.py index 3fecb151d0fdcb0b23a3d6e3f4f9c8010ba36662..8f1673fdd2d94cb2f24af7b8dc2a3bf4bba33a5b 100755 --- a/src/napari_3dtimereg/movieRegistration.py +++ b/src/napari_3dtimereg/movieRegistration.py @@ -1,17 +1,15 @@ import napari import tifffile -from magicgui import magicgui -from napari.utils.notifications import show_info import itk import random, math import numpy as np import pathlib import os, glob, csv import napari_3dtimereg.Utils as ut -from qtpy.QtWidgets import QFileDialog +from skimage.measure import label, regionprops +from magicgui import magicgui from napari.utils.history import get_save_history, update_save_history from webbrowser import open_new_tab -from skimage.measure import label, regionprops """ Napari - 3D Time Reg @@ -24,6 +22,7 @@ author: Gaëlle Letort, CNRS/Institut Pasteur def get_filename(): """ User selection of movie to process """ + from qtpy.QtWidgets import QFileDialog dialog = QFileDialog(caption="Choose reference image") hist = get_save_history() dialog.setHistory(hist) @@ -48,26 +47,24 @@ def start(): return getChanels() def start_noshow(): - global viewer - viewer = napari.Viewer( show=False ) + global viewer + viewer = None + #viewer = napari.Viewer( show=False ) def open_file( filename, show_images=True ): global refimg, refchanel global imagename global resimg global scaleXY, scaleZ - global aligndir, imagedir, ptsdir + global aligndir, imagedir global colchan, dim global refpts refpts = None refchanel = 0 refimg, scaleXY, scaleZ, names = ut.open_image(filename, verbose=True) global pixel_spacing - #pixel_spacing = [scaleXY, scaleXY] pixel_spacing = [1, 1] if (scaleZ is not None) and (scaleZ>0): - #pixel_spacing = [scaleZ/scaleXY, scaleZ/scaleXY, 1] - #pixel_spacing.append(scaleZ) pixel_spacing.append(scaleZ/scaleXY) print("Image size: "+str(refimg.shape)) print("Scale: "+str(pixel_spacing)) @@ -81,9 +78,8 @@ def open_file( filename, show_images=True ): colchan = 2 dim = 3 imagename, imagedir, aligndir = ut.extract_names( filename, subname="aligned" ) - ptsdir = os.path.join(imagedir, "regpoints") - update_save_history(imagedir) if show_images: + update_save_history(imagedir) for chan in range(refimg.shape[colchan]): cmap = ut.colormapname(chan) if dim == 3: @@ -140,7 +136,6 @@ def getChanels(): #cview.contrast_limits = quants iterative_registration() - get_chanel.help.clicked.connect(show_help_chanel) wid = viewer.window.add_dock_widget(get_chanel, name="Choose chanel") return wid @@ -157,8 +152,6 @@ def getChanels_noshow( reference_chanel=0 ): else: resimg = np.copy(refimg[:,:,refchanel,:,:]) resimg[0] = resimg[0] - np.min(resimg[0]) - - iterative_registration() def itk_to_layer(img, name, color): @@ -575,10 +568,11 @@ def save_result_image(): resimg[time, :, chan, :,:] = img os.remove(filename) - viewer.add_image(resimg, name="Res", blending="additive") - for lay in viewer.layers: - if lay.name != "Res": - remove_layer(lay) + if viewer is not None: + viewer.add_image(resimg, name="Res", blending="additive") + for lay in viewer.layers: + if lay.name != "Res": + remove_layer(lay) imgname = os.path.join(aligndir, imagename+".tif") resimg = np.array(resimg, "uint16") # move the chanel axis after the Z axis (imageJ format) @@ -588,6 +582,6 @@ def save_result_image(): tifffile.imwrite(imgname, resimg, imagej=True, resolution=[1./scaleXY, 1./scaleXY], metadata={'PhysicalSizeX': scaleXY, 'spacing': scaleZ, 'unit': 'um', 'axes': 'TZCYX'}) else: tifffile.imwrite(imgname, resimg, imagej=True, resolution=[1./scaleXY, 1./scaleXY], metadata={'PhysicalSizeX': scaleXY, 'unit': 'um', 'axes': 'TCYX'}) - show_info("Image "+imgname+" saved") + print("Image "+imgname+" saved")