Exemplo n.º 1
0
def build_orientation(patient_position,
                      column_direction,
                      row_direction,
                      frame_of_reference_uid=None):
    sb = StudyBuilder(patient_position=patient_position,
                      patient_id="oblique_mr_x_z",
                      patient_name="Amanda^Grayson^Mother^Of^Spock",
                      patient_birthdate="20121212")
    if frame_of_reference_uid != None:
        sb.current_study['FrameOfReferenceUID'] = frame_of_reference_uid

    print "building %s..." % (patient_position, )
    print "ct"
    ct = sb.build_mr(num_voxels=[7, 7, 7],
                     voxel_size=[4, 4, 4],
                     pixel_representation=0,
                     row_direction=row_direction,
                     column_direction=column_direction)
    ct.clear(stored_value=0)
    ct.add_box(size=[4, 4, 4], center=[-12, -12, -12], stored_value=100)
    ct.add_box(size=[4, 4, 4], center=[-12, -12, -8], stored_value=200)
    ct.add_box(size=[4, 4, 4], center=[-12, -12, -4], stored_value=300)
    ct.add_box(size=[4, 4, 4], center=[-12, -12, 0], stored_value=400)
    ct.add_box(size=[4, 4, 4], center=[-12, -12, 4], stored_value=500)
    ct.add_box(size=[4, 4, 4], center=[-12, -12, 8], stored_value=600)
    ct.add_box(size=[4, 4, 4], center=[-12, -12, 12], stored_value=700)

    ct.add_box(size=[4, 4, 4], center=[0, 0, -12], stored_value=450)
    ct.add_box(size=[4, 4, 4], center=[0, 0, -8], stored_value=450)
    ct.add_box(size=[4, 4, 4], center=[0, 0, -4], stored_value=450)
    ct.add_box(size=[4, 4, 4], center=[0, 0, 0], stored_value=450)
    ct.add_box(size=[4, 4, 4], center=[0, 0, 4], stored_value=450)
    ct.add_box(size=[4, 4, 4], center=[0, 0, 8], stored_value=450)
    ct.add_box(size=[4, 4, 4], center=[0, 0, 12], stored_value=450)

    ct.add_box(size=[4, 4, 4], center=[12, -12, -12], stored_value=100)
    ct.add_box(size=[4, 4, 4], center=[12, -8, -12], stored_value=200)
    ct.add_box(size=[4, 4, 4], center=[12, -4, -12], stored_value=300)
    ct.add_box(size=[4, 4, 4], center=[12, -0, -12], stored_value=400)
    ct.add_box(size=[4, 4, 4], center=[12, 4, -12], stored_value=500)
    ct.add_box(size=[4, 4, 4], center=[12, 8, -12], stored_value=600)
    ct.add_box(size=[4, 4, 4], center=[12, 12, -12], stored_value=700)

    ct.build()

    return sb
Exemplo n.º 2
0
def generate_mr_signed_in_short_range(out_dir, patient_id):
    sb = StudyBuilder(patient_position="HFS",
                      patient_id=patient_id,
                      patients_name="MrSigned^InShortRange",
                      patients_birthdate="20121212")
    ct = sb.build_mr(num_voxels=[48, 64, 10],
                     voxel_size=[4, 3, 4],  # [mm]
                     pixel_representation=get_pixel_representation('signed'))
    ct.clear(stored_value=0)
    ct.add_box(size=[25, 50, 5], center=[0, 0, 0], stored_value=12345, mode='set')

    # Smallest stored value is: 0 (in short range)
    # Largest stored value is: 12345 (in short range).

    mk_fresh_dir(out_dir)
    sb.write(out_dir)
    print out_dir
Exemplo n.º 3
0
def generate_pt_unsigned_not_in_short_range(out_dir, patient_id):
    sb = StudyBuilder(patient_position="HFS",
                      patient_id=patient_id,
                      patients_name="PtUnsigned^NotInShortRange",
                      patients_birthdate="20121212")
    pt = sb.build_pt(num_voxels=[48, 64, 10],
                     voxel_size=[4, 3, 4],  # [mm]
                     pixel_representation=get_pixel_representation('unsigned'),
                     rescale_slope=1)
    pt.clear(stored_value=0)
    pt.add_box(size=[25, 50, 5], center=[0, 0, 0], stored_value=54321, mode='set')

    # Smallest stored value is: 0 (in short range)
    # Largest stored value is: 54321 (greater than 32767).

    mk_fresh_dir(out_dir)
    sb.write(out_dir)
    print out_dir
Exemplo n.º 4
0
def generate_ct_unsigned_rescaled_in_short_range(out_dir, patient_id):
    sb = StudyBuilder(patient_position="HFS",
                      patient_id=patient_id,
                      patients_name="CtUnsigned^InShortRange",
                      patients_birthdate="20121212")
    ct = sb.build_ct(num_voxels=[48, 64, 10],
                     voxel_size=[4, 3, 4],  # [mm]
                     pixel_representation=get_pixel_representation('unsigned'),
                     rescale_slope=1,
                     rescale_intercept=-1024)
    ct.clear(stored_value=0)
    ct.add_box(size=[25, 50, 5], center=[0, 0, 0], stored_value=12345, mode='set')

    # Smallest rescaled value is: 1 * 0 - 1024 = -1024 (in short range)
    # Largest rescaled value is: 1 * 54321 - 1024 = 11321 (in short range).

    mk_fresh_dir(out_dir)
    sb.write(out_dir)
    print out_dir
Exemplo n.º 5
0
def build_orientation(patient_position, column_direction, row_direction, frame_of_reference_uid = None):
    sb = StudyBuilder(patient_position=patient_position, patient_id="smallValuesUInt32", patient_name="smallValuesUInt32", patient_birthdate = "20121212")
    if frame_of_reference_uid != None:
        sb.current_study['FrameOfReferenceUID'] = frame_of_reference_uid

    print "building %s..." % (patient_position,)
    print "ct"
    ct = sb.build_ct(
        num_voxels=[7, 7, 7],
        voxel_size=[3, 3, 3],
        pixel_representation=0,
        rescale_slope=1,
        rescale_intercept=-1024,
        row_direction=row_direction,
        column_direction=column_direction)
    ct.clear(real_value = -1000)
    ct.add_box(size = [4,4,4], center = [0,0,0], real_value = 0)
    ct.add_box(size = [20,4,4], center = [0,-8,-8], real_value = 0)
    ct.add_box(size = [4,20,4], center = [8,0,-8], real_value = 0)
    ct.add_box(size = [4,4,20], center = [8,8,0], real_value = 0)
    ct.add_sphere(radius = 4, center = [-8,-8,-8], real_value = 0)

    print "rtstruct"
    rtstruct = sb.build_structure_set(ct)
    rtstruct.add_external_box()
    rtstruct.add_box(size = [4,4,4], center = [0,0,0], name='CenterVoxel', interpreted_type='SITE')
    rtstruct.add_box(size = [20,4,4], center = [0,-8,-8], name='x=-8 to 8, y=z=-8', interpreted_type='SITE')
    rtstruct.add_box(size = [4,20,4], center = [8,0,-8], name='y=-8 to 8 x=8, z=-8', interpreted_type='SITE')
    rtstruct.add_box(size = [4,4,20], center = [8,8,0], name='z=-8 to 8, x=y=8', interpreted_type='SITE')
    rtstruct.add_sphere(radius=4, center = [-8,-8,-8], name='x=y=z=-8', interpreted_type='SITE')
    rtstruct.build()

    print "rtplan"
    rtplan = sb.build_static_plan(structure_set = rtstruct, sad=20)
    b1 = rtplan.build_beam(gantry_angle = 0, collimator_angle=30, meterset = 100)
    b1.conform_to_rectangle(4, 4, [0,0])
    b2 = rtplan.build_beam(gantry_angle = 120, meterset = 100)
    b2.conform_to_rectangle(4, 4, [4,4])
    rtplan.build()

    print "rtdose beam 1"
    rtdose1 = sb.build_dose(planbuilder = rtplan, bits = 32)
    rtdose1.dose_grid_scaling = 1
    rtdose1.dose_summation_type = "PLAN"
    rtdose1.beam_number = None
    rtdose1.BitsAllocated = 32
    rtdose1.BitsStored = 32
    rtdose1.HighBit = 31

    rtdose1.add_box(size = [0,0,0], center = [9,  9, -9], stored_value = 65536) #50%
    rtdose1.add_box(size = [0,0,0], center = [-9, 9, -9], stored_value = 65536) #50%
    rtdose1.add_box(size = [0,0,0], center = [9,  -9,-9], stored_value = 65536) #50%
    rtdose1.add_box(size = [0,0,0], center = [-9, -9,-9], stored_value = 65536) #50%
    rtdose1.add_box(size = [0,0,0], center = [0, 0,  -9], stored_value = 65535*2) #100  
    rtdose1.add_box(size = [0,0,0], center = [0, 0,   0], stored_value = 65535*2)  #100

    return sb
Exemplo n.º 6
0
def build_orientation(patient_position, row_direction, column_direction, frame_of_reference_uid = None):
    sb = StudyBuilder(patient_position=patient_position, patient_id="OrientationTests", patient_name="Orientation^Tests", patient_birthdate = "20121212")
    if frame_of_reference_uid != None:
        sb.current_study['FrameOfReferenceUID'] = frame_of_reference_uid

    print "building %s..." % (patient_position,)
    print "ct"
    ct = sb.build_ct(
        num_voxels=[7, 7, 7],
        voxel_size=[4, 4, 4],
        pixel_representation=0,
        rescale_slope=1,
        rescale_intercept=-1024,
        row_direction=row_direction,
        column_direction=column_direction)
    ct.clear(real_value = -1000)
    ct.add_box(size = [4,4,4], center = [0,0,0], real_value = 0)
    ct.add_box(size = [20,4,4], center = [0,-8,-8], real_value = 0)
    ct.add_box(size = [4,20,4], center = [8,0,-8], real_value = 0)
    ct.add_box(size = [4,4,20], center = [8,8,0], real_value = 0)
    ct.add_sphere(radius = 4, center = [-8,-8,-8], real_value = 0)

    print "rtstruct"
    rtstruct = sb.build_structure_set(ct)
    rtstruct.add_external_box()
    rtstruct.add_box(size = [4,4,4], center = [0,0,0], name='CenterVoxel', interpreted_type='SITE')
    rtstruct.add_box(size = [20,4,4], center = [0,-8,-8], name='x=-8 to 8, y=z=-8', interpreted_type='SITE')
    rtstruct.add_box(size = [4,20,4], center = [8,0,-8], name='y=-8 to 8 x=8, z=-8', interpreted_type='SITE')
    rtstruct.add_box(size = [4,4,20], center = [8,8,0], name='z=-8 to 8, x=y=8', interpreted_type='SITE')
    rtstruct.add_sphere(radius=4, center = [-8,-8,-8], name='x=y=z=-8', interpreted_type='SITE')
    rtstruct.build()

    print "rtplan"
    rtplan = sb.build_static_plan(structure_set = rtstruct, sad=20)
    b1 = rtplan.build_beam(gantry_angle = 0, collimator_angle=30, meterset = 100)
    b1.conform_to_rectangle(4, 4, [0,0])
    b2 = rtplan.build_beam(gantry_angle = 120, meterset = 100)
    b2.conform_to_rectangle(4, 4, [4,4])
    rtplan.build()

    print "rtdose"
    rtdose = sb.build_dose(planbuilder = rtplan)
    for beam in rtplan.beam_builders:
        rtdose.add_lightfield(beam.rtbeam, beam.meterset)

    return sb
Exemplo n.º 7
0
                    help="""Add an opening to the current list of mlc openings.
                    For syntax, see the forthcoming documentation or the source code...""")
parser.add_argument('--jaw-shape', dest='jawshapes', default=[], action='append',
                    help="""Sets the jaw shape to x * y, centered at (xc, yc).
                    Given as [x;y;xc;yc]. Defaults to conforming to the MLC.""")
parser.add_argument('--outdir', dest='outdir', default='.',
                    help="""Generate data to this directory. (default: working directory)""")
args = parser.parse_args(namespace=argparse.Namespace(studies=[[]]))

voxel_size = [float(x) for x in args.VoxelSize.split(",")]
num_voxels = [int(x) for x in args.NumVoxels.split(",")]

if not os.path.exists(args.outdir):
    os.makedirs(args.outdir)
for study in args.studies:
    sb = StudyBuilder()
    for series in study:
        if series.center.__class__ is str:
            series.center = [float(b) for b in series.center.lstrip('[').rstrip(']').split(";")]
        if series.modality == "CT":
            if 'PatientPosition' not in sb.current_study:
                parser.error("Patient position must be specified when writing CT images!")

            ib = sb.build_ct(
                num_voxels=num_voxels,
                voxel_size=voxel_size,
                pixel_representation=pixel_representations[series.pixel_representation],
                rescale_slope=series.rescale_slope,
                rescale_intercept=series.rescale_intercept,
                center=np.array(series.center))
        elif series.modality == "MR":
Exemplo n.º 8
0
def build_orientation(patient_position, column_direction, row_direction, frame_of_reference_uid = None):
    sb = StudyBuilder(patient_position=patient_position, patient_id="OrientationTests", patient_name="Orientation^Tests", patient_birthdate = "20121212")
    if frame_of_reference_uid != None:
        sb.current_study['FrameOfReferenceUID'] = frame_of_reference_uid

    print "building %s..." % (patient_position,)
    print "ct"
    ct = sb.build_ct(
        num_voxels=[7, 7, 7],
        voxel_size=[4, 4, 4],
        pixel_representation=0,
        rescale_slope=1,
        rescale_intercept=-1024,
        row_direction=row_direction,
        column_direction=column_direction)
    ct.clear(real_value = -1000)
    ct.add_box(size = [4,4,4], center = [0,0,0], real_value = 0)
    ct.add_box(size = [20,4,4], center = [0,-8,-8], real_value = 0)
    ct.add_box(size = [4,20,4], center = [8,0,-8], real_value = 0)
    ct.add_box(size = [4,4,20], center = [8,8,0], real_value = 0)
    ct.add_sphere(radius = 4, center = [-8,-8,-8], real_value = 0)

    print "rtstruct"
    rtstruct = sb.build_structure_set(ct)
    rtstruct.add_external_box()
    rtstruct.add_box(size = [4,4,4], center = [0,0,0], name='CenterVoxel', interpreted_type='SITE')
    rtstruct.add_box(size = [20,4,4], center = [0,-8,-8], name='x=-8 to 8, y=z=-8', interpreted_type='SITE')
    rtstruct.add_box(size = [4,20,4], center = [8,0,-8], name='y=-8 to 8 x=8, z=-8', interpreted_type='SITE')
    rtstruct.add_box(size = [4,4,20], center = [8,8,0], name='z=-8 to 8, x=y=8', interpreted_type='SITE')
    rtstruct.add_sphere(radius=4, center = [-8,-8,-8], name='x=y=z=-8', interpreted_type='SITE')
    rtstruct.build()

    print "rtplan"
    rtplan = sb.build_static_plan(structure_set = rtstruct, sad=20)
    b1 = rtplan.build_beam(gantry_angle = 0, collimator_angle=30, meterset = 100)
    b1.conform_to_rectangle(4, 4, [0,0])
    b2 = rtplan.build_beam(gantry_angle = 120, meterset = 100)
    b2.conform_to_rectangle(4, 4, [4,4])
    rtplan.build()

    print "rtdose beam 1"
    rtdose1 = sb.build_dose(planbuilder = rtplan)
    rtdose1.dose_grid_scaling = 1
    rtdose1.dose_summation_type = "BEAM"
    rtdose1.beam_number = 1

    rtdose1.add_box(size = [4,4,4], center = [0,-12, 0], stored_value = 65535) #100%
    rtdose1.add_box(size = [4,4,4], center = [0, -8, 0], stored_value = 39321) #60%
    rtdose1.add_box(size = [4,4,4], center = [0, -4, 0], stored_value = 38665) #59%
    rtdose1.add_box(size = [4,4,4], center = [0,  0, 0], stored_value = 32767) #50%
    rtdose1.add_box(size = [4,4,4], center = [0,  4, 0], stored_value = 32112) #49%
    rtdose1.add_box(size = [4,4,4], center = [0,  8, 0], stored_value = 15728) #24%
    rtdose1.add_box(size = [4,4,4], center = [0, 12, 0], stored_value = 0)     #0%

    ############# second beam
    print "rtdose beam 2"
    rtdose2 = sb.build_dose(planbuilder = rtplan)
    rtdose2.dose_grid_scaling = 1
    rtdose2.dose_summation_type = "BEAM"
    rtdose2.beam_number = 2

    rtdose2.add_box(size = [4,4,4], center = [-12,0, 0], stored_value = 65535) # 100%
    rtdose2.add_box(size = [4,4,4], center = [-8, 0, 0], stored_value = 62259) # 95%
    rtdose2.add_box(size = [4,4,4], center = [-4, 0, 0], stored_value = 61602) # 94%
    rtdose2.add_box(size = [4,4,4], center = [0,  0, 0], stored_value = 32767) # 50%
    rtdose2.add_box(size = [4,4,4], center = [4,  0, 0], stored_value = 52428) # 80%
    rtdose2.add_box(size = [4,4,4], center = [8,  0, 0], stored_value = 51772) # 79%
    rtdose2.add_box(size = [4,4,4], center = [12, 0, 0], stored_value = 15728) # 24%

    ############# second plan
    print "rtdose plan dose"
    rtdosePlan = sb.build_dose(planbuilder = rtplan)
    rtdosePlan.dose_grid_scaling = 1
    rtdosePlan.dose_summation_type = "PLAN"
    rtdosePlan.beam_number = None

    rtdosePlan.pixel_array = numpy.add(rtdose2.pixel_array, rtdose1.pixel_array)

    return sb
Exemplo n.º 9
0
import dicom
import builders
reload(builders)
import modules
reload(modules)
from builders import StudyBuilder

import os
tmpdir = os.path.join(os.getenv("TEMP"), "studybuilder")
if not os.path.exists(tmpdir):
    os.mkdir(tmpdir)

sb = StudyBuilder(patient_position="HFS", patient_id="123", patients_name="Kalle^Kula", patients_birthdate = "20121212")
ct = sb.build_ct(num_voxels = [48,64,48], voxel_size = [4,3,4], rescale_slope = 1, rescale_intercept = -1024)
ct.clear(real_value = 0)
print ct.pixel_array.max(),ct.pixel_array.min()
ct.add_sphere(radius = 25, center = [0,0,0], real_value = -1000, mode = 'set')
print ct.pixel_array.max(),ct.pixel_array.min()
ct.add_box(size = [25,50,25], center = [0,0,0], stored_value = 300, mode = 'add')
print ct.pixel_array.max(),ct.pixel_array.min()

assert sb.seriesbuilders['CT'] == [ct]

rtstruct = sb.build_structure_set()
rtstruct.add_external_box()
rtstruct.add_sphere(radius = 25, center = [0,0,0], name='Sph-PTV', interpreted_type='PTV')
rtstruct.add_box(size = [25,50,25], center = [0,0,0], name='Box-Organ', interpreted_type='CAVITY')

rtplan = sb.build_static_plan()
b1 = rtplan.build_beam(gantry_angle = 0, meterset = 100)
b1.conform_to_circle(25, [0,0])
Exemplo n.º 10
0
parser.add_argument('--isocenter', dest='isocenter', default='[0;0;0]',
                    help="""Set the isocenter of the beams.""")
parser.add_argument('--mlc-shape', dest='mlcshapes', default=[], action='append',
                    help="""Add an opening to the current list of mlc openings.
                    For syntax, see the forthcoming documentation or the source code...""")
parser.add_argument('--jaw-shape', dest='jawshapes', default=[], action='append',
                    help="""Sets the jaw shape to x * y, centered at (xc, yc). Given as [x;y;xc;yc]. Defaults to conforming to the MLC.""")
parser.add_argument('--outdir', dest='outdir', default='.',
                    help="""Generate data to this directory. (default: working directory)""")
args = parser.parse_args(namespace = argparse.Namespace(studies=[[]]))
voxel_size = [float(x) for x in args.VoxelSize.split(",")]
num_voxels = [int(x) for x in args.NumVoxels.split(",")]
if not os.path.exists(args.outdir):
    os.makedirs(args.outdir)
for study in args.studies:
    sb = StudyBuilder()
    for series in study:
        if series.center.__class__ is str:
            series.center = [float(b) for b in series.center.lstrip('[').rstrip(']').split(";")]
        if series.modality == "CT":
            if 'PatientPosition' not in sb.current_study:
                parser.error("Patient position must be specified when writing CT images!")
            ib = sb.build_ct(num_voxels=num_voxels, voxel_size=voxel_size, center=np.array(series.center))
        elif series.modality == "RTDOSE":
            ib = sb.build_dose(num_voxels=num_voxels, voxel_size=voxel_size, center=np.array(series.center))
        elif series.modality == "RTPLAN":
            isocenter = [float(b) for b in series.isocenter.lstrip('[').rstrip(']').split(";")]
            rp = sb.build_static_plan(nominal_beam_energy=series.nominal_energy, isocenter = isocenter)
        elif series.modality == "RTSTRUCT":
            rtstruct = sb.build_structure_set()
        else:
Exemplo n.º 11
0
def build_orientation(patient_position,
                      column_direction,
                      row_direction,
                      frame_of_reference_uid=None):
    sb = StudyBuilder(patient_position=patient_position,
                      patient_id="doseSmallVoxelsOutsideImageData",
                      patient_name="doseSmallVoxelsOutsideImageData",
                      patient_birthdate="20121212")
    if frame_of_reference_uid != None:
        sb.current_study['FrameOfReferenceUID'] = frame_of_reference_uid

    print "building %s..." % (patient_position, )
    print "ct"
    ct = sb.build_ct(num_voxels=[7, 7, 7],
                     voxel_size=[4, 4, 4],
                     pixel_representation=0,
                     rescale_slope=1,
                     rescale_intercept=-1024,
                     row_direction=row_direction,
                     column_direction=column_direction)
    ct.clear(real_value=-1000)
    ct.add_box(size=[4, 4, 4], center=[0, 0, 0], real_value=0)
    ct.add_box(size=[20, 4, 4], center=[0, -8, -8], real_value=0)
    ct.add_box(size=[4, 20, 4], center=[8, 0, -8], real_value=0)
    ct.add_box(size=[4, 4, 20], center=[8, 8, 0], real_value=0)
    ct.add_sphere(radius=4, center=[-8, -8, -8], real_value=0)

    print "rtstruct"
    rtstruct = sb.build_structure_set(ct)
    rtstruct.add_external_box()
    rtstruct.add_box(size=[4, 4, 4],
                     center=[0, 0, 0],
                     name='CenterVoxel',
                     interpreted_type='SITE')
    rtstruct.add_box(size=[20, 4, 4],
                     center=[0, -8, -8],
                     name='x=-8 to 8, y=z=-8',
                     interpreted_type='SITE')
    rtstruct.add_box(size=[4, 20, 4],
                     center=[8, 0, -8],
                     name='y=-8 to 8 x=8, z=-8',
                     interpreted_type='SITE')
    rtstruct.add_box(size=[4, 4, 20],
                     center=[8, 8, 0],
                     name='z=-8 to 8, x=y=8',
                     interpreted_type='SITE')
    rtstruct.add_sphere(radius=4,
                        center=[-8, -8, -8],
                        name='x=y=z=-8',
                        interpreted_type='SITE')
    rtstruct.build()

    print "rtplan"
    rtplan = sb.build_static_plan(structure_set=rtstruct, sad=20)
    b1 = rtplan.build_beam(gantry_angle=0, collimator_angle=30, meterset=100)
    b1.conform_to_rectangle(4, 4, [0, 0])

    b2 = rtplan.build_beam(gantry_angle=120, meterset=100)
    b2.conform_to_rectangle(4, 4, [4, 4])

    b3 = rtplan.build_beam(gantry_angle=120, meterset=100)
    b3.conform_to_rectangle(4, 4, [4, 4])

    b4 = rtplan.build_beam(gantry_angle=120, meterset=100)
    b4.conform_to_rectangle(4, 4, [4, 4])

    rtplan.build()

    print "rtdose beam 1"
    rtdose1 = sb.build_dose(planbuilder=None,
                            num_voxels=[31, 31, 31],
                            voxel_size=[1, 1, 1],
                            row_direction=row_direction,
                            column_direction=column_direction)
    rtdose1.dose_grid_scaling = 0.5
    rtdose1.dose_summation_type = "BEAM"
    rtdose1.beam_number = 1

    rtdose1.add_box(size=[1, 1, 1], center=[0, 14, 0], stored_value=200)
    rtdose1.add_box(size=[1, 1, 1], center=[0, 12, 0], stored_value=180)
    rtdose1.add_box(size=[1, 1, 1], center=[0, 10, 0], stored_value=160)
    rtdose1.add_box(size=[1, 1, 1], center=[0, 8, 0], stored_value=140)
    rtdose1.add_box(size=[1, 1, 1], center=[0, 6, 0], stored_value=120)
    rtdose1.add_box(size=[1, 1, 1], center=[0, 4, 0], stored_value=110)
    rtdose1.add_box(size=[1, 1, 1], center=[0, 2, 0], stored_value=105)
    rtdose1.add_box(size=[1, 1, 1], center=[0, 0, 0], stored_value=100)

    rtdose1.add_box(size=[1, 1, 1], center=[0, -14, 0], stored_value=200)
    rtdose1.add_box(size=[1, 1, 1], center=[0, -12, 0], stored_value=180)
    rtdose1.add_box(size=[1, 1, 1], center=[0, -10, 0], stored_value=160)
    rtdose1.add_box(size=[1, 1, 1], center=[0, -8, 0], stored_value=140)
    rtdose1.add_box(size=[1, 1, 1], center=[0, -6, 0], stored_value=120)
    rtdose1.add_box(size=[1, 1, 1], center=[0, -4, 0], stored_value=110)
    rtdose1.add_box(size=[1, 1, 1], center=[0, -2, 0], stored_value=105)
    rtdose1.add_box(size=[1, 1, 1], center=[0, 0, 0], stored_value=100)

    ############# second beam
    print "rtdose beam 2"
    rtdose2 = sb.build_dose(planbuilder=None,
                            num_voxels=[31, 31, 31],
                            voxel_size=[1, 1, 1],
                            row_direction=row_direction,
                            column_direction=column_direction)
    rtdose2.dose_grid_scaling = 0.5
    rtdose2.dose_summation_type = "BEAM"
    rtdose2.beam_number = 2

    rtdose2.add_box(size=[1, 1, 1], center=[14, 0, 0], stored_value=200)
    rtdose2.add_box(size=[1, 1, 1], center=[12, 0, 0], stored_value=180)
    rtdose2.add_box(size=[1, 1, 1], center=[10, 0, 0], stored_value=160)
    rtdose2.add_box(size=[1, 1, 1], center=[8, 0, 0], stored_value=140)
    rtdose2.add_box(size=[1, 1, 1], center=[6, 0, 0], stored_value=120)
    rtdose2.add_box(size=[1, 1, 1], center=[4, 0, 0], stored_value=110)
    rtdose2.add_box(size=[1, 1, 1], center=[2, 0, 0], stored_value=105)
    rtdose2.add_box(size=[1, 1, 1], center=[0, 0, 0], stored_value=100)

    rtdose2.add_box(size=[1, 1, 1], center=[-14, 0, 0], stored_value=200)
    rtdose2.add_box(size=[1, 1, 1], center=[-12, 0, 0], stored_value=180)
    rtdose2.add_box(size=[1, 1, 1], center=[-10, 0, 0], stored_value=160)
    rtdose2.add_box(size=[1, 1, 1], center=[-8, 0, 0], stored_value=140)
    rtdose2.add_box(size=[1, 1, 1], center=[-6, 0, 0], stored_value=120)
    rtdose2.add_box(size=[1, 1, 1], center=[-4, 0, 0], stored_value=110)
    rtdose2.add_box(size=[1, 1, 1], center=[-2, 0, 0], stored_value=105)
    rtdose2.add_box(size=[1, 1, 1], center=[0, 0, 0], stored_value=100)

    ############# third beam
    print "rtdose beam 3"
    rtdose3 = sb.build_dose(planbuilder=None,
                            num_voxels=[31, 31, 31],
                            voxel_size=[1, 1, 1],
                            row_direction=row_direction,
                            column_direction=column_direction)
    rtdose3.dose_grid_scaling = 0.5
    rtdose3.dose_summation_type = "BEAM"
    rtdose3.beam_number = 3

    rtdose3.add_box(size=[1, 1, 1], center=[14, 0, -12], stored_value=200)
    rtdose3.add_box(size=[1, 1, 1], center=[12, 0, -12], stored_value=180)
    rtdose3.add_box(size=[1, 1, 1], center=[10, 0, -12], stored_value=160)
    rtdose3.add_box(size=[1, 1, 1], center=[8, 0, -12], stored_value=140)
    rtdose3.add_box(size=[1, 1, 1], center=[6, 0, -12], stored_value=120)
    rtdose3.add_box(size=[1, 1, 1], center=[4, 0, -12], stored_value=110)
    rtdose3.add_box(size=[1, 1, 1], center=[2, 0, -12], stored_value=105)
    rtdose3.add_box(size=[1, 1, 1], center=[0, 0, -12], stored_value=100)

    rtdose3.add_box(size=[1, 1, 1], center=[-14, 0, -12], stored_value=200)
    rtdose3.add_box(size=[1, 1, 1], center=[-12, 0, -12], stored_value=180)
    rtdose3.add_box(size=[1, 1, 1], center=[-10, 0, -12], stored_value=160)
    rtdose3.add_box(size=[1, 1, 1], center=[-8, 0, -12], stored_value=140)
    rtdose3.add_box(size=[1, 1, 1], center=[-6, 0, -12], stored_value=120)
    rtdose3.add_box(size=[1, 1, 1], center=[-4, 0, -12], stored_value=110)
    rtdose3.add_box(size=[1, 1, 1], center=[-2, 0, -12], stored_value=105)
    rtdose3.add_box(size=[1, 1, 1], center=[0, 0, -12], stored_value=100)

    ############# fourth beam
    print "rtdose beam 4"
    rtdose4 = sb.build_dose(planbuilder=None,
                            num_voxels=[31, 31, 31],
                            voxel_size=[1, 1, 1],
                            row_direction=row_direction,
                            column_direction=column_direction)
    rtdose4.dose_grid_scaling = 0.5
    rtdose4.dose_summation_type = "BEAM"
    rtdose4.beam_number = 4

    rtdose4.add_box(size=[1, 1, 1], center=[14, 0, 12], stored_value=200)
    rtdose4.add_box(size=[1, 1, 1], center=[12, 0, 12], stored_value=180)
    rtdose4.add_box(size=[1, 1, 1], center=[10, 0, 12], stored_value=160)
    rtdose4.add_box(size=[1, 1, 1], center=[8, 0, 12], stored_value=140)
    rtdose4.add_box(size=[1, 1, 1], center=[6, 0, 12], stored_value=120)
    rtdose4.add_box(size=[1, 1, 1], center=[4, 0, 12], stored_value=110)
    rtdose4.add_box(size=[1, 1, 1], center=[2, 0, 12], stored_value=105)
    rtdose4.add_box(size=[1, 1, 1], center=[0, 0, 12], stored_value=100)

    rtdose4.add_box(size=[1, 1, 1], center=[-14, 0, 12], stored_value=200)
    rtdose4.add_box(size=[1, 1, 1], center=[-12, 0, 12], stored_value=180)
    rtdose4.add_box(size=[1, 1, 1], center=[-10, 0, 12], stored_value=160)
    rtdose4.add_box(size=[1, 1, 1], center=[-8, 0, 12], stored_value=140)
    rtdose4.add_box(size=[1, 1, 1], center=[-6, 0, 12], stored_value=120)
    rtdose4.add_box(size=[1, 1, 1], center=[-4, 0, 12], stored_value=110)
    rtdose4.add_box(size=[1, 1, 1], center=[-2, 0, 12], stored_value=105)
    rtdose4.add_box(size=[1, 1, 1], center=[0, 0, 12], stored_value=100)

    ############# second plan
    print "rtdose plan dose"
    rtdosePlan = sb.build_dose(planbuilder=None,
                               num_voxels=[31, 31, 31],
                               voxel_size=[1, 1, 1],
                               row_direction=row_direction,
                               column_direction=column_direction)
    rtdosePlan.dose_grid_scaling = 0.5
    rtdosePlan.dose_summation_type = "PLAN"
    rtdosePlan.beam_number = None

    rtdosePlan.pixel_array = numpy.add(rtdose2.pixel_array,
                                       rtdose1.pixel_array)
    rtdosePlan.pixel_array = numpy.add(rtdose3.pixel_array,
                                       rtdosePlan.pixel_array)
    rtdosePlan.pixel_array = numpy.add(rtdose4.pixel_array,
                                       rtdosePlan.pixel_array)

    return sb
Exemplo n.º 12
0
                    help="""Add an opening to the current list of mlc openings.
                    For syntax, see the forthcoming documentation or the source code...""")
parser.add_argument('--jaw-shape', dest='jawshapes', default=[], action='append',
                    help="""Sets the jaw shape to x * y, centered at (xc, yc).
                    Given as [x;y;xc;yc]. Defaults to conforming to the MLC.""")
parser.add_argument('--outdir', dest='outdir', default='.',
                    help="""Generate data to this directory. (default: working directory)""")
args = parser.parse_args(namespace=argparse.Namespace(studies=[[]]))

voxel_size = [float(x) for x in args.VoxelSize.split(",")]
num_voxels = [int(x) for x in args.NumVoxels.split(",")]

if not os.path.exists(args.outdir):
    os.makedirs(args.outdir)
for study in args.studies:
    sb = StudyBuilder()
    for series in study:
        if series.center.__class__ is str:
            series.center = [float(b) for b in series.center.lstrip('[').rstrip(']').split(";")]
        if series.modality == "CT":
            if 'PatientPosition' not in sb.current_study:
                parser.error("Patient position must be specified when writing CT images!")

            ib = sb.build_ct(
                num_voxels=num_voxels,
                voxel_size=voxel_size,
                pixel_representation=pixel_representations[series.pixel_representation],
                rescale_slope=series.rescale_slope,
                rescale_intercept=series.rescale_intercept,
                center=np.array(series.center))
        elif series.modality == "MR":
Exemplo n.º 13
0
def build_orientation(patient_position,
                      row_direction,
                      column_direction,
                      frame_of_reference_uid=None):
    sb = StudyBuilder(patient_position=patient_position,
                      patient_id="OrientationTests",
                      patient_name="Orientation^Tests",
                      patient_birthdate="20121212")
    if frame_of_reference_uid != None:
        sb.current_study['FrameOfReferenceUID'] = frame_of_reference_uid

    print "building %s..." % (patient_position, )
    print "ct"
    ct = sb.build_ct(num_voxels=[7, 7, 7],
                     voxel_size=[4, 4, 4],
                     pixel_representation=0,
                     rescale_slope=1,
                     rescale_intercept=-1024,
                     row_direction=row_direction,
                     column_direction=column_direction)
    ct.clear(real_value=-1000)
    ct.add_box(size=[4, 4, 4], center=[0, 0, 0], real_value=0)
    ct.add_box(size=[20, 4, 4], center=[0, -8, -8], real_value=0)
    ct.add_box(size=[4, 20, 4], center=[8, 0, -8], real_value=0)
    ct.add_box(size=[4, 4, 20], center=[8, 8, 0], real_value=0)
    ct.add_sphere(radius=4, center=[-8, -8, -8], real_value=0)

    print "rtstruct"
    rtstruct = sb.build_structure_set(ct)
    rtstruct.add_external_box()
    rtstruct.add_box(size=[4, 4, 4],
                     center=[0, 0, 0],
                     name='CenterVoxel',
                     interpreted_type='SITE')
    rtstruct.add_box(size=[20, 4, 4],
                     center=[0, -8, -8],
                     name='x=-8 to 8, y=z=-8',
                     interpreted_type='SITE')
    rtstruct.add_box(size=[4, 20, 4],
                     center=[8, 0, -8],
                     name='y=-8 to 8 x=8, z=-8',
                     interpreted_type='SITE')
    rtstruct.add_box(size=[4, 4, 20],
                     center=[8, 8, 0],
                     name='z=-8 to 8, x=y=8',
                     interpreted_type='SITE')
    rtstruct.add_sphere(radius=4,
                        center=[-8, -8, -8],
                        name='x=y=z=-8',
                        interpreted_type='SITE')
    rtstruct.build()

    print "rtplan"
    rtplan = sb.build_static_plan(structure_set=rtstruct, sad=20)
    b1 = rtplan.build_beam(gantry_angle=0, collimator_angle=30, meterset=100)
    b1.conform_to_rectangle(4, 4, [0, 0])
    b2 = rtplan.build_beam(gantry_angle=120, meterset=100)
    b2.conform_to_rectangle(4, 4, [4, 4])
    rtplan.build()

    print "rtdose"
    rtdose = sb.build_dose(planbuilder=rtplan)
    for beam in rtplan.beam_builders:
        rtdose.add_lightfield(beam.rtbeam, beam.meterset)

    return sb
Exemplo n.º 14
0
import builders
reload(builders)
import modules
reload(modules)
from builders import StudyBuilder
import matplotlib.pyplot as pp

import os
tmpdir = os.path.join(os.getenv("TEMP"), "studybuilder")
if not os.path.exists(tmpdir):
    os.mkdir(tmpdir)

sb = StudyBuilder(patient_position="HFS",
                  patient_id="123",
                  patients_name="Kalle^Kula",
                  patients_birthdate="20121212")
ct = sb.build_ct(num_voxels=[48, 64, 75],
                 voxel_size=[4, 3, 4],
                 pixel_representation=0,
                 rescale_slope=1,
                 rescale_intercept=-1024)
ct.clear(real_value=0)
print ct.pixel_array.max(), ct.pixel_array.min()
ct.add_sphere(radius=25, center=[0, 0, 0], real_value=-1000, mode='set')
print ct.pixel_array.max(), ct.pixel_array.min()
ct.add_box(size=[25, 50, 25], center=[0, 0, 0], stored_value=300, mode='add')
print ct.pixel_array.max(), ct.pixel_array.min()

assert sb.seriesbuilders['CT'] == [ct]

rtstruct = sb.build_structure_set()
Exemplo n.º 15
0
import builders
reload(builders)
import modules
reload(modules)
from builders import StudyBuilder
import matplotlib.pyplot as pp

import os
tmpdir = os.path.join(os.getenv("TEMP"), "studybuilder")
if not os.path.exists(tmpdir):
    os.mkdir(tmpdir)

sb = StudyBuilder(patient_position="HFS", patient_id="123", patient_name="Kalle^Kula", patient_birthdate = "20121212")
ct = sb.build_ct(
    num_voxels=[48, 64, 75],
    voxel_size=[4, 3, 4],
    pixel_representation=0,
    rescale_slope=1,
    rescale_intercept=-1024)
ct.clear(real_value = 0)
print ct.pixel_array.max(),ct.pixel_array.min()
ct.add_sphere(radius = 25, center = [0,0,0], real_value = -1000, mode = 'set')
print ct.pixel_array.max(),ct.pixel_array.min()
ct.add_box(size = [25,50,25], center = [0,0,0], stored_value = 300, mode = 'add')
print ct.pixel_array.max(),ct.pixel_array.min()

assert sb.seriesbuilders['CT'] == [ct]

rtstruct = sb.build_structure_set()
rtstruct.add_external_box()
sph = rtstruct.add_sphere(radius=70, center = [-50,0,-100], name='Sph-Organ', interpreted_type='CAVITY')
Exemplo n.º 16
0
def build_orientation(patient_position,
                      column_direction,
                      row_direction,
                      frame_of_reference_uid=None):
    sb = StudyBuilder(patient_position=patient_position,
                      patient_id="doseDifferentMax",
                      patient_name="doseDifferentMax",
                      patient_birthdate="20121212")
    if frame_of_reference_uid != None:
        sb.current_study['FrameOfReferenceUID'] = frame_of_reference_uid

    print "building %s..." % (patient_position, )
    print "ct"
    ct = sb.build_ct(num_voxels=[7, 7, 7],
                     voxel_size=[4, 4, 4],
                     pixel_representation=0,
                     rescale_slope=1,
                     rescale_intercept=-1024,
                     row_direction=row_direction,
                     column_direction=column_direction)
    ct.clear(real_value=-1000)
    ct.add_box(size=[4, 4, 4], center=[0, 0, 0], real_value=0)
    ct.add_box(size=[20, 4, 4], center=[0, -8, -8], real_value=0)
    ct.add_box(size=[4, 20, 4], center=[8, 0, -8], real_value=0)
    ct.add_box(size=[4, 4, 20], center=[8, 8, 0], real_value=0)
    ct.add_sphere(radius=4, center=[-8, -8, -8], real_value=0)

    print "rtstruct"
    rtstruct = sb.build_structure_set(ct)
    rtstruct.add_external_box()
    rtstruct.add_box(size=[4, 4, 4],
                     center=[0, 0, 0],
                     name='CenterVoxel',
                     interpreted_type='SITE')
    rtstruct.add_box(size=[20, 4, 4],
                     center=[0, -8, -8],
                     name='x=-8 to 8, y=z=-8',
                     interpreted_type='SITE')
    rtstruct.add_box(size=[4, 20, 4],
                     center=[8, 0, -8],
                     name='y=-8 to 8 x=8, z=-8',
                     interpreted_type='SITE')
    rtstruct.add_box(size=[4, 4, 20],
                     center=[8, 8, 0],
                     name='z=-8 to 8, x=y=8',
                     interpreted_type='SITE')
    rtstruct.add_sphere(radius=4,
                        center=[-8, -8, -8],
                        name='x=y=z=-8',
                        interpreted_type='SITE')
    rtstruct.build()

    print "rtstruct 2 not connected to the plan"
    rtstruct2 = sb.build_structure_set(ct)
    rtstruct2.add_external_box()
    rtstruct2.add_sphere(radius=4,
                         center=[0, 0, 0],
                         name='center sphere',
                         interpreted_type='SITE')
    rtstruct2.build()

    print "rtplan"
    rtplan = sb.build_static_plan(structure_set=rtstruct, sad=20)
    b1 = rtplan.build_beam(gantry_angle=0, collimator_angle=30, meterset=100)
    b1.conform_to_rectangle(4, 4, [0, 0])
    b2 = rtplan.build_beam(gantry_angle=120, meterset=100)
    b2.conform_to_rectangle(4, 4, [4, 4])
    rtplan.build()

    print "rtdose beam 1"
    rtdose1 = sb.build_dose(planbuilder=None,
                            num_voxels=[7, 9, 5],
                            voxel_size=[3, 1, 1],
                            row_direction=row_direction,
                            column_direction=column_direction)
    rtdose1.dose_grid_scaling = 0.01
    rtdose1.dose_summation_type = "BEAM"
    rtdose1.beam_number = 1

    rtdose1.add_box(size=[3, 1, 1], center=[0, -3, 0], stored_value=100)
    rtdose1.add_box(size=[3, 1, 1], center=[0, -2, 0], stored_value=91)
    rtdose1.add_box(size=[3, 1, 1], center=[0, -1, 0], stored_value=81)
    rtdose1.add_box(size=[3, 1, 1], center=[0, 0, 0], stored_value=71)
    rtdose1.add_box(size=[3, 1, 1], center=[0, 1, 0], stored_value=61)
    rtdose1.add_box(size=[3, 1, 1], center=[0, 2, 0], stored_value=51)
    rtdose1.add_box(size=[3, 1, 1], center=[0, 3, 0], stored_value=0)

    ############# second beam
    print "rtdose beam 2"
    rtdose2 = sb.build_dose(planbuilder=None,
                            num_voxels=[7, 9, 5],
                            voxel_size=[3, 1, 1],
                            row_direction=row_direction,
                            column_direction=column_direction)
    rtdose2.dose_grid_scaling = 0.01
    rtdose2.dose_summation_type = "BEAM"
    rtdose2.beam_number = 2

    rtdose2.add_box(size=[3, 1, 1], center=[-9, 0, 0], stored_value=100)
    rtdose2.add_box(size=[3, 1, 1], center=[-6, 0, 0], stored_value=91)
    rtdose2.add_box(size=[3, 1, 1], center=[-3, 0, 0], stored_value=81)
    rtdose2.add_box(size=[3, 1, 1], center=[0, 0, 0], stored_value=71)
    rtdose2.add_box(size=[3, 1, 1], center=[3, 0, 0], stored_value=61)
    rtdose2.add_box(size=[3, 1, 1], center=[6, 0, 0], stored_value=51)
    rtdose2.add_box(size=[3, 1, 1], center=[9, 0, 0], stored_value=0)

    ############# second plan
    print "rtdose plan dose"
    rtdosePlan = sb.build_dose(planbuilder=None,
                               num_voxels=[7, 9, 5],
                               voxel_size=[3, 1, 1],
                               row_direction=row_direction,
                               column_direction=column_direction)
    rtdosePlan.dose_grid_scaling = 0.01
    rtdosePlan.dose_summation_type = "PLAN"
    rtdosePlan.beam_number = None

    rtdosePlan.pixel_array = numpy.add(rtdose2.pixel_array,
                                       rtdose1.pixel_array)

    return sb
Exemplo n.º 17
0
def build_orientation(patient_position,
                      column_direction,
                      row_direction,
                      frame_of_reference_uid=None):
    sb = StudyBuilder(patient_position=patient_position,
                      patient_id="OrientationTests",
                      patient_name="Orientation^Tests",
                      patient_birthdate="20121212")
    if frame_of_reference_uid != None:
        sb.current_study['FrameOfReferenceUID'] = frame_of_reference_uid

    print "building %s..." % (patient_position, )
    print "ct"
    ct = sb.build_ct(num_voxels=[7, 7, 7],
                     voxel_size=[4, 4, 4],
                     pixel_representation=0,
                     rescale_slope=1,
                     rescale_intercept=-1024,
                     row_direction=row_direction,
                     column_direction=column_direction)
    ct.clear(real_value=-1000)
    ct.add_box(size=[4, 4, 4], center=[0, 0, 0], real_value=0)
    ct.add_box(size=[20, 4, 4], center=[0, -8, -8], real_value=0)
    ct.add_box(size=[4, 20, 4], center=[8, 0, -8], real_value=0)
    ct.add_box(size=[4, 4, 20], center=[8, 8, 0], real_value=0)
    ct.add_sphere(radius=4, center=[-8, -8, -8], real_value=0)

    print "rtstruct"
    rtstruct = sb.build_structure_set(ct)
    rtstruct.add_external_box()
    rtstruct.add_box(size=[4, 4, 4],
                     center=[0, 0, 0],
                     name='CenterVoxel',
                     interpreted_type='SITE')
    rtstruct.add_box(size=[20, 4, 4],
                     center=[0, -8, -8],
                     name='x=-8 to 8, y=z=-8',
                     interpreted_type='SITE')
    rtstruct.add_box(size=[4, 20, 4],
                     center=[8, 0, -8],
                     name='y=-8 to 8 x=8, z=-8',
                     interpreted_type='SITE')
    rtstruct.add_box(size=[4, 4, 20],
                     center=[8, 8, 0],
                     name='z=-8 to 8, x=y=8',
                     interpreted_type='SITE')
    rtstruct.add_sphere(radius=4,
                        center=[-8, -8, -8],
                        name='x=y=z=-8',
                        interpreted_type='SITE')
    rtstruct.build()

    print "rtplan"
    rtplan = sb.build_static_plan(structure_set=rtstruct, sad=20)
    b1 = rtplan.build_beam(gantry_angle=0, collimator_angle=30, meterset=100)
    b1.conform_to_rectangle(4, 4, [0, 0])
    b2 = rtplan.build_beam(gantry_angle=120, meterset=100)
    b2.conform_to_rectangle(4, 4, [4, 4])
    rtplan.build()

    print "rtdose beam 1"
    rtdose1 = sb.build_dose(planbuilder=rtplan)
    rtdose1.dose_grid_scaling = 1
    rtdose1.dose_summation_type = "BEAM"
    rtdose1.beam_number = 1

    rtdose1.add_box(size=[4, 4, 4], center=[0, -12, 0],
                    stored_value=65535)  #100%
    rtdose1.add_box(size=[4, 4, 4], center=[0, -8, 0],
                    stored_value=39321)  #60%
    rtdose1.add_box(size=[4, 4, 4], center=[0, -4, 0],
                    stored_value=38665)  #59%
    rtdose1.add_box(size=[4, 4, 4], center=[0, 0, 0], stored_value=32767)  #50%
    rtdose1.add_box(size=[4, 4, 4], center=[0, 4, 0], stored_value=32112)  #49%
    rtdose1.add_box(size=[4, 4, 4], center=[0, 8, 0], stored_value=15728)  #24%
    rtdose1.add_box(size=[4, 4, 4], center=[0, 12, 0], stored_value=0)  #0%

    ############# second beam
    print "rtdose beam 2"
    rtdose2 = sb.build_dose(planbuilder=rtplan)
    rtdose2.dose_grid_scaling = 1
    rtdose2.dose_summation_type = "BEAM"
    rtdose2.beam_number = 2

    rtdose2.add_box(size=[4, 4, 4], center=[-12, 0, 0],
                    stored_value=65535)  # 100%
    rtdose2.add_box(size=[4, 4, 4], center=[-8, 0, 0],
                    stored_value=62259)  # 95%
    rtdose2.add_box(size=[4, 4, 4], center=[-4, 0, 0],
                    stored_value=61602)  # 94%
    rtdose2.add_box(size=[4, 4, 4], center=[0, 0, 0],
                    stored_value=32767)  # 50%
    rtdose2.add_box(size=[4, 4, 4], center=[4, 0, 0],
                    stored_value=52428)  # 80%
    rtdose2.add_box(size=[4, 4, 4], center=[8, 0, 0],
                    stored_value=51772)  # 79%
    rtdose2.add_box(size=[4, 4, 4], center=[12, 0, 0],
                    stored_value=15728)  # 24%

    ############# second plan
    print "rtdose plan dose"
    rtdosePlan = sb.build_dose(planbuilder=rtplan)
    rtdosePlan.dose_grid_scaling = 1
    rtdosePlan.dose_summation_type = "PLAN"
    rtdosePlan.beam_number = None

    rtdosePlan.pixel_array = numpy.add(rtdose2.pixel_array,
                                       rtdose1.pixel_array)

    return sb