def validate_filepath(self): """Fix the broken filenames in FluoView experiment files. The FluoView software usually stores corrupted filenames in its experiment description files, that have a missing suffix, e.g. Slide1sec001\\Slide1sec001.oib whereas the correct filename would be Slide1sec001\\Slide1sec001_01.oib This function attempts to fix this by checking if the supplied path is actually existing and trying the default suffix if not. Raises an IOError exception if no corresponding file can be found. Returns ------- storage : pathtools.parse_path """ fpath = self.storage ext = fpath['ext'] log.debug("Validating file path: %s" % fpath) if not exists(fpath['full']): fpath = parse_path(fpath['orig'].replace(ext, '_01' + ext)) log.debug("Trying next path: %s" % fpath['full']) if not exists(fpath['full']): raise IOError("Can't find file: %s" % fpath) return fpath
def __init__(self, ds_type, st_type, st_path): """Prepare the dataset object. Parameters ---------- ds_type : str One of ('mosaic', 'stack', 'single') st_type : str 'single' : a single file container with the full dataset 'tree' : a directory hierarchy 'sequence' : a sequence of files st_path : str The full path to either a file or directory, depending on the storage type of this dataset. supplement : dict An auxiliary dict to keep supplementary information. Instance Variables ------------------ ds_type : str storage : pathtools.parse_path """ log.debug("Creating a 'Dataset' object.") ds_type_allowed = ('mosaic', 'stack', 'single') st_type_allowed = ('single', 'tree', 'sequence') if not ds_type in ds_type_allowed: raise TypeError("Illegal dataset type: %s." % ds_type) if not st_type in st_type_allowed: raise TypeError("Illegal storage type: %s." % st_type) self.ds_type = ds_type self.storage = parse_path(st_path) self.storage['type'] = st_type if st_type == 'single' and self.storage['fname'] == '': raise TypeError("File name missing for storage type 'single'.") self.supplement = {}
def __init__(self, infile): """Set up the common experiment properties. Parameters ---------- infile : str The experiment file or folder. Instance Variables ------------------ infile : pathtools.parse_path datasets : list(Dataset) """ super(Experiment, self).__init__() log.info("Creating an 'Experiment' object.") self.infile = parse_path(infile) log.debug(self.infile)