Пример #1
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
Пример #2
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
Пример #3
0
                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":
            if 'PatientPosition' not in sb.current_study:
                parser.error("Patient position must be specified when writing MR images!")

            ib = sb.build_mr(
                num_voxels=num_voxels,
                voxel_size=voxel_size,
                pixel_representation=pixel_representations[series.pixel_representation],
                center=np.array(series.center))
        elif series.modality == "PT":
            if 'PatientPosition' not in sb.current_study:
                parser.error("Patient position must be specified when writing MR images!")

            ib = sb.build_pt(
                num_voxels=num_voxels,
                voxel_size=voxel_size,
                pixel_representation=pixel_representations[series.pixel_representation],
                rescale_slope=series.rescale_slope,
                center=np.array(series.center))
        elif series.modality == "RTDOSE":
            ib = sb.build_dose(
                num_voxels=num_voxels,
Пример #4
0
                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":
            if 'PatientPosition' not in sb.current_study:
                parser.error("Patient position must be specified when writing MR images!")

            ib = sb.build_mr(
                num_voxels=num_voxels,
                voxel_size=voxel_size,
                pixel_representation=pixel_representations[series.pixel_representation],
                center=np.array(series.center))
        elif series.modality == "PT":
            if 'PatientPosition' not in sb.current_study:
                parser.error("Patient position must be specified when writing MR images!")

            ib = sb.build_pt(
                num_voxels=num_voxels,
                voxel_size=voxel_size,
                pixel_representation=pixel_representations[series.pixel_representation],
                rescale_slope=series.rescale_slope,
                center=np.array(series.center))
        elif series.modality == "RTDOSE":
            ib = sb.build_dose(
                num_voxels=num_voxels,