guiwitz / MorphoDynamics

A Python package for tracking the deformation of biological cells.
https://guiwitz.github.io/MorphoDynamics/mydocs/Introduction.html
BSD 3-Clause "New" or "Revised" License
6 stars 3 forks source link

InterfaceFigureTabs cannot handle whitespaces #23

Closed mheydasch closed 2 years ago

mheydasch commented 3 years ago

After running the Morpho_segmentation pipeline I get following error when trying to load it in the InterfaceFigureTabs notebook.

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
~\miniconda3\envs\morphodynamics\lib\site-packages\morphodynamics\plots\ui_outputs.py in load_data(self, b)
     70         with self.wimage_out:
     71             display(self.wimage.interface)
---> 72         self.wimage.show_segmentation()
     73         self.create_ui()
     74 

~\miniconda3\envs\morphodynamics\lib\site-packages\morphodynamics\plots\ui_wimage.py in show_segmentation(self, change)
    141                     "window_k_" + str(t) + ".pkl",
    142                 )
--> 143                 window = pickle.load(open(name, "rb"))
    144 
    145                 name = os.path.join(

FileNotFoundError: [Errno 2] No such file or directory: 'D:\\Max\\Ilastik\\1B2_DLC_05_1_w13TIRF GFP_s4movie\\ouput\\segmented\\window_k_0.pkl'

I suspect that it cannot handle the whitespace in the folder name. Unfortunately when I change the folder name to include an underscore instead I get the error

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
~\miniconda3\envs\morphodynamics\lib\site-packages\morphodynamics\plots\ui_outputs.py in load_data(self, b)
     66     def load_data(self, b=None):
     67 
---> 68         self.param, self.res, self.data = load_alldata(self.expdir, load_results=True)
     69         self.wimage = Wimage(self.param, self.data, self.res)
     70         with self.wimage_out:

~\miniconda3\envs\morphodynamics\lib\site-packages\morphodynamics\utils.py in load_alldata(folder_path, load_results, param)
     75             step=param.step,
     76             bad_frames=param.bad_frames,
---> 77             max_time=param.max_time,
     78         )
     79 

~\miniconda3\envs\morphodynamics\lib\site-packages\morphodynamics\dataset.py in __init__(self, expdir, channel_name, bad_frames, step, max_time, data_type, morpho_name, signal_name)
     73             step=step,
     74             max_time=max_time,
---> 75             data_type=data_type,
     76         )
     77         self.morpho_name = morpho_name

~\miniconda3\envs\morphodynamics\lib\site-packages\microfilm\dataset\dataset.py in __init__(self, expdir, channel_name, bad_frames, step, max_time, data_type)
    228         )
    229 
--> 230         self.initialize()
    231 
    232     def initialize(self):

~\miniconda3\envs\morphodynamics\lib\site-packages\microfilm\dataset\dataset.py in initialize(self)
    234         # if no channel names are provided, consider all folders as channel
    235         if self.channel_name is None:
--> 236             self.channel_name = self.find_files(self.expdir, check_time=False)
    237         if len(self.channel_name) == 0:
    238             raise Exception(f"Sorry, no tif/tiff/TIF/TIFF files found in {self.expdir}")

~\miniconda3\envs\morphodynamics\lib\site-packages\microfilm\dataset\dataset.py in find_files(self, folderpath, check_time)
     90         """Given a folder, find all tif files contained in it and try to sort as time-lapse"""
     91 
---> 92         image_names = np.array(findfiles('*.tif', folderpath) + findfiles('*.tiff', folderpath))
     93         if len(image_names) > 0:
     94 

~\miniconda3\envs\morphodynamics\lib\site-packages\microfilm\dataset\dataset.py in findfiles(which, where)
    458     # TODO: recursive param with walk() filtering
    459     rule = re.compile(fnmatch.translate(which), re.IGNORECASE)
--> 460     return [name for name in os.listdir(where) if rule.match(name)]

FileNotFoundError: [WinError 3] The system cannot find the path specified: 'D:\\Max\\Ilastik\\1B2_DLC_05_1_w13TIRF GFP_s4movie'

I guess the original folder name is saved in one of the files, therefore post analysis renaming does not solve the issue.

guiwitz commented 3 years ago

Yes indeed, white spaces as well as symbols like % or & should NEVER EVER be used for folder naming. That's going to create trouble for many software, not just this one. All the analysis parameters are indeed saved in the Parameters.yml file. This is a human readable text file, so you should be able to fix path names there (for analysis_folder, data_folder and seg_folder).

As mentioned in the other issue, if you encounter further problems, just send me an example dataset so that I can test it myself.