"'dataset_name' argument is unused since there is only one dataset in the file"
)
name=datasets[0]
vol=f[name]
# Multiple datasets were found
eliflen(datasets)>1:
ifself.dataset_nameindatasets:# Provided dataset name is valid
name=self.dataset_name
vol=f[name]
else:
ifself.dataset_name:# Dataset name is provided
similar_names=difflib.get_close_matches(
self.dataset_name,datasets
)# Find closest matching name if any
ifsimilar_names:
suggestion=similar_names[0]# Get the closest match
raiseValueError(
f"Invalid dataset name. Did you mean '{suggestion}'?"
)
else:
raiseValueError(
f"Invalid dataset name. Please choose between the following datasets: {datasets}"
)
else:
raiseValueError(
f"Found multiple datasets: {datasets}. Please specify which of them that you want to load with the argument 'dataset_name'"
)
# No datasets were found
else:
raiseValueError(f"Did not find any data in the file: {path}")
ifnotself.virtual_stack:
vol=vol[()]# Load dataset into memory
f.close()
else:
log.info("Using virtual stack")
log.info("Loaded the following dataset: %s",name)
log.info("Loaded shape: %s",vol.shape)
log.info("Using %s of memory",sizeof(sys.getsizeof(vol)))
ifself.return_metadata:
returnvol,metadata
else:
returnvol
defload_tiff_stack(self,path):
"""Load a stack of TIFF files from the specified path.
Args:
path (str): The path to the stack of TIFF files.
Returns:
numpy.ndarray: The loaded volume as a NumPy array.
Raises:
ValueError: If the 'contains' argument is not specified.
ValueError: If the 'contains' argument matches multiple TIFF stacks in the directory
"""
=======
>>>>>>>main
ifnotself.contains:
raiseValueError(
"Please specify a part of the name that is common for the TIFF file stack with the argument 'contains'"
...
...
@@ -287,11 +191,7 @@ class DataLoader:
raiseValueError(f"The provided part of the filename for the TIFF stack matches multiple TIFF stacks: {unique_names}.\nPlease provide a string that is unique for the TIFF stack that is intended to be loaded")