def WriteControls(filename, data):
    """Write current values to a .imctrl (Image Controls) file"""
    File = open(filename, 'w')
    keys = ['type', 'color', 'wavelength', 'calibrant', 'distance',
        'center', 'Oblique', 'tilt', 'rotation', 'azmthOff',
        'fullIntegrate', 'LRazimuth', 'setdist', 'IOtth', 'outChannels',
        'outAzimuths', 'invert_x', 'invert_y', 'DetDepth', 'calibskip',
        'pixLimit', 'cutoff', 'calibdmin', 'Flat Bkg', 'varyList',
        'binType', 'SampleShape', 'PolaVal', 'SampleAbs', 'dark image',
        'background image', 'twoth']
    for key in keys:
        if key not in data:
            continue
        File.write(key + ':' + str(data[key]) + '\n')
    File.close()
