Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 19054

AttributeError: 'WindowsPath' object has no attribute 'endswith' -- WindowsPath is correct and contains files that endswith .tif

$
0
0

I'm stuck at the following error message:

AttributeError: 'WindowsPath' object has no attribute 'endswith'

Here is a part of the code:

im_path = Path("C:/Users/zeiss/_Python/fastddm-main/tests/test-imgs/confocal/")images = np.array([fddm.tiff2numpy(im) for im in sorted(im_path.iterdir()) if im.name.endswith(".tif")])images = np.ascontiguousarray(images)images.shape

And the error message:

AttributeError                            Traceback (most recent call last)Cell In[48], line 3      1 # read image files      2 im_path = Path("C:/Users/zeiss/_Python/fastddm-main/tests/test-imgs/confocal/")----> 3 images = np.array([fddm.tiff2numpy(im) for im in sorted(im_path.iterdir()) if im.name.endswith(".tif")])      4 images = np.ascontiguousarray(images)      5 images.shapeFile c:\Users\zeiss\AppData\Local\Programs\Python\Python312\Lib\site-packages\fastddm\_utils.py:60, in tiff2numpy(src, seq, color_seq, input_order)     23 def tiff2numpy(     24     src: str,     25     seq: Optional[Sequence[int]] = None,     26     color_seq: Optional[Sequence[int]] = None,     27     input_order: Optional[str] = None,     28 ) -> np.ndarray:     29     """Read a TIFF file (or a sequence inside a multipage TIFF) and return it as a numpy array.     30      31     The tiff file is assumed to be of the shape (T,Y,X). If `color_seq` is given, the order   (...)     58         Coordinate convention is (T,Y,X) (or (C,T,Y,X)).     59     """---> 60     if not src.endswith(".tif"):  # read anything but tif files with io.imread     61         warnings.warn(     62             "Non-tiff file, returning array opened with default settings only."     63         )     64         return io.imread(src)AttributeError: 'WindowsPath' object has no attribute 'endswith'

Can someone offer advice on what might be causing this? Thanks!

I confirmed that WindowsPath refers to the actual path with TIF files.


Viewing all articles
Browse latest Browse all 19054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>