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

Python 3.7 issue creating Tiff sequences and ROI object #254

Open
Saksham20 opened this issue Feb 18, 2020 · 0 comments
Open

Python 3.7 issue creating Tiff sequences and ROI object #254

Saksham20 opened this issue Feb 18, 2020 · 0 comments

Comments

@Saksham20
Copy link

Saksham20 commented Feb 18, 2020

Similar to #253,
With the example dataset for TIFF in the repo, when I create a sequence object like:

sequences_tiff = [sima.Sequence.join(sima.Sequence.create('TIFF', base_dir + 'example_Ch1.tif'),sima.Sequence.create('TIFF', base_dir + 'example_Ch2.tif'))]

I get an error(works in python <3.7):

[Command: python -u '$\py2_sima.py']
Traceback (most recent call last):
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\sequence.py", line 631, in __iter__
    for _ in range(self._num_planes)], 0)
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\sequence.py", line 631, in <listcomp>
    for _ in range(self._num_planes)], 0)
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\sequence.py", line 629, in <listcomp>
    for _ in range(self._num_channels)],
StopIteration

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

Traceback (most recent call last):
  File "$\py2_sima.py", line 34, in <module>
    sequences_tiff = [sima.Sequence.join(sima.Sequence.create('TIFF', base_dir + 'example_Ch1.tif'),sima.Sequence.create('TIFF', base_dir + 'example_Ch2.tif'))]
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\sequence.py", line 276, in join
    return _Joined_Sequence(sequences)
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\sequence.py", line 966, in __init__
    shape = seq.shape[:-1]
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\sequence.py", line 199, in shape
    return (len(self),) + self._get_frame(0).shape
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\sequence.py", line 680, in __len__
    self._len = sum(1 for _ in self)
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\sequence.py", line 680, in <genexpr>
    self._len = sum(1 for _ in self)
RuntimeError: generator raised StopIteration
[Finished in 3.795s]

I am however able to create sequence objects for numpy and hdf5:

cycle1_channel1 = np.random.rand(100, 1, 128, 128, 1)
cycle1_channel2 = np.random.rand(100, 1, 128, 128, 1)
cycle2_channel1 = np.random.rand(100, 1, 128, 128, 1)
cycle2_channel2 = np.random.rand(100, 1, 128, 128, 1)
sequences_np = [sima.Sequence.join(
                  sima.Sequence.create('ndarray', cycle1_channel1),
                  sima.Sequence.create('ndarray', cycle1_channel2)),
                  sima.Sequence.join(
                  sima.Sequence.create('ndarray', cycle2_channel1),
                  sima.Sequence.create('ndarray', cycle2_channel2))]`
sequences_hdf5 = [sima.Sequence.create('HDF5', base_dir + 'example.h5', 'yxt')]

But, with np object when I create a ROI object it thrown an error:

segmentation_approach = sima.segment.PlaneCA1PC(
    channel='Green',
    num_pcs=30,
    max_dist=(3, 6),
    spatial_decay=(3, 6),
    cut_max_pen=0.10,
    cut_min_size=50,
    cut_max_size=150,
    x_diameter=14,
    y_diameter=7,
    circularity_threhold=.5,
    min_roi_size=20,
    min_cut_size=40
)

rois = dataset_corr_np.segment(segmentation_approach, label='auto_ROIs')

ERROR:

[Command: python -u '$\py3_sima.py']
Estimating model parameters.
Estimating displacements for cycle  0
Estimating displacements for cycle  1
Traceback (most recent call last):
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\segment\oPCA.py", line 249, in __iter__
    raise StopIteration
StopIteration

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

Traceback (most recent call last):
  File "$\py3_sima.py", line 95, in <module>
    rois = dataset_corr_np.segment(segmentation_approach, label='auto_ROIs')
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\imaging.py", line 913, in segment
    rois = strategy.segment(self)
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\segment\segment.py", line 46, in segment
    rois = self._segment(dataset)
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\segment\segment.py", line 88, in checked_func
    return func(self, dataset)
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\segment\ca1pc.py", line 276, in _segment
    return self._normcut_method.segment(dataset)
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\segment\segment.py", line 46, in segment
    rois = self._segment(dataset)
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\segment\segment.py", line 88, in checked_func
    return func(self, dataset)
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\segment\normcut.py", line 500, in _segment
    affinity = params['affinity_method'].calculate(dataset)
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\segment\normcut.py", line 406, in calculate
    self._setup(dataset)
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\segment\ca1pc.py", line 162, in _setup
    super(AffinityMatrixCA1PC, self)._setup(dataset)
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\segment\normcut.py", line 403, in _setup
    self._correlations = self._calculate_correlations(dataset)
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\segment\normcut.py", line 393, in _calculate_correlations
    num_pcs=self._params['num_pcs'], verbose=self._params['verbose'])
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\segment\normcut.py", line 307, in _offset_corrs
    verbose=verbose)
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\segment\oPCA.py", line 301, in dataset_opca
    DatasetIterable(dataset, ch), num_pcs=num_pcs, verbose=verbose)
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\segment\oPCA.py", line 109, in EM_oPCA
    _opca._Z_update(Z, U, data)
  File "sima\segment\_opca.pyx", line 84, in sima.segment._opca._Z_update
RuntimeError: generator raised StopIteration
Exception ignored in: <function _Sequence_HDF5.__del__ at 0x00000000107FB798>
Traceback (most recent call last):
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\sima\sequence.py", line 817, in __del__
  File "$\AppData\Local\Programs\Python\Python37\lib\site-packages\h5py\_hl\files.py", line 431, in close
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py\h5f.pyx", line 267, in h5py.h5f.get_obj_ids
  File "h5py\h5i.pyx", line 40, in h5py.h5i.wrap_identifier
ImportError: sys.meta_path is None, Python is likely shutting down
[Finished in 26.508s]
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

1 participant