dataset.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:augment3D 作者: yulkang 项目源码 文件源码
def __init__(self, filename_or_obj, dataset, preamble=None, file_meta=None,
                 is_implicit_VR=True, is_little_endian=True):
        """Initialize a dataset read from a DICOM file.

        Parameters
        ----------
        filename_or_obj : str, None
            Full path and filename to the file. Use None if is a BytesIO.
        dataset : Dataset, dict
            Some form of dictionary, usually a Dataset from read_dataset()
        preamble : None, optional
            The 128-byte DICOM preamble
        file_meta : None, optional
            The file meta info dataset, as returned by _read_file_meta,
            or an empty dataset if no file meta information is in the file.
        is_implicit_VR : boolean, optional
            True (default) if implicit VR transfer syntax used; False if explicit VR.
        is_little_endian : boolean
            True (default) if little-endian transfer syntax used; False if big-endian.
        """
        Dataset.__init__(self, dataset)
        self.preamble = preamble
        self.file_meta = file_meta
        self.is_implicit_VR = is_implicit_VR
        self.is_little_endian = is_little_endian
        if isinstance(filename_or_obj, compat.string_types):
            self.filename = filename_or_obj
            self.fileobj_type = open
        elif isinstance(filename_or_obj, io.BufferedReader):
            self.filename = filename_or_obj.name
            # This is the appropriate constructor for io.BufferedReader
            self.fileobj_type = open
        else:
            self.fileobj_type = filename_or_obj.__class__  # use __class__ python <2.7?; http://docs.python.org/reference/datamodel.html
            if getattr(filename_or_obj, "name", False):
                self.filename = filename_or_obj.name
            elif getattr(filename_or_obj, "filename", False):  # gzip python <2.7?
                self.filename = filename_or_obj.filename
            else:
                self.filename = None  # e.g. came from BytesIO or something file-like
        self.timestamp = None
        if stat_available and self.filename and os.path.exists(self.filename):
            statinfo = os.stat(self.filename)
            self.timestamp = statinfo.st_mtime
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号