Exemple #1
0
    def set_data_path_key(self, data_nr, new_path, new_key):
        """Sets file path and h5 key of the dataset.

        :param data_nr: number of dataset
        :param new_path: new file path
        :param new_key: new h5 key
        """
        rel_path = os.path.relpath(os.path.abspath(new_path), self.project_dir) + "/" + new_key
        h5_key = const.filepath(data_nr)
        vigra.writeHDF5(rel_path, self.project_filename, h5_key)
Exemple #2
0
    def set_data_path_key(self, data_nr, new_path, new_key):
        """Sets file path and h5 key of the dataset.

        :param data_nr: number of dataset
        :param new_path: new file path
        :param new_key: new h5 key
        """
        rel_path = os.path.relpath(os.path.abspath(new_path),
                                   self.project_dir) + "/" + new_key
        h5_key = const.filepath(data_nr)
        vigra.writeHDF5(rel_path, self.project_filename, h5_key)
Exemple #3
0
    def _datatype(self, data_nr):
        """Returns the data type of the given data. Valid data types are: "hdf5", "tiff", "bmp". If none of these types
        are present, None is returned.

        :param data_nr: number of dataset
        :return: data type
        """
        h5_key = const.filepath(data_nr)
        data_path = vigra.readHDF5(self.project_filename, h5_key)
        if ".h5/" in data_path.lower() or ".hdf5/" in data_path.lower():
            return "hdf5"
        elif data_path[-4:].lower() == ".tif" or data_path[-5:].lower() == ".tiff":
            return "tiff"
        elif data_path[-4:].lower() == ".bmp":
            return "bmp"
        else:
            return None
Exemple #4
0
    def get_data_key(self, data_nr):
        """Returns the h5 key of the dataset.

        :param data_nr: number of dataset
        :return: key of the dataset inside its h5 file
        :rtype: str
        """
        if self.is_internal(data_nr):
            dataset_id = self.get_dataset_id(data_nr)
            data_key = const.localdataset(dataset_id)
        else:
            if self._datatype(data_nr) != "hdf5":
                return const.default_export_key()
            h5_key = const.filepath(data_nr)
            data_path = vigra.readHDF5(self.project_filename, h5_key)
            data_key = os.path.basename(data_path)
        return data_key
Exemple #5
0
    def get_data_path(self, data_nr):
        """Returns the file path of the dataset.

        :param data_nr: number of dataset
        :return: file path of the dataset
        :rtype: str
        """
        if self.is_internal(data_nr):
            return self.project_filename
        else:
            h5_key = const.filepath(data_nr)
            data_path = vigra.readHDF5(self.project_filename, h5_key)
            if self._datatype(data_nr) == "hdf5":
                data_key = os.path.basename(data_path)
                data_path = data_path[:-len(data_key)-1]
            data_path = os.path.join(self.project_dir, data_path)
            return data_path
Exemple #6
0
    def get_data_key(self, data_nr):
        """Returns the h5 key of the dataset.

        :param data_nr: number of dataset
        :return: key of the dataset inside its h5 file
        :rtype: str
        """
        if self.is_internal(data_nr):
            dataset_id = self.get_dataset_id(data_nr)
            data_key = const.localdataset(dataset_id)
        else:
            if self._datatype(data_nr) != "hdf5":
                return const.default_export_key()
            h5_key = const.filepath(data_nr)
            data_path = vigra.readHDF5(self.project_filename, h5_key)
            data_key = os.path.basename(data_path)
        return data_key
Exemple #7
0
    def get_data_path(self, data_nr):
        """Returns the file path of the dataset.

        :param data_nr: number of dataset
        :return: file path of the dataset
        :rtype: str
        """
        if self.is_internal(data_nr):
            return self.project_filename
        else:
            h5_key = const.filepath(data_nr)
            data_path = vigra.readHDF5(self.project_filename, h5_key)
            if self._datatype(data_nr) == "hdf5":
                data_key = os.path.basename(data_path)
                data_path = data_path[:-len(data_key) - 1]
            data_path = os.path.join(self.project_dir, data_path)
            return data_path
Exemple #8
0
    def _datatype(self, data_nr):
        """Returns the data type of the given data. Valid data types are: "hdf5", "tiff", "bmp". If none of these types
        are present, None is returned.

        :param data_nr: number of dataset
        :return: data type
        """
        h5_key = const.filepath(data_nr)
        data_path = vigra.readHDF5(self.project_filename, h5_key)
        if ".h5/" in data_path.lower() or ".hdf5/" in data_path.lower():
            return "hdf5"
        elif data_path[-4:].lower() == ".tif" or data_path[-5:].lower(
        ) == ".tiff":
            return "tiff"
        elif data_path[-4:].lower() == ".bmp":
            return "bmp"
        else:
            return None