Ejemplo n.º 1
0
# -*- coding: utf-8 -*-
"""
Created on Thu Jul  2 14:45:55 2015

@author: sansomk
"""

# D. Mason, Aug 2009 
from dicom.datadict import DicomDictionary, NameDict, CleanName 
import dicom 

new_dict_items = { 
0x10011001: ('UL', '1', "Test One", ''), 
0x10011002: ('OB', '1', "Test Two", ''), 
0x10011003: ('UI', '1', "Test Three", ''), 
} 
DicomDictionary.update(new_dict_items) 

new_names_dict = dict([(CleanName(tag), tag) for tag in 
new_dict_items]) 
NameDict.update(new_names_dict) 

filename = r"c:\co\pydicom\source\dicom\testfiles\CT_small.dcm" 
ds = dicom.read_file(filename) 

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

print ds.top() 
Ejemplo n.º 2
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]
Ejemplo n.º 3
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())