Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect cropping outside of the image #92

Closed
multimeric opened this issue Oct 10, 2024 · 5 comments
Closed

Detect cropping outside of the image #92

multimeric opened this issue Oct 10, 2024 · 5 comments

Comments

@multimeric
Copy link
Collaborator

Currently if your ROI expands outside of the image, as seen here:
Screenshot 2024-10-11 at 10 16 56 AM

Then the processing fails with:

LogicError: clEnqueueNDRangeKernel failed: INVALID_GLOBAL_WORK_SIZE

Traceback:

---------------------------------------------------------------------------
LogicError                                Traceback (most recent call last)
File ~/Programming/napari_lattice/plugin/napari_lattice/dock_widget.py:172, in LLSZWidget.save(self=<napari_lattice.dock_widget.LLSZWidget object>)
    170 from napari.utils.notifications import show_info
    171 lattice = self._make_model()
--> 172 lattice.save()
        lattice = LatticeData(input_image=<xarray.DataArray (T: 1, C: 1, Z: 60, Y: 256, X: 256)>
<class 'numpy.ndarray'> (1, 1, 60, 256, 256) uint16
Dimensions without coordinates: T, C, Z, Y, X, skew=<DeskewDirection.Y: 2>, angle=30.0, physical_pixel_sizes=DefinedPixelSizes(X=0.1499219273, Y=0.1499219273, Z=0.3), derived=DerivedDeskewFields(deskew_vol_shape=(128, 342, 256), deskew_affine_transform=<pyclesperanto_prototype._tier8._AffineTransform3D.AffineTransform3D object at 0x7fb8e3473130>), save_dir=PosixPath('/private/tmp'), save_suffix='_deskewed', save_name='membrane_deskewed', save_type=<SaveFileType.h5: 'h5'>, time_range=range(0, 1), channel_range=range(0, 1), deconvolution=None, crop=CropParams(roi_list=[Roi(top_left=(1234.2218426072347, 1138.9518876459392), top_right=(1234.2218426072347, 2053.5436103361817), bottom_left=(1882.057646179489, 2053.5436103361817), bottom_right=(1882.057646179489, 1138.9518876459392))], roi_subset=[0], z_range=(0, 1)), workflow=None)
    173 show_info(f"Deskewing successfuly completed. Results are located in {lattice.save_dir}")

File ~/Programming/napari_lattice/core/lls_core/models/lattice_data.py:463, in LatticeData.save(self=LatticeData(input_image=<xarray.DataArray (T: 1,..., roi_subset=[0], z_range=(0, 1)), workflow=None))
    461     list(self.process_workflow().save())
    462 else:
--> 463     self.process().save_image()
        self = LatticeData(input_image=<xarray.DataArray (T: 1, C: 1, Z: 60, Y: 256, X: 256)>
<class 'numpy.ndarray'> (1, 1, 60, 256, 256) uint16
Dimensions without coordinates: T, C, Z, Y, X, skew=<DeskewDirection.Y: 2>, angle=30.0, physical_pixel_sizes=DefinedPixelSizes(X=0.1499219273, Y=0.1499219273, Z=0.3), derived=DerivedDeskewFields(deskew_vol_shape=(128, 342, 256), deskew_affine_transform=<pyclesperanto_prototype._tier8._AffineTransform3D.AffineTransform3D object at 0x7fb8e3473130>), save_dir=PosixPath('/private/tmp'), save_suffix='_deskewed', save_name='membrane_deskewed', save_type=<SaveFileType.h5: 'h5'>, time_range=range(0, 1), channel_range=range(0, 1), deconvolution=None, crop=CropParams(roi_list=[Roi(top_left=(1234.2218426072347, 1138.9518876459392), top_right=(1234.2218426072347, 2053.5436103361817), bottom_left=(1882.057646179489, 2053.5436103361817), bottom_right=(1882.057646179489, 1138.9518876459392))], roi_subset=[0], z_range=(0, 1)), workflow=None)

File ~/Programming/napari_lattice/core/lls_core/models/results.py:83, in ImageSlices.save_image(self=ImageSlices(slices=<generator object LatticeData... roi_subset=[0], z_range=(0, 1)), workflow=None)))
     79 """
     80 Saves result slices to disk
     81 """
     82 Writer = self.lattice_data.get_writer()
---> 83 for roi, roi_results in groupby(self.slices, key=lambda it: it.roi_index):
        self.slices = <generator object LatticeData._process_crop at 0x7fb8f36ea490>
        self = ImageSlices(slices=<generator object LatticeData._process_crop at 0x7fb8f36ea490>, lattice_data=LatticeData(input_image=<xarray.DataArray (T: 1, C: 1, Z: 60, Y: 256, X: 256)>
<class 'numpy.ndarray'> (1, 1, 60, 256, 256) uint16
Dimensions without coordinates: T, C, Z, Y, X, skew=<DeskewDirection.Y: 2>, angle=30.0, physical_pixel_sizes=DefinedPixelSizes(X=0.1499219273, Y=0.1499219273, Z=0.3), derived=DerivedDeskewFields(deskew_vol_shape=(128, 342, 256), deskew_affine_transform=<pyclesperanto_prototype._tier8._AffineTransform3D.AffineTransform3D object at 0x7fb8e3473130>), save_dir=PosixPath('/private/tmp'), save_suffix='_deskewed', save_name='membrane_deskewed', save_type=<SaveFileType.h5: 'h5'>, time_range=range(0, 1), channel_range=range(0, 1), deconvolution=None, crop=CropParams(roi_list=[Roi(top_left=(1234.2218426072347, 1138.9518876459392), top_right=(1234.2218426072347, 2053.5436103361817), bottom_left=(1882.057646179489, 2053.5436103361817), bottom_right=(1882.057646179489, 1138.9518876459392))], roi_subset=[0], z_range=(0, 1)), workflow=None))
     84     writer = Writer(self.lattice_data, roi_index=roi)
     85     for slice in roi_results:

File ~/Programming/napari_lattice/core/lls_core/models/lattice_data.py:354, in LatticeData._process_crop(self=LatticeData(input_image=<xarray.DataArray (T: 1,..., roi_subset=[0], z_range=(0, 1)), workflow=None))
    346 if self.deconvolution is not None:
    347     deconv_args = dict(
    348         num_iter = self.deconvolution.psf_num_iter,
    349         psf = self.deconvolution.psf[slice.channel].to_numpy(),
    350         decon_processing=self.deconvolution.decon_processing
    351     )
    353 yield slice.copy(update={
--> 354     "data": crop_volume_deskew(
        slice = ProcessedSlice(data=<xarray.DataArray (Z: 60, Y: 256, X: 256)>
<class 'numpy.ndarray'> (60, 256, 256) uint16
Dimensions without coordinates: Z, Y, X, time_index=0, time=0, channel_index=0, channel=0, roi_index=None)
        slice.data = <xarray.DataArray (Z: 60, Y: 256, X: 256)>
<class 'numpy.ndarray'> (60, 256, 256) uint16
Dimensions without coordinates: Z, Y, X
        self = LatticeData(input_image=<xarray.DataArray (T: 1, C: 1, Z: 60, Y: 256, X: 256)>
<class 'numpy.ndarray'> (1, 1, 60, 256, 256) uint16
Dimensions without coordinates: T, C, Z, Y, X, skew=<DeskewDirection.Y: 2>, angle=30.0, physical_pixel_sizes=DefinedPixelSizes(X=0.1499219273, Y=0.1499219273, Z=0.3), derived=DerivedDeskewFields(deskew_vol_shape=(128, 342, 256), deskew_affine_transform=<pyclesperanto_prototype._tier8._AffineTransform3D.AffineTransform3D object at 0x7fb8e3473130>), save_dir=PosixPath('/private/tmp'), save_suffix='_deskewed', save_name='membrane_deskewed', save_type=<SaveFileType.h5: 'h5'>, time_range=range(0, 1), channel_range=range(0, 1), deconvolution=None, crop=CropParams(roi_list=[Roi(top_left=(1234.2218426072347, 1138.9518876459392), top_right=(1234.2218426072347, 2053.5436103361817), bottom_left=(1882.057646179489, 2053.5436103361817), bottom_right=(1882.057646179489, 1138.9518876459392))], roi_subset=[0], z_range=(0, 1)), workflow=None)
        roi = Roi(top_left=(1234.2218426072347, 1138.9518876459392), top_right=(1234.2218426072347, 2053.5436103361817), bottom_left=(1882.057646179489, 2053.5436103361817), bottom_right=(1882.057646179489, 1138.9518876459392))
        self.angle = 30.0
        self.crop = CropParams(roi_list=[Roi(top_left=(1234.2218426072347, 1138.9518876459392), top_right=(1234.2218426072347, 2053.5436103361817), bottom_left=(1882.057646179489, 2053.5436103361817), bottom_right=(1882.057646179489, 1138.9518876459392))], roi_subset=[0], z_range=(0, 1))
        self.crop.z_range[0] = 0
        self.crop.z_range = (0, 1)
        self.crop.z_range[1] = 1
        deconv_args = {}
        roi_index = 0
        self.crop.roi_subset[roi_index] = 0
        self.crop.roi_subset = [0]
    355         original_volume=slice.data,
    356         deconvolution=self.deconv_enabled,
    357         get_deskew_and_decon=False,
    358         debug=False,
    359         roi_shape=list(roi),
    360         linear_interpolation=True,
    361         voxel_size_x=self.dx,
    362         voxel_size_y=self.dy,
    363         voxel_size_z=self.dz,
    364         angle_in_degrees=self.angle,
    365         deskewed_volume=self.deskewed_volume,
    366         z_start=self.crop.z_range[0],
    367         z_end=self.crop.z_range[1],
    368         **deconv_args
    369     ),
    370     "roi_index": self.crop.roi_subset[roi_index]
    371 })

File ~/Programming/napari_lattice/core/lls_core/llsz_core.py:257, in crop_volume_deskew(original_volume=<xarray.DataArray (Z: 60, Y: 256, X: 256)>
<clas...6) uint16
Dimensions without coordinates: Z, Y, X, deskewed_volume=dask.array<zeros_like, shape=(128, 342, 256), dt...unksize=(128, 342, 256), chunktype=numpy.ndarray>, roi_shape=[(1234.2218426072347, 1138.9518876459392), (1234.2218426072347, 2053.5436103361817), (1882.057646179489, 2053.5436103361817), (1882.057646179489, 1138.9518876459392)], angle_in_degrees=30.0, voxel_size_x=0.1499219273, voxel_size_y=0.1499219273, voxel_size_z=0.3, z_start=0, z_end=1, debug=False, deconvolution=False, decon_processing=None, psf=None, num_iter=10, linear_interpolation=True, skew_dir=<DeskewDirection.Y: 2>, get_deskew_and_decon=False)
    247         deskewed_no_decon = affine_transform_deskew_3d(
    248             crop_volume,
    249             transform=deskew_transform,
   (...)
    254             deskew_direction=skew_dir,
    255         )
    256 else:
--> 257     deskewed_prelim = affine_transform_deskew_3d(
        crop_volume = <xarray.DataArray (Z: 0, Y: 2, X: 0)>
<class 'numpy.ndarray'> (0, 2, 0) uint16
Dimensions without coordinates: Z, Y, X
        deskew_transform = <pyclesperanto_prototype._tier8._AffineTransform3D.AffineTransform3D object at 0x7fb8f385fbe0>
        angle_in_degrees = 30.0
        voxel_size_x = 0.1499219273
        voxel_size_y = 0.1499219273
        voxel_size_z = 0.3
        skew_dir = <DeskewDirection.Y: 2>
    258         crop_volume,
    259         transform=deskew_transform,
    260         deskewing_angle_in_degrees=angle_in_degrees,
    261         voxel_size_x=voxel_size_x,
    262         voxel_size_y=voxel_size_y,
    263         voxel_size_z=voxel_size_z,
    264         deskew_direction=skew_dir,
    265     )
    267 # The height of deskewed_prelim will be larger than specified shape
    268 # as the coordinates of the ROI are skewed in the original volume
    269 # IF CLIPPING HAPPENS FOR Y_START or Y_END, use difference to calculate offset
    270 if skew_dir == DeskewDirection.Y:

File /opt/anaconda3/envs/napari2/lib/python3.10/site-packages/pyclesperanto_prototype/_tier0/_plugin_function.py:71, in plugin_function.<locals>.worker_function(*args=(<xarray.DataArray (Z: 0, Y: 2, X: 0)>
<class 'nu...0) uint16
Dimensions without coordinates: Z, Y, X,), **kwargs={'deskew_direction': <DeskewDirection.Y: 2>, 'deskewing_angle_in_degrees': 30.0, 'transform': <pyclesperanto_prototype._tier8._AffineTransform3D.AffineTransform3D object>, 'voxel_size_x': 0.1499219273, 'voxel_size_y': 0.1499219273, 'voxel_size_z': 0.3})
     68         bound.arguments[key] = output_creator(*bound.args[:len(sig2.parameters)])
     70 # call the decorated function
---> 71 return function(*bound.args, **bound.kwargs)
        bound = <BoundArguments (source=<class 'numpy.ndarray'> (0, 2, 0) float32, destination=None, transform=<pyclesperanto_prototype._tier8._AffineTransform3D.AffineTransform3D object at 0x7fb8f385fbe0>, deskewing_angle_in_degrees=30.0, voxel_size_x=0.1499219273, voxel_size_y=0.1499219273, voxel_size_z=0.3, deskew_direction=<DeskewDirection.Y: 2>)>
        function = <function affine_transform_deskew_3d at 0x7fb8e2841f30>

File /opt/anaconda3/envs/napari2/lib/python3.10/site-packages/pyclesperanto_prototype/_tier8/_affine_transform_deskew_3d.py:105, in affine_transform_deskew_3d(source=<class 'numpy.ndarray'> (0, 2, 0) float32, destination=<class 'numpy.ndarray'> (1, 2, 0) float32, transform=<pyclesperanto_prototype._tier8._AffineTransform3D.AffineTransform3D object>, deskewing_angle_in_degrees=30.0, voxel_size_x=0.1499219273, voxel_size_y=0.1499219273, voxel_size_z=0.3, deskew_direction=<DeskewDirection.Y: 2>)
     93 # pass the shape of the final image, pixel step and precalculated trig
     95 parameters = {
     96     "input": source,
     97     "output": destination,
   (...)
    102     "sintheta": sintheta
    103 }
--> 105 execute(__file__, './affine_transform_' + kernel_suffix + str(len(destination.shape)) + 'd' + '_x.cl',
        destination = <class 'numpy.ndarray'> (1, 2, 0) float32
        kernel_suffix = 'deskew_y_'
        __file__ = '/opt/anaconda3/envs/napari2/lib/python3.10/site-packages/pyclesperanto_prototype/_tier8/_affine_transform_deskew_3d.py'
        './affine_transform_' + kernel_suffix + str(len(destination.shape)) + 'd' + '_x.cl' = './affine_transform_deskew_y_3d_x.cl'
        destination.shape = (1, 2, 0)
        './affine_transform_' + kernel_suffix + str(len(destination.shape)) + 'd' = './affine_transform_deskew_y_3d'
        './affine_transform_' + kernel_suffix + str(len(destination.shape)) = './affine_transform_deskew_y_3'
        str(len(destination.shape)) = '3'
        './affine_transform_' + kernel_suffix = './affine_transform_deskew_y_'
        len(destination.shape) = 3
        parameters = {'input': <class 'numpy.ndarray'> (0, 2, 0) float32, 'output': <class 'numpy.ndarray'> (1, 2, 0) float32, 'mat': <class 'numpy.ndarray'> (4, 4) float32, 'pixel_step': 2.0010414, 'tantheta': 0.57735026, 'costheta': 0.8660254, 'sintheta': 0.5}
        'affine_transform_'  + kernel_suffix + str(len(destination.shape)) + 'd' = 'affine_transform_deskew_y_3d'
        'affine_transform_'  + kernel_suffix + str(len(destination.shape)) = 'affine_transform_deskew_y_3'
        'affine_transform_'  + kernel_suffix = 'affine_transform_deskew_y_'
    106         'affine_transform_'  + kernel_suffix + str(len(destination.shape)) + 'd', destination.shape, parameters)
    108 return destination

File /opt/anaconda3/envs/napari2/lib/python3.10/site-packages/pyclesperanto_prototype/_tier0/_execute.py:35, in execute(anchor='/opt/anaconda3/envs/napari2/lib/python3.10/site-...o_prototype/_tier8/_affine_transform_deskew_3d.py', opencl_kernel_filename='./affine_transform_deskew_y_3d_x.cl', kernel_name='affine_transform_deskew_y_3d', global_size=(1, 2, 0), parameters={'costheta': 0.8660254, 'input': <class 'numpy.ndarray'> (0, 2, 0) float32, 'mat': <class 'numpy.ndarray'> (4, 4) float32, 'output': <class 'numpy.ndarray'> (1, 2, 0) float32, 'pixel_step': 2.0010414, 'sintheta': 0.5, 'tantheta': 0.57735026}, prog=None, constants=None, image_size_independent_kernel_compilation=None, device=None)
      2 def execute(anchor, opencl_kernel_filename:str, kernel_name:str, global_size, parameters, prog = None, constants = None, image_size_independent_kernel_compilation : bool = None, device = None):
      3     """
      4     Call opencl kernels (.cl files)
      5 
   (...)
     33 
     34     """
---> 35     return Backend.get_instance().get().execute(anchor, opencl_kernel_filename, kernel_name, global_size, parameters, prog, constants, image_size_independent_kernel_compilation, device)
        anchor = '/opt/anaconda3/envs/napari2/lib/python3.10/site-packages/pyclesperanto_prototype/_tier8/_affine_transform_deskew_3d.py'
        opencl_kernel_filename = './affine_transform_deskew_y_3d_x.cl'
        kernel_name = 'affine_transform_deskew_y_3d'
        global_size = (1, 2, 0)
        parameters = {'input': <class 'numpy.ndarray'> (0, 2, 0) float32, 'output': <class 'numpy.ndarray'> (1, 2, 0) float32, 'mat': <class 'numpy.ndarray'> (4, 4) float32, 'pixel_step': 2.0010414, 'tantheta': 0.57735026, 'costheta': 0.8660254, 'sintheta': 0.5}
        prog = None
        constants = None
        image_size_independent_kernel_compilation = None
        device = None

File /opt/anaconda3/envs/napari2/lib/python3.10/site-packages/pyclesperanto_prototype/_tier0/_opencl_backend.py:41, in OpenCLBackend.execute(self=<pyclesperanto_prototype._tier0._opencl_backend.OpenCLBackend object>, anchor='/opt/anaconda3/envs/napari2/lib/python3.10/site-...o_prototype/_tier8/_affine_transform_deskew_3d.py', opencl_kernel_filename='./affine_transform_deskew_y_3d_x.cl', kernel_name='affine_transform_deskew_y_3d', global_size=(1, 2, 0), parameters={'costheta': 0.8660254, 'input': <class 'numpy.ndarray'> (0, 2, 0) float32, 'mat': <class 'numpy.ndarray'> (4, 4) float32, 'output': <class 'numpy.ndarray'> (1, 2, 0) float32, 'pixel_step': 2.0010414, 'sintheta': 0.5, 'tantheta': 0.57735026}, prog=None, constants=None, image_size_independent_kernel_compilation=None, device=None)
     40 def execute(self, anchor, opencl_kernel_filename, kernel_name, global_size, parameters, prog = None, constants = None, image_size_independent_kernel_compilation : bool = None, device = None):
---> 41     return execute(anchor, opencl_kernel_filename, kernel_name, global_size, parameters, prog, constants, image_size_independent_kernel_compilation, device)
        anchor = '/opt/anaconda3/envs/napari2/lib/python3.10/site-packages/pyclesperanto_prototype/_tier8/_affine_transform_deskew_3d.py'
        opencl_kernel_filename = './affine_transform_deskew_y_3d_x.cl'
        kernel_name = 'affine_transform_deskew_y_3d'
        global_size = (1, 2, 0)
        parameters = {'input': <class 'numpy.ndarray'> (0, 2, 0) float32, 'output': <class 'numpy.ndarray'> (1, 2, 0) float32, 'mat': <class 'numpy.ndarray'> (4, 4) float32, 'pixel_step': 2.0010414, 'tantheta': 0.57735026, 'costheta': 0.8660254, 'sintheta': 0.5}
        prog = None
        constants = None
        image_size_independent_kernel_compilation = None
        device = None

File /opt/anaconda3/envs/napari2/lib/python3.10/site-packages/pyclesperanto_prototype/_tier0/_opencl_execute.py:322, in execute(anchor='/opt/anaconda3/envs/napari2/lib/python3.10/site-...o_prototype/_tier8/_affine_transform_deskew_3d.py', opencl_kernel_filename='./affine_transform_deskew_y_3d_x.cl', kernel_name='affine_transform_deskew_y_3d', global_size=(1, 2, 0), parameters={'costheta': 0.8660254, 'input': <class 'numpy.ndarray'> (0, 2, 0) float32, 'mat': <class 'numpy.ndarray'> (4, 4) float32, 'output': <class 'numpy.ndarray'> (1, 2, 0) float32, 'pixel_step': 2.0010414, 'sintheta': 0.5, 'tantheta': 0.57735026}, prog=<pyclesperanto_prototype._tier0._program.OCLProgram object>, constants=None, image_size_independent_kernel_compilation=True, device=<Apple M2 on Platform: Apple (21 refs)>)
    312     #prog = OCLProgram.from_source("\n".join(defines))
    313 
    314     # Todo: the order of the arguments matters; fix that
    315     # print("Compilation " + opencl_kernel_filename + " took " + str((time.time() - time_stamp) * 1000) + " ms")
    316 else:
    317     warnings.warn(
    318         "The `prog` parameter of pyclesperanto_prototype.execute is deprecated since 0.11.0. It will be removed in 0.12.0.",
    319         DeprecationWarning
    320     )
--> 322 prog.run_kernel(kernel_name, tuple(global_size[::-1]), None, *arguments)
        arguments = [<class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, None, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, None, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <pyopencl._cl.Buffer object at 0x7fb9044c8900>, <class 'numpy.ndarray'> (1,) float32, <class 'numpy.ndarray'> (1,) float32, <class 'numpy.ndarray'> (1,) float32, <class 'numpy.ndarray'> (1,) float32]
        prog = <pyclesperanto_prototype._tier0._program.OCLProgram object at 0x7fb8f32ad660>
        kernel_name = 'affine_transform_deskew_y_3d'
        tuple(global_size[::-1]) = (0, 2, 1)
        global_size[::-1] = (0, 2, 1)
        global_size = (1, 2, 0)
    324 return prog

File /opt/anaconda3/envs/napari2/lib/python3.10/site-packages/pyclesperanto_prototype/_tier0/_program.py:34, in OCLProgram.run_kernel(self=<pyclesperanto_prototype._tier0._program.OCLProgram object>, name='affine_transform_deskew_y_3d', global_size=(0, 2, 1), local_size=None, *args=(<class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, None, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, None, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <pyopencl._cl.Buffer object>, <class 'numpy.ndarray'> (1,) float32, <class 'numpy.ndarray'> (1,) float32, <class 'numpy.ndarray'> (1,) float32, <class 'numpy.ndarray'> (1,) float32), **kwargs={})
     31 if name not in self._kernel_dict:
     32     self._kernel_dict[name] = getattr(self, name)
---> 34 self._kernel_dict[name](
        name = 'affine_transform_deskew_y_3d'
        self._kernel_dict = {'affine_transform_deskew_y_3d': <pyopencl._cl.Kernel object at 0x7fb8f32fe250>}
        self._kernel_dict[name] = <pyopencl._cl.Kernel object at 0x7fb8f32fe250>
        self = <pyclesperanto_prototype._tier0._program.OCLProgram object at 0x7fb8f32ad660>
        self._dev.queue = <pyopencl._cl.CommandQueue object at 0x7fb8e2865e90>
        global_size = (0, 2, 1)
        local_size = None
        self._dev = <Apple M2 on Platform: Apple (21 refs)>
        args = (<class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, None, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, None, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <pyopencl._cl.Buffer object at 0x7fb9044c8900>, <class 'numpy.ndarray'> (1,) float32, <class 'numpy.ndarray'> (1,) float32, <class 'numpy.ndarray'> (1,) float32, <class 'numpy.ndarray'> (1,) float32)
        kwargs = {}
     35     self._dev.queue, global_size, local_size, *args, **kwargs
     36 )
     37 if OCLProgram._wait_for_kernel_finish:
     38     self._dev.queue.finish()

File /opt/anaconda3/envs/napari2/lib/python3.10/site-packages/pyopencl/__init__.py:901, in _add_functionality.<locals>.kernel_call(self=<pyopencl._cl.Kernel object>, queue=<pyopencl._cl.CommandQueue object>, global_size=(0, 2, 1), local_size=None, *args=(<class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, None, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, None, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <pyopencl._cl.Buffer object>, <class 'numpy.ndarray'> (1,) float32, <class 'numpy.ndarray'> (1,) float32, <class 'numpy.ndarray'> (1,) float32, <class 'numpy.ndarray'> (1,) float32), **kwargs={})
    895 def kernel_call(self, queue, global_size, local_size, *args, **kwargs):
    896     # __call__ can't be overridden directly, so we need this
    897     # trampoline hack.
    898 
    899     # Note: This is only used for the generic __call__, before
    900     # kernel_set_scalar_arg_dtypes is called.
--> 901     return self._enqueue(self, queue, global_size, local_size, *args, **kwargs)
        self._enqueue = <function enqueue_knl_affine_transform_deskew_y_3d at 0x7fb8f3263520>
        self = <pyopencl._cl.Kernel object at 0x7fb8f32fe250>
        queue = <pyopencl._cl.CommandQueue object at 0x7fb8e2865e90>
        global_size = (0, 2, 1)
        local_size = None
        args = (<class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, None, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, None, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <class 'numpy.ndarray'> (1,) int32, <pyopencl._cl.Buffer object at 0x7fb9044c8900>, <class 'numpy.ndarray'> (1,) float32, <class 'numpy.ndarray'> (1,) float32, <class 'numpy.ndarray'> (1,) float32, <class 'numpy.ndarray'> (1,) float32)
        kwargs = {}

File <pyopencl invoker for 'affine_transform_deskew_y_3d'>:8, in enqueue_knl_affine_transform_deskew_y_3d(self=<pyopencl._cl.Kernel object>, queue=<pyopencl._cl.CommandQueue object>, global_size=(0, 2, 1), local_size=None, arg0=<class 'numpy.ndarray'> (1,) int32, arg1=<class 'numpy.ndarray'> (1,) int32, arg2=<class 'numpy.ndarray'> (1,) int32, arg3=None, arg4=<class 'numpy.ndarray'> (1,) int32, arg5=<class 'numpy.ndarray'> (1,) int32, arg6=<class 'numpy.ndarray'> (1,) int32, arg7=None, arg8=<class 'numpy.ndarray'> (1,) int32, arg9=<class 'numpy.ndarray'> (1,) int32, arg10=<class 'numpy.ndarray'> (1,) int32, arg11=<pyopencl._cl.Buffer object>, arg12=<class 'numpy.ndarray'> (1,) float32, arg13=<class 'numpy.ndarray'> (1,) float32, arg14=<class 'numpy.ndarray'> (1,) float32, arg15=<class 'numpy.ndarray'> (1,) float32, global_offset=None, g_times_l=False, allow_empty_ndrange=False, wait_for=None)

LogicError: clEnqueueNDRangeKernel failed: INVALID_GLOBAL_WORK_SIZE

This should be detected using a new validator on the LatticeData model.

@pr4deepr
Copy link
Collaborator

The code here should take care of it

https://github.com/BioimageAnalysisCoreWEHI/napari_lattice/blob/master/core%2Flls_core%2Fllsz_core.py#L160

Assuming the coordinates get passed in pixels instead of microns?

@multimeric
Copy link
Collaborator Author

I don't think the scale is an issue here. I'll have to investigate why it doesn't get clipped appropriately.

@pr4deepr
Copy link
Collaborator

I remember testing this in napari.
Could you run this using cli only? Although it will have to be an ROI manager file from Fiji.

@multimeric
Copy link
Collaborator Author

multimeric commented Oct 11, 2024

Hmm actually this might be a bug in #91. Let me know if you can work out the cause, because I thought I was correctly scaling it by dy:

for shape in self.shapes.shapes.value:
rois.append(Roi.from_array(shape.get_array() / deskew.dy))

@multimeric
Copy link
Collaborator Author

Closing as I haven't been able to reproduce this recently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants