aelefebv / nellie

Nellie: Automated organelle segmentation, tracking, and hierarchical feature extraction in 2D/3D live-cell microscopy
Other
30 stars 4 forks source link

Cannot change expected structure size within GUI #27

Open schienstockd opened 1 month ago

schienstockd commented 1 month ago

Hello,

I tried to run the preprocessing on a 2D time image and get the following output. Am I doing anything wrong?

2024-08-06 | 13:01:31.337 :: WARNING:root:[__init__.py:22] :: GPU packages not detected, running via CPU.
2024-08-06 | 13:01:32.833 :: DEBUG:matplotlib:[__init__.py:337] :: matplotlib data path: /Users/Dominik/Library/r-miniconda/envs/r-cecelia-env/lib/python3.9/site-packages/matplotlib/mpl-data
2024-08-06 | 13:01:32.842 :: DEBUG:matplotlib:[__init__.py:337] :: CONFIGDIR=/Users/Dominik/.matplotlib
2024-08-06 | 13:01:32.845 :: DEBUG:matplotlib:[__init__.py:1498] :: interactive is False
2024-08-06 | 13:01:32.846 :: DEBUG:matplotlib:[__init__.py:1499] :: platform is darwin
2024-08-06 | 13:01:32.874 :: DEBUG:matplotlib:[__init__.py:337] :: CACHEDIR=/Users/Dominik/.matplotlib
2024-08-06 | 13:01:32.880 :: DEBUG:matplotlib.font_manager:[font_manager.py:1574] :: Using fontManager instance from /Users/Dominik/.matplotlib/fontlist-v330.json
2024-08-06 | 13:01:33.215 :: DEBUG:in_n_out:[_store.py:960] :: Rebuilding processor map cache
2024-08-06 | 13:01:33.216 :: DEBUG:in_n_out:[_store.py:576] :: Invoking processors on result (<nellie_napari.nellie_loader.NellieLoader object at 0x168008b80>, 'Nellie (Nellie)') from function 'Store.inject.<locals>._inner.<locals>._exec'
2024-08-06 | 13:01:33.217 :: DEBUG:in_n_out:[_store.py:581] ::   P: <function _add_plugin_dock_widget at 0x15d40bee0>
2024-08-06 13:01:43.171 python3.9[40556:2686672] -[NSNull length]: unrecognized selector sent to instance 0x7ff84d1c10c0
2024-08-06 13:01:43.171 python3.9[40556:2686672] Exception calling directoryDidChange: on delegate <QNSOpenSavePanelDelegate: 0x600002aa0af0> exception=-[NSNull length]: unrecognized selector sent to instance 0x7ff84d1c10c0
2024-08-06 13:01:43.172 python3.9[40556:2686672] -[NSNull length]: unrecognized selector sent to instance 0x7ff84d1c10c0
2024-08-06 13:01:43.172 python3.9[40556:2686672] Exception calling directoryDidChange: on delegate <QNSOpenSavePanelDelegate: 0x600002aa0af0> exception=-[NSNull length]: unrecognized selector sent to instance 0x7ff84d1c10c0
2024-08-06 13:01:44.852 python3.9[40556:2686672] -[NSNull length]: unrecognized selector sent to instance 0x7ff84d1c10c0
2024-08-06 13:01:44.852 python3.9[40556:2686672] Exception calling directoryDidChange: on delegate <QNSOpenSavePanelDelegate: 0x600002aa0af0> exception=-[NSNull length]: unrecognized selector sent to instance 0x7ff84d1c10c0
2024-08-06 13:01:44.903 python3.9[40556:2686672] -[NSNull length]: unrecognized selector sent to instance 0x7ff84d1c10c0
2024-08-06 13:01:44.903 python3.9[40556:2686672] Exception calling directoryDidChange: on delegate <QNSOpenSavePanelDelegate: 0x600002aa0af0> exception=-[NSNull length]: unrecognized selector sent to instance 0x7ff84d1c10c0
2024-08-06 | 13:02:03.292 :: WARNING:root:[im_info.py:159] :: No ZResolution tag found.
2024-08-06 | 13:02:03.294 :: WARNING:root:[im_info.py:195] :: File is an ImageJ type, but has weird metadata, found dimension sizes: {'X': 1.0, 'Y': 1.0, 'Z': None, 'T': None}
2024-08-06 | 13:02:03.295 :: WARNING:root:[im_info.py:221] :: No FrameRate tag found.
2024-08-06 | 13:02:03.299 :: INFO:root:[im_info.py:105] :: Found existing OME TIFF file at /Volumes/FunIVCM_Examples/nellie_output/LD_inf_P_final-ch0-ome.ome.tif.

INFO: Axes resolutions not set.
INFO: Selected file: LD_inf_P_final.tif
INFO: Please enter a valid number
INFO: Please enter a valid number

2024-08-06 | 13:02:09.611 :: INFO:root:[im_info.py:105] :: Found existing OME TIFF file at /Volumes/FunIVCM_Examples/nellie_output/LD_inf_P_final-ch0-ome.ome.tif.
2024-08-06 | 13:02:09.634 :: DEBUG:root:[general.py:5] :: Reshaping image.
2024-08-06 | 13:02:09.634 :: DEBUG:root:[general.py:19] :: 6 timepoints found, shape is now (6, 643, 615).
2024-08-06 | 13:02:15.173 :: INFO:root:[filtering.py:265] :: Running frangi filter.
2024-08-06 | 13:02:15.174 :: DEBUG:root:[filtering.py:53] :: Allocating memory for frangi filter.
2024-08-06 | 13:02:15.183 :: DEBUG:root:[general.py:5] :: Reshaping image.
2024-08-06 | 13:02:15.184 :: DEBUG:root:[general.py:19] :: 6 timepoints found, shape is now (6, 643, 615).
2024-08-06 | 13:02:15.191 :: DEBUG:root:[im_info.py:323] :: Saving axes as TYX

INFO: Nellie in running: Preprocessing

2024-08-06 | 13:02:15.507 :: DEBUG:root:[filtering.py:70] :: Setting to sigma values.
2024-08-06 | 13:02:15.508 :: DEBUG:root:[filtering.py:81] :: Calculated sigma step size = -0.03333333333333334. Sigmas = []
2024-08-06 | 13:02:15.509 :: INFO:root:[filtering.py:201] :: Running frangi filter on t=0.
Traceback (most recent call last):
  File "/Users/Dominik/Library/r-miniconda/envs/r-cecelia-env/lib/python3.9/site-packages/superqt/utils/_qthreading.py", line 613, in reraise
    raise e
  File "/Users/Dominik/Library/r-miniconda/envs/r-cecelia-env/lib/python3.9/site-packages/superqt/utils/_qthreading.py", line 175, in run
    result = self.work()
  File "/Users/Dominik/Library/r-miniconda/envs/r-cecelia-env/lib/python3.9/site-packages/superqt/utils/_qthreading.py", line 354, in work
    return self._func(*self._args, **self._kwargs)
  File "/Users/Dominik/Library/r-miniconda/envs/r-cecelia-env/lib/python3.9/site-packages/nellie_napari/nellie_processor.py", line 172, in _run_preprocessing
    preprocessing.run()
  File "/Users/Dominik/Library/r-miniconda/envs/r-cecelia-env/lib/python3.9/site-packages/nellie/segmentation/filtering.py", line 269, in run
    self._run_filter(mask=mask)
  File "/Users/Dominik/Library/r-miniconda/envs/r-cecelia-env/lib/python3.9/site-packages/nellie/segmentation/filtering.py", line 252, in _run_filter
    frangi_frame = self._mask_volume(frangi_frame)
  File "/Users/Dominik/Library/r-miniconda/envs/r-cecelia-env/lib/python3.9/site-packages/nellie/segmentation/filtering.py", line 226, in _mask_volume
    frangi_threshold = xp.percentile(frangi_frame[frangi_frame > 0], 1)
  File "/Users/Dominik/Library/r-miniconda/envs/r-cecelia-env/lib/python3.9/site-packages/numpy/lib/function_base.py", line 4283, in percentile
    return _quantile_unchecked(
  File "/Users/Dominik/Library/r-miniconda/envs/r-cecelia-env/lib/python3.9/site-packages/numpy/lib/function_base.py", line 4555, in _quantile_unchecked
    return _ureduce(a,
  File "/Users/Dominik/Library/r-miniconda/envs/r-cecelia-env/lib/python3.9/site-packages/numpy/lib/function_base.py", line 3823, in _ureduce
    r = func(a, **kwargs)
  File "/Users/Dominik/Library/r-miniconda/envs/r-cecelia-env/lib/python3.9/site-packages/numpy/lib/function_base.py", line 4722, in _quantile_ureduce_func
    result = _quantile(arr,
  File "/Users/Dominik/Library/r-miniconda/envs/r-cecelia-env/lib/python3.9/site-packages/numpy/lib/function_base.py", line 4831, in _quantile
    slices_having_nans = np.isnan(arr[-1, ...])
IndexError: index -1 is out of bounds for axis 0 with size 0
2024-08-06 | 13:02:15.526 :: DEBUG:root:[general.py:5] :: Reshaping image.
2024-08-06 | 13:02:15.527 :: DEBUG:root:[general.py:19] :: 6 timepoints found, shape is now (6, 643, 615).
aelefebv commented 1 month ago

Hello! Looks like maybe your metadata wasn't correct (from the text "2024-08-06 | 13:02:03.294 :: WARNING:root:[im_info.py:195] :: File is an ImageJ type, but has weird metadata, found dimension sizes: {'X': 1.0, 'Y': 1.0, 'Z': None, 'T': None}", which led to weird parameters being chosen during filtering. Are your pixels really 1x1 micron? If no, change these to the correct values before running. If yes, I would suggest imaging at a higher resolution.

Let me know if this works!

ps. If you did change it to the correct dimensions, please let me know what they are, and email me (austin.e.lefebvre+nellie@gmail.com) your file, so i can figure out what's going on.

schienstockd commented 1 month ago

I was hoping to test this framework for a different kind of image and see what happens. It's confocal images from human cornea. The resolution is that low though ..

I emailed you a file. Let me know if that is totally out of your scope as your framework seems to be focussed on organelles and probably higher resolution images.

aelefebv commented 1 month ago

Ahhh totally makes sense! I'm planning on adding an advanced section to tweak the "expected structure size" so that anyone (who knows what they're doing) can mess with the parameters for cases like this. If you're familiar with Python though, you should be able to mess with the parameters within this file (https://github.com/aelefebv/nellie/blob/main/nellie/segmentation/filtering.py) and specifically change the "min_radius_um" and "max_radius_um" parameters.

In the meantime though, I'll keep this issue open so I remember to add that advanced section into the GUI.