HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/anaconda3/Lib/site-packages/spyder/plugins/io_dcm/plugin.py
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright (c) 2009- Spyder Project Contributors
#
# Distributed under the terms of the MIT License
# (see spyder/__init__.py for details)
# -----------------------------------------------------------------------------


"""Example of I/O plugin for loading DICOM files."""


# Standard library imports
import os.path as osp


try:
    try:
        # pydicom 0.9
        import dicom as dicomio
    except ImportError:
        # pydicom 1.0
        from pydicom import dicomio
    def load_dicom(filename):
        try:
            name = osp.splitext(osp.basename(filename))[0]
            try:
                data = dicomio.read_file(filename, force=True)
            except TypeError:
                data = dicomio.read_file(filename)
            arr = data.pixel_array
            return {name: arr}, None
        except Exception as error:
            return None, str(error)
except ImportError:
    load_dicom = None