RiosGroup / STAPL3D

SegmenTation Analysis by ParaLlelization of 3D Datasets
Apache License 2.0
9 stars 3 forks source link

zipping:relabel #3

Closed moore-cl closed 1 year ago

moore-cl commented 1 year ago

Hi, really loving the demo and the extremely clear Nature protocols publication as a guidebook.

When running the segmentation demo, I am running into the following error during the zipping module. This could be a problem on my end or a limitation in my device, let me know if that's the case. Thanks for any help, and again thank you for the great demo !

OSError: Can't write data (inflate() failed) """

The above exception was the direct cause of the following exception:

OSError Traceback (most recent call last) Cell In [30], line 1 ----> 1 zipp3r.relabel() 2 zipp3r.copyblocks()

File ~\anaconda3\envs\stapl3d\lib\site-packages\stapl3d\segmentation\zipping.py:197, in Zipp3r.relabel(self, **kwargs) 194 self._gather_maxlabels(self.ids_labels) 196 with multiprocessing.Pool(processes=self._n_workers) as pool: --> 197 pool.starmap(self._relabel_blocks, arglist)

File ~\anaconda3\envs\stapl3d\lib\multiprocessing\pool.py:372, in Pool.starmap(self, func, iterable, chunksize) 366 def starmap(self, func, iterable, chunksize=None): 367 ''' 368 Like map() method but the elements of the iterable are expected to 369 be iterables as well and will be unpacked as arguments. Hence 370 func and (a, b) becomes func(a, b). 371 ''' --> 372 return self._map_async(func, iterable, starmapstar, chunksize).get()

File ~\anaconda3\envs\stapl3d\lib\multiprocessing\pool.py:771, in ApplyResult.get(self, timeout) 769 return self._value 770 else: --> 771 raise self._value

File ~\anaconda3\envs\stapl3d\lib\multiprocessing\pool.py:125, in worker() 123 job, i, func, args, kwds = task 124 try: --> 125 result = (True, func(*args, **kwds)) 126 except Exception as e: 127 if wrap_exception and func is not _helper_reraises_exception:

File ~\anaconda3\envs\stapl3d\lib\multiprocessing\pool.py:51, in starmapstar() 50 def starmapstar(args): ---> 51 return list(itertools.starmap(args[0], args[1]))

File ~\anaconda3\envs\stapl3d\lib\site-packages\stapl3d\segmentation\zipping.py:226, in _relabel_blocks() 223 data[~mask] += maxlabel 225 outpath =f'{filepath}/{self.ods_labels}' --> 226 mo = write_output(outpath, data, props=im.get_props(), imtype='Label') 228 try: 229 maxlabel_block = im.ds.attrs['maxlabel']

File ~\anaconda3\envs\stapl3d\lib\site-packages\stapl3d\segmentation\zipping.py:836, in write_output() 834 mo = Image(outpath, **props) 835 mo.create() --> 836 mo.write(out) 838 return mo

File ~\anaconda3\envs\stapl3d\lib\site-packages\stapl3d__init__.py:1460, in write() 1450 slices = self.slices 1452 formats = {'.h5': self.h5_write, 1453 '.ims': self.ims_write, 1454 '.bdv': self.bdv_write, (...) 1457 '.tifs': self.tifs_write, 1458 '.dat': self.dat_write} -> 1460 formats[self.format](data, slices)

File ~\anaconda3\envs\stapl3d\lib\site-packages\stapl3d__init__.py:1465, in h5_write() 1462 def h5_write(self, data, slices): 1463 """Write data to a hdf5 dataset.""" -> 1465 self.write_block(self.ds, data, slices)

File ~\anaconda3\envs\stapl3d\lib\site-packages\stapl3d__init__.py:1676, in write_block() 1674 ds[slices[0], slices[1]] = data 1675 elif ndim == 3: -> 1676 ds[slices[0], slices[1], slices[2]] = data 1677 elif ndim == 4: 1678 ds[slices[0], slices[1], slices[2], slices[3]] = data

File h5py_objects.pyx:54, in h5py._objects.with_phil.wrapper()

File h5py_objects.pyx:55, in h5py._objects.with_phil.wrapper()

File ~\anaconda3\envs\stapl3d\lib\site-packages\h5py_hl\dataset.py:982, in setitem() 980 mspace = h5s.create_simple(selection.expand_shape(mshape)) 981 for fspace in selection.broadcast(mshape): --> 982 self.id.write(mspace, fspace, val, mtype, dxpl=self._dxpl)

File h5py_objects.pyx:54, in h5py._objects.with_phil.wrapper()

File h5py_objects.pyx:55, in h5py._objects.with_phil.wrapper()

File h5py\h5d.pyx:232, in h5py.h5d.DatasetID.write()

File h5py_proxy.pyx:114, in h5py._proxy.dset_rw()

OSError: Can't write data (inflate() failed)

michielkleinnijenhuis commented 1 year ago

Hi Chad,

I'm sorry that you experience some trouble during the demos. From the looks of the error message it appears one of the files got corrupted. I think this sometimes happens when the file is open in another program or process while it is being written to. As it is a demo, really the easiest fix here is to delete the hdf5-files in the ‘blocks’ directory and start over the demo. Please let me know if the issue persists or if you encounter any others.

Best, Michiel