Esempio n. 1
0
 def testPrivate1(self):
     """private dict: """
     self.assert_(CleanName(0x00100010) == "PatientsName")
     self.assert_(CleanName(Tag((0x0010, 0x0010))) == "PatientsName")
Esempio n. 2
0
 def testTagNotFound(self):
     """dicom_dictionary: CleanName returns blank string for unknown tag"""
     self.assert_(CleanName(0x99991111) == "")
Esempio n. 3
0
 def testCleanName(self):
     """dicom_dictionary: CleanName returns correct strings............."""
     self.assert_(CleanName(0x00100010) == "PatientsName")
     self.assert_(CleanName(Tag((0x0010, 0x0010))) == "PatientsName")
Esempio n. 4
0
    https://www.aapm.org/GrandChallenge/LowDoseCT/#registration
"""

from __future__ import division
import numpy as np
import os
import dicom
import odl
import tqdm

from dicom.datadict import DicomDictionary, NameDict, CleanName
from odl.contrib.datasets.ct.mayo_dicom_dict import new_dict_items

# Update the DICOM dictionary with the extra Mayo tags
DicomDictionary.update(new_dict_items)
NameDict.update((CleanName(tag), tag) for tag in new_dict_items)

__all__ = ('load_projections', 'load_reconstruction')


def _read_projections(folder, indices):
    """Read mayo projections from a folder."""
    datasets = []

    # Get the relevant file names
    file_names = sorted([f for f in os.listdir(folder) if f.endswith(".dcm")])

    if len(file_names) == 0:
        raise ValueError('No DICOM files found in {}'.format(folder))

    file_names = file_names[indices]
Esempio n. 5
0
from datetime import datetime
from dicom.datadict import CleanName
from glob import glob

src_dcms = glob("/input/*.dcm")
if len(src_dcms) > 0:
    src_dcm = src_dcms[0]
    ds = dicom.read_file(src_dcm)
    ds.remove_private_tags()
    tags = ds.keys()
    info = {}
    for tag in tags:
        element = ds[tag]
        if element.VM > 1:
            continue
        clean_name = CleanName(tag)
        if element.VR == "DA":
            first_part = clean_name[:-4]
            try:
                date = datetime.strptime(element.value, '%Y%m%d')
                time_name = first_part + "Time"
                time_element = ds.data_element(time_name)
                time = datetime.strptime(time_element.value,
                                         '%H%M%S.%f').time()
                date = datetime.combine(date, time)
                info[first_part + "DateTime"] = date.isoformat()
            except:
                pass
            info[clean_name] = element.value
        elif element.VR == "PN":
            info[clean_name] = str(element.value)
Esempio n. 6
0
where a block is reserved etc as specified in the DICOM standards.
"""

# D. Mason, 2013-01
from dicom.datadict import DicomDictionary, NameDict, CleanName
from dicom.dataset import Dataset

# Define items as (VR, VM, description, is_retired flag, keyword)
#   Leave is_retired flag blank.
new_dict_items = {
    0x10011001: ('UL', '1', "Test One", '', 'TestOne'),
    0x10011002: ('OB', '1', "Test Two", '', 'TestTwo'),
    0x10011003: ('UI', '1', "Test Three", '', 'TestThree'),
}

# Update the dictionary itself
DicomDictionary.update(new_dict_items)

# Update the reverse mapping from name to tag
new_names_dict = dict([(CleanName(tag), tag) for tag in new_dict_items])
NameDict.update(new_names_dict)

# Test that it is working
ds = Dataset()  # or could get one from read_file, etc

ds.TestOne = 42
ds.TestTwo = '12345'
ds.TestThree = '1.2.3.4.5'

print(ds.top())