コード例 #1
0
def update_hm(m2m_dir):
    eeg_positions = os.path.join(m2m_dir, "eeg_positions")
    print("Transforming EEG positions")
    if not os.path.exists(eeg_positions):
        os.mkdir(eeg_positions)
    cap_file = os.path.abspath(
        os.path.realpath(
            os.path.join(SIMNIBSDIR, 'resources', 'ElectrodeCaps_MNI',
                         'EEG10-10_UI_Jurak_2007.csv')))
    cap_out = os.path.join(eeg_positions, 'EEG10-10_UI_Jurak_2007.csv')
    geo_out = os.path.join(eeg_positions, 'EEG10-10_UI_Jurak_2007.geo')
    warp_coordinates(cap_file,
                     m2m_dir,
                     out_name=cap_out,
                     transformation_direction='mni2subject',
                     out_geo=geo_out)
コード例 #2
0
def main():
    args = parse_arguments(sys.argv[1:])
    m2m_dir = os.path.abspath(
        os.path.realpath(os.path.expanduser(args.m2mpath)))
    if not os.path.isdir(m2m_dir):
        raise IOError('Could not find directory: {0}'.format(args.m2mpath))
    if args.out is not None:
        fn_out = os.path.abspath(os.path.realpath(os.path.expanduser(
            args.out)))
        fn_geo = os.path.splitext(fn_out)[0] + '.geo'
    else:
        fn_out = None
        fn_geo = None

    if args.coords is not None:
        coords = [float(d) for d in args.coords]

    elif args.csv is not None:
        coords = os.path.abspath(os.path.realpath(os.path.expanduser(
            args.csv)))
        if not os.path.isfile(coords):
            raise IOError('Could not find CSV file: {0}'.format(args.csv))
    else:
        raise argparse.ArgumentTypeError('Plase use either -c or -s')

    if args.coords is not None and args.csv is not None:
        raise argparse.ArgumentError('Please use only -c or -s')

    coords = transformations.warp_coordinates(
        coords,
        m2m_dir,
        out_name=fn_out,
        transformation_direction='mni2subject',
        transformation_type=args.t,
        out_geo=fn_geo)[1]
    if fn_out is None:
        np.set_printoptions(precision=2,
                            formatter={'float': lambda x: '{0:.2f}'.format(x)})
        print('Transformed coodinates:\n{0}'.format(coords.squeeze()))
コード例 #3
0
        fn_geo = os.path.splitext(fn_out)[0] + '.geo'
    else:
        fn_out = None
        fn_geo = None

    if args.coords is not None:
        coords = np.array([float(d) for d in args.coords])

    elif args.csv is not None:
        coords = os.path.abspath(os.path.realpath(os.path.expanduser(
            args.csv)))
        if not os.path.isfile(coords):
            raise IOError('Could not find CSV file: {0}'.format(args.csv))
    else:
        raise argparse.ArgumentTypeError('Plase use either -c or -s')

    if args.coords is not None and args.csv is not None:
        raise argparse.ArgumentError('Please use only -c or -s')

    coords = transformations.warp_coordinates(
        coords,
        m2m_dir,
        out_name=fn_out,
        transformation_direction='subject2mni',
        transformation_type=args.t,
        out_geo=fn_geo)[1]
    if fn_out is None:
        np.set_printoptions(precision=2,
                            formatter={'float': lambda x: '{0:.2f}'.format(x)})
        print('Transformed coodinates:\n{0}'.format(coords.squeeze()))