marcnol / pyHiM

Multiplexed DNA-FISH data analysis pipeline
GNU Lesser General Public License v3.0
4 stars 2 forks source link

segmentSources3D bug related to network name #163

Closed marcnol closed 1 year ago

marcnol commented 1 year ago

When I run pyHiM.py -C segmentSources3D

in /mnt/grey/DATA/rawData_2023/Experiment_78_Marie_Christel_Julian_Droso_Late_embryos_confocal_2/Analysis/001

I get the following error, WHICH DOES NOT APPEAR IN THE MASTER branch.

there seems to be an error with reading the dictionary as here it should be looking for the network for the 3D-PSFs but instead is looking for a network for the 2D segmentation of DAPI !

> Loading model stardist_nc14_nrays:64_epochs:40_grid:2 from /mnt/grey/DATA/users/marcnol/models/StarDist3D/training3Dbarcodes/models...
Traceback (most recent call last):
  File "/home/marcnol/Repositories/pyHiM/src/pyHiM.py", line 154, in <module>
    main()
  File "/home/marcnol/Repositories/pyHiM/src/pyHiM.py", line 112, in main
    pipe.segment_sources_3d(current_param, label)
  File "/home/marcnol/Repositories/pyHiM/src/core/function_caller.py", line 136, in segment_sources_3d
    _segment_sources_3d.segment_sources_3d()
  File "/home/marcnol/Repositories/pyHiM/src/imageProcessing/segmentSources3D.py", line 604, in segment_sources_3d
    self.segment_sources_3d_in_folder()
  File "/home/marcnol/Repositories/pyHiM/src/imageProcessing/segmentSources3D.py", line 537, in segment_sources_3d_in_folder
    self.segment_sources_3d_file(filename_to_process)
  File "/home/marcnol/Repositories/pyHiM/src/imageProcessing/segmentSources3D.py", line 327, in segment_sources_3d_file
    _, segmented_image_3d = self._segment_3d_volumes(image_3d_aligned)
  File "/home/marcnol/Repositories/pyHiM/src/imageProcessing/segmentSources3D.py", line 226, in _segment_3d_volumes
    binary, segmented_image_3d = _segment_3d_volumes_stardist(
  File "/home/marcnol/Repositories/pyHiM/src/imageProcessing/segmentMasks.py", line 991, in _segment_3d_volumes_stardist
    model = StarDist3D(None, name=model_name, basedir=model_dir)
  File "/home/marcnol/anaconda3/envs/pyHiM39/lib/python3.9/site-packages/stardist/models/model3d.py", line 329, in __init__
    super().__init__(config, name=name, basedir=basedir)
  File "/home/marcnol/anaconda3/envs/pyHiM39/lib/python3.9/site-packages/stardist/models/base.py", line 220, in __init__
    super().__init__(config=config, name=name, basedir=basedir)
  File "/home/marcnol/anaconda3/envs/pyHiM39/lib/python3.9/site-packages/csbdeep/models/base_model.py", line 106, in __init__
    self._set_logdir()
  File "/home/marcnol/anaconda3/envs/pyHiM39/lib/python3.9/site-packages/csbdeep/models/base_model.py", line 32, in wrapper
    return f(*args, **kwargs)
  File "/home/marcnol/anaconda3/envs/pyHiM39/lib/python3.9/site-packages/csbdeep/models/base_model.py", line 145, in _set_logdir
    raise FileNotFoundError("config file doesn't exist: %s" % str(config_file.resolve()))
FileNotFoundError: config file doesn't exist: /mnt/grey/DATA/users/marcnol/models/StarDist3D/training3Dbarcodes/models/stardist_nc14_nrays:64_epochs:40_grid:2/config.json
XDevos commented 1 year ago

In your infoList.json, the parameter "stardist_network3D" is missing for the common and barcode section. So, pyHiM cherry-pick this parameter inside the standard parameters (branch:development; src/core/parameters.py: line 379) and the value is stardist_nc14_nrays:64_epochs:40_grid:2, which bug your run.

But I don't understand that it works on master... Did you pull the master recently? Because before this commit fcfaf9f, it was possible that your run was working thanks to a bug, but it's an old commit. I don't see anything else.

marcnol commented 1 year ago

mmm. I don't understand why the master branch is working... It maybe a good idea to just exit in this instance as otherwise it will use very likely the wrong network?

XDevos commented 1 year ago

Should we remove the parameter "stardist_network3D" from the strandard parameters or add line of codes to check this ?

marcnol commented 1 year ago

I am thinking that maybe we need a infoList checkup routine that runs from the beginning and verifies that each expected parameter is there and when it will be replaced by a default it sends a warning message. This at least will allow us to spot if there is anything unexpected... Then we could stop execution for some very important parameters instead of replacing them by a default.?

XDevos commented 1 year ago

Pull request #167

When pyHiM start, checks are made on the infoList.json parameters: