source/dcm_transform.py
def compute_3d_transforms(dataset, args):
    """Compute all 3d transforms (translation/rotation) and update"""

    if not is_3d_tranformation(args):
        return

    # Generate new UIDs automatically when any transform changes the geometry
    generate_new_uids(dataset, args.suid, args.foruid,
                      generate_soiud_from_seriesuid(args.suid, dataset.InstanceNumber))

    pos = [dataset.ImagePositionPatient[0].real,
           dataset.ImagePositionPatient[1].real, dataset.ImagePositionPatient[2].real, 1.]
    row = [dataset.ImageOrientationPatient[0].real,
           dataset.ImageOrientationPatient[1].real, dataset.ImageOrientationPatient[2].real, 1.]
    col = [dataset.ImageOrientationPatient[3].real,
           dataset.ImageOrientationPatient[4].real, dataset.ImageOrientationPatient[5].real, 1.]
    xform = np.identity(4)

    matrix_set_rotation(xform, args.ax, args.ay, args.az)

    precision = 5
    new_row = np.around(xform.dot(row), precision)
    new_col = np.around(xform.dot(col), precision)
    new_orient = np.concatenate([new_row[:3], new_col[:3]])

    matrix_set_translation(xform, args.x, args.y, args.z)
    new_pos = np.around([pos[0] + args.x, pos[1] + args.y, pos[2] + args.z], precision)

    # update dataset with new values
    set_str_vec(dataset.ImagePositionPatient, new_pos[:3], 3)
    set_str_vec(dataset.ImageOrientationPatient, new_orient[:6], 6)
Compute all 3d transforms (translation/rotation) and update
Compute all 3d transforms (translation/rotation) and update
Compute all 3d transforms ( translation / rotation ) and update
def compute_3d_transforms(dataset, args):
    if not is_3d_tranformation(args):
        return
    generate_new_uids(dataset, args.suid, args.foruid,
                      generate_soiud_from_seriesuid(args.suid, dataset.InstanceNumber))
    pos = [dataset.ImagePositionPatient[0].real,
           dataset.ImagePositionPatient[1].real, dataset.ImagePositionPatient[2].real, 1.]
    row = [dataset.ImageOrientationPatient[0].real,
           dataset.ImageOrientationPatient[1].real, dataset.ImageOrientationPatient[2].real, 1.]
    col = [dataset.ImageOrientationPatient[3].real,
           dataset.ImageOrientationPatient[4].real, dataset.ImageOrientationPatient[5].real, 1.]
    xform = np.identity(4)
    matrix_set_rotation(xform, args.ax, args.ay, args.az)
    precision = 5
    new_row = np.around(xform.dot(row), precision)
    new_col = np.around(xform.dot(col), precision)
    new_orient = np.concatenate([new_row[:3], new_col[:3]])
    matrix_set_translation(xform, args.x, args.y, args.z)
    new_pos = np.around([pos[0] + args.x, pos[1] + args.y, pos[2] + args.z], precision)
    set_str_vec(dataset.ImagePositionPatient, new_pos[:3], 3)
    set_str_vec(dataset.ImageOrientationPatient, new_orient[:6], 6)
def compute_3d_transforms ( dataset , args ) : if not is_3d_tranformation ( args ) : return generate_new_uids ( dataset , args . suid , args . foruid , generate_soiud_from_seriesuid ( args . suid , dataset . InstanceNumber ) ) pos = [ dataset . ImagePositionPatient [ 0 ] . real , dataset . ImagePositionPatient [ 1 ] . real , dataset . ImagePositionPatient [ 2 ] . real , 1. ] row = [ dataset . ImageOrientationPatient [ 0 ] . real , dataset . ImageOrientationPatient [ 1 ] . real , dataset . ImageOrientationPatient [ 2 ] . real , 1. ] col = [ dataset . ImageOrientationPatient [ 3 ] . real , dataset . ImageOrientationPatient [ 4 ] . real , dataset . ImageOrientationPatient [ 5 ] . real , 1. ] xform = np . identity ( 4 ) matrix_set_rotation ( xform , args . ax , args . ay , args . az ) precision = 5 new_row = np . around ( xform . dot ( row ) , precision ) new_col = np . around ( xform . dot ( col ) , precision ) new_orient = np . concatenate ( [ new_row [ : 3 ] , new_col [ : 3 ] ] ) matrix_set_translation ( xform , args . x , args . y , args . z ) new_pos = np . around ( [ pos [ 0 ] + args . x , pos [ 1 ] + args . y , pos [ 2 ] + args . z ] , precision ) set_str_vec ( dataset . ImagePositionPatient , new_pos [ : 3 ] , 3 ) set_str_vec ( dataset . ImageOrientationPatient , new_orient [ : 6 ] , 6 )
Compute all 3d transforms (translation/rotation) and update
Compute all 3d transforms ( translation / rotation ) and update
"""Compute all 3d transforms (translation/rotation) and update""" # Generate new UIDs automatically when any transform changes the geometry # update dataset with new values
dataset
args