SchmollerLab / Cell_ACDC

A Python GUI-based framework for segmentation, tracking and cell cycle annotations of microscopy data
BSD 3-Clause "New" or "Revised" License
134 stars 22 forks source link

opening blobs.tif fails #268

Open haesleinhuepf opened 1 year ago

haesleinhuepf commented 1 year ago

Description:

Hi,

I just installed CellACDC and tried to open blobs.tif (the ImageJ example 2D image). After drag&drop, I received this error:

Traceback (most recent call last):
  File "C:\Users\rober\miniconda3\envs\acdc\lib\site-packages\cellacdc\__init__.py", line 108, in inner_function
    result = func(self, *args, **kwargs)
  File "C:\Users\rober\miniconda3\envs\acdc\lib\site-packages\cellacdc\gui.py", line 18237, in _openFolder
    ch_name_selector.get_available_channels(filenames, exp_path)
  File "C:\Users\rober\miniconda3\envs\acdc\lib\site-packages\cellacdc\prompts.py", line 145, in get_available_channels
    isBasenamePresent = myutils.checkDataIntegrity(filenames, images_path)
  File "C:\Users\rober\miniconda3\envs\acdc\lib\site-packages\cellacdc\myutils.py", line 344, in checkDataIntegrity
    char = filenames[0][:2]
IndexError: list index out of range

2023-02-12_12-20-49_gui_stdout.log 2023-02-12_12-20-27_main_stdout.log

Way to reproduce:

Start CellACDC Click "Test segmentation on my data" Drag & drop blobs.tif

blobs.zip

Note: I did the installation like this:

mamba create --name acdc python=3.9 devbio-napari

conda activate acdc 

pip install cellacdc

acdc

Let me know if I can help tracing the issue down!

Best, Robert

(Optional) Link to data to reproduce error:

No response

Terminal output:

(acdc) C:\Users\rober>acdc
Importing modules...
Importing GUI modules...
Launching application...
**********************************************
Welcome to Cell-ACDC v1.2.5!
**********************************************
----------------------------------------------
NOTE: If application is not visible, it is probably minimized
or behind some other open window.
----------------------------------------------
Opening GUI...
Initializing GUI v1.2.5...
Initiliazing profilers...
GUI ready.
Traceback (most recent call last):
  File "C:\Users\rober\miniconda3\envs\acdc\lib\site-packages\cellacdc\help\welcome.py", line 893, in openGUIsingleImage
    self.mainWin.guiWin.openFile()
AttributeError: 'mainWin' object has no attribute 'guiWin'
Dragged and dropped path "C:/structure/data/blobs.tif"
Opening FILE "C:/structure/data/blobs.tif"
Loading from C:/structure/data\20230212_122108_acdc\Images
Traceback (most recent call last):
  File "C:\Users\rober\miniconda3\envs\acdc\lib\site-packages\cellacdc\__init__.py", line 108, in inner_function
    result = func(self, *args, **kwargs)
  File "C:\Users\rober\miniconda3\envs\acdc\lib\site-packages\cellacdc\gui.py", line 18237, in _openFolder
    ch_name_selector.get_available_channels(filenames, exp_path)
  File "C:\Users\rober\miniconda3\envs\acdc\lib\site-packages\cellacdc\prompts.py", line 145, in get_available_channels
    isBasenamePresent = myutils.checkDataIntegrity(filenames, images_path)
  File "C:\Users\rober\miniconda3\envs\acdc\lib\site-packages\cellacdc\myutils.py", line 344, in checkDataIntegrity
    char = filenames[0][:2]
IndexError: list index out of range
Traceback (most recent call last):
  File "C:\Users\rober\miniconda3\envs\acdc\lib\site-packages\cellacdc\__init__.py", line 108, in inner_function
    result = func(self, *args, **kwargs)
  File "C:\Users\rober\miniconda3\envs\acdc\lib\site-packages\cellacdc\gui.py", line 18237, in _openFolder
    ch_name_selector.get_available_channels(filenames, exp_path)
  File "C:\Users\rober\miniconda3\envs\acdc\lib\site-packages\cellacdc\prompts.py", line 145, in get_available_channels
    isBasenamePresent = myutils.checkDataIntegrity(filenames, images_path)
  File "C:\Users\rober\miniconda3\envs\acdc\lib\site-packages\cellacdc\myutils.py", line 344, in checkDataIntegrity
    char = filenames[0][:2]
IndexError: list index out of range
Lazy loader paused.
====================================
Cell-ACDC is in error state. Please restart.
====================================

Version information:

(acdc) C:\Users\rober>python
Python 3.9.16 | packaged by conda-forge | (main, Feb  1 2023, 21:28:38) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys; print(sys.version)
3.9.16 | packaged by conda-forge | (main, Feb  1 2023, 21:28:38) [MSC v.1929 64 bit (AMD64)]
>>> import platform; print(platform.platform())
Windows-10-10.0.19045-SP0
>>> import cellacdc; print(f'Cell-ACDC version: {cellacdc.__version__}')
Cell-ACDC version: 1.2.5
>>>
ElpadoCan commented 1 year ago

Hi Robert,

I'm sorry to hear you are having these issues. I fixed it now on the developer version, but you don't need the fix to load that image file, let me explain.

The way Cell-ACDC expects the data is with the images (one image per channel for example) in a folder called Images. In your case, the image file was in a different folder and in that case, Cell-ACDC creates the Images folder for you and copies the file into it. However, there was a bug in the copying step. Now, in the folder where you have the blobs.tif file, you should also have a new folder that starts with a timestamp and ends with _acdc. Inside there is the Images folder which instead of containing the blobs.tif file is empty. If you copy (or move) the image file inside that folder you will be able to load it. You can also just put the blobs.tif file in any folder called Images, you don't need the parent folder ending with _acdc.

The other option is that you install from source instead of from PyPi. In any case, I will soon release the fix, since now that I think about it, new users will start in the same way you started. I will also add more explanation about it.

In the long run, if you plan to use Cell-ACDC for image data analysis, I recommend structuring the data in the expected way. We have a module to automatically create the data structure from raw microscopy files (it uses python-bioformats). In the user manual, there is a dedicated section right after the installation instructions.

The data structure is rather "rigid", but it allows Cell-ACDC to perform many actions automatically. Most of the utilities, for example, can perform batch processing of multiple images if the data is structured in the expected way. Additionally, the Images folder, allows the user to select the folder instead of a specific image file. Cell-ACDC can then read the channel names and prompt the user to select which channel to load.

Note that the image files can be any 2D, 3D (z-stacks or 2D over time), or 4D (z-stacks over time) data in TIFF format. We plan to start supporting .h5 files soon to allow lazy loading. Let me know how it goes, thanks!

And thank you very much for spotting this bug (and for the detailed bug report, you allowed me to fix the bug in a second).

Best, Francesco

haesleinhuepf commented 1 year ago

Awesome thanks for the light speed response @ElpadoCan .

In the long run, if you plan to use Cell-ACDC for image data analysis, I recommend structuring the data in the expected way.

I'm not so much analysing images myself, I develop tools and workflows for people who want to analyse images themselves. I deploy my tools e.g. as Fiji/Napari (and maybe Cell-ACDC) plugins and/or Python packages. But thanks again for the hint. I'll tell my collaborators then. It's a good exercise to structure / manage data anyway.

Thanks again! Feel free to close this issue. 🌞

Best, Robert

ElpadoCan commented 1 year ago

Oh yeah I know your tools 😁. The stackview is amazing.

Wow, I'm excited to hear you are considering further development with Cell-ACDC! Let me know if there is anything I can help with!

If you don't mind I will keep the issue open until I release the fix we discussed.

Cheers Francesco

ElpadoCan commented 1 year ago

Hi Robert,

I just released v1.2.6 with a fix for this issue. When the user loads an image that is not in a Images folder, Cell-ACDC will display a warning explaining the situation and giving the user the possibility to let Cell-ACDC automatically create the folder and copy or move the file, or abort the process.

To update, activate the acdc environment and run the command pip install --upgrade cellacdc.

Let me know if it works, thanks!

Cheers, Francesco

github-actions[bot] commented 1 year ago

Hi there, I'm the Cell-ACDC bot :wave:. This issue had no activity for more than 180 days. For now, we have marked it as "inactive" until there is some new activity. If this issue was not solved yet, unfortunately we haven't had the time to implement it or it requires more discussion. Note that it doesn't mean it has been ignored, but a little reminder from your side would help :D. Feel free to reach out to us here or on our forum. If you think that this issue is no longer relevant, you may close it by yourself. In any case, we apologise for the inconvenience and we thank you for your patience and contributions so far!