Comments (4)
Thanks for the report!
If I manually rename both the file and its directory, i.e. to "CellLine1_1Hz_Field_2.NDTiffStack.tif", the command io.imread(CellLine1_1Hz_Field_2.NDTiffStack.tif) provides the following error:
[Errno 2] No such file or directory: CellLine1_1Hz_Field_2/CellLine1_1Hz_Field_1.NDTiffStack.tif
This seems a little confusing to me. I'm not sure if this is an oversight while writing the report or if this points to the actual cause of the issue. But these paths don't line up. You rename to "CellLine1_1Hz_Field_2.NDTiffStack.tif" including the directory but the error message indicates that you used "CellLine1_1Hz_Field_1.NDTiffStack.tif". Can you check if that's the case and maybe try to describe the issue in clearer more explicit terms? E.g.
# path before renaming
directory_1/file_name_1.tif
# path after renaming
directory_2/file_name_2.tif
It would be even better if you could provide a snippet to reproduce this. 🙏
Note that we are planning on deprecating the IO plugin infrastructure altogether (#7353). You could also try to use imageio
directly.
from scikit-image.
Thank you, Lars, for the quick reply. Apologies for the confusion.
That point is the actual cause of the issue. I follow up below with some specifications.
# 1. path before renaming
## correctly read by io.imread()
file_name_1_directory/file_name_1.NDTiffStack.tif
# 2. path after renaming
## not read by io.imread()
file_name_2_directory/file_name_2.NDTiffStack.tif
### Here the error that is outputed will be:
[Errno 2] No such file or directory: 'file_name_2_directory/file_name_1.NDTiffStack.tif' (yes, it's looking for the original file name into the renamed directory)
# 3. solution that works
## if I duplicate the file at point no. 2 and I rename one of the two as the file in point no. 1, both are correctly read.
file_name_2_directory/file_name_1.NDTiffStack.tif
file_name_2_directory/file_name_2.NDTiffStack.tif
To me, it seems that io.imread() somehow have access to the pre-renamed filename in the renamed folder, and this of course causes the error as the file in the new folder has indeed another name, since it has been indeed renamed. I have no clue on how/where io.imread() gets the information on the old file name. I already emptied Win10 cache.
The snippet is very minimal in my case, as the error is recreated already with:
from skimage import io
import os
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
main_dir = input("Enter the path to the main directory: ") #this would be, e.g., file_name_1_directory or file_name_2_directory
tif_files = []
for root, dirs, files in os.walk(main_dir):
for file in files:
if file.endswith('.tif'):
tif_path = os.path.join(root, file)
tif_files.append(tif_path)
for tif_path in tqdm(tif_files, desc="Processing .tif files"):
try:
# Check if the path has enough directories
tif_path_parts = tif_path.split(os.sep)
# Extract the second and third from the last directory names
if len(tif_path_parts) >= 4:
dir2 = tif_path_parts[-3] # Second from the last
last = tif_path_parts[-1] # This is the file
# Combine them as a new file name
file_name = f"{dir2}_{last}"
stack = io.imread(tif_path)
The files to be analyzed are 2-3 Gb in size. Let me know if you think one sample is required.
from scikit-image.
The metadata for NDTiff stacks, including the file names where image data are stored, are found in a separate NDTiff.index
file. Renaming a NDTiff file invalidates the metadata. Try to remove the NDTiff.index
file or tell tifffile not to use NDTiff metadata: imread(..., is_ndtiff=False)
.
from scikit-image.
The metadata for NDTiff stacks, including the file names where image data are stored, are found in a separate
NDTiff.index
file. Renaming a NDTiff file invalidates the metadata. Try to remove theNDTiff.index
file or tell tifffile not to use NDTiff metadata:imread(..., is_ndtiff=False)
.
Thanks a lot; the imread(..., is_ndtiff=False)
solved the issue completely.
from scikit-image.
Related Issues (20)
- Wheel building action fails with `actions/upload-artifact@v4` HOT 1
- In `scikit-image==0.23.1` `img_as_ubyte` stop accepting `np.ulonglong` HOT 22
- Investigate performance optimization in `_corner_fast` HOT 2
- test_unsharp_masking_output_type_and_shape fails on non-x86 architectures HOT 9
- H&E and Residual, rather than HED HOT 5
- Invalid no-name-in-module from pylint on scikit-image>=0.19.0 using filters module HOT 3
- libatlas 3.10.3 related failures on debian
- Discrepancy of skimage.filters.frangi output between 0.19.3 and 0.22.0 HOT 2
- Adding `spacing` to `extra_properties`'s possible arguments in `regionprops` HOT 3
- CI fails on MacOS with "clang cannot compile programs" HOT 2
- ORB test points file should be read in x-y and not r-c
- Typo in `skimage.measure.find_contours` HOT 3
- Vulnerability: code injection HOT 9
- The Skeletonize function output wrong figure. HOT 3
- Docs mention non-existing ASV benchmarks HOT 2
- `morphology.skel` modifies input image HOT 1
- moments_weighted_normalized causes warning "invalid value encountered in double_scalars" HOT 2
- rgb2lab([1,1,1]) returns [0.,0.,0.] HOT 1
- Rolling ball algorithm scales badly with radius HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scikit-image.