Ejemplo n.º 1
0
def transform_image(in_filename, out_filename, reference_filename,
                    in_transforms, interpolation_method, verbose_flag,
                    debug_flag):

    if type(in_filename) is list:
        filename = in_filename
    else:
        filename = [in_filename]

    if type(in_transforms) is list:
        transforms = in_transforms
    else:
        transforms = [in_transforms]

    input_files = filename + reference_filename + transforms

    if debug_flag:
        print('\n')
        print('!!! ctf.transform_image ')
        print(input_files)
        print('\n')

    util.verify_inputs(filename)

    cmd = [
        "antsApplyTransforms", "-d", "3", "-i", in_filename[0], "-o",
        out_filename[0], "-r", reference_filename[0], "-n",
        interpolation_method, "-t"
    ] + transforms

    util.iw_subprocess(cmd, debug_flag, debug_flag)
Ejemplo n.º 2
0
def transform_points(in_filename, out_filename, in_transforms, scale,
                     verbose_flag, debug_flag):

    if type(in_filename) is list:
        filename = in_filename
    else:
        filename = [in_filename]

    if type(in_transforms) is list:
        transforms = in_transforms
    else:
        transforms = [in_transforms]

    input_files = filename + transforms

    if debug_flag:
        print('\n')
        print('!!! ctf.transform_points ')
        print(input_files)
        print('\n')

    util.verify_inputs(filename)

    in_points = print_points_from_file(in_filename, verbose_flag)

    cmd = [
        "antsApplyTransformsToPoints", "-d", "3", "-i", in_filename, "-o",
        out_filename, "-t"
    ] + transforms

    util.iw_subprocess(cmd, debug_flag, debug_flag)

    # Perform scaling

    out_points = pd.read_csv(out_filename, sep=',', header=0)
    out_points = scale_points(out_points, scale, debug_flag)

    # Fix Comment Column
    out_points['label'] = in_points['label']
    out_points['comment'] = in_points['comment']

    #
    write_points(out_filename, out_points, verbose_flag)
Ejemplo n.º 3
0
    step_01 = numpy.where(data > 0)
    label = numpy.extract(data > 0, data)

    x = step_01[0].tolist()
    y = step_01[1].tolist()
    z = step_01[2].tolist()

    if nshape[3] > 1:
        t = step_01[3].tolist()
    else:
        t = 0 * len(x)

    comment = [' '] * len(x)

    util.verify_inputs([inArgs.in_label], inArgs.debug)

    tmp = pandas.DataFrame(
        {
            'x': x,
            'y': y,
            'z': z,
            't': t,
            'label': label,
            'comment': comment
        },
        columns=['x', 'y', 'z', 't', 'label', 'comment'])
    iras_points = tmp.sort_values(['label', 'x', 'y', 'z', 't'],
                                  ascending=[1, 1, 1, 1, 1])

    labels.write_points(out_filename, iras_points, inArgs.verbose)