def main():
    task =  SR_EELS_CharacterisationPlugin()
    task.setRotation(do_rotate)
    settings = SR_EELS_CharacterisationSettings()
    settings.path = in_dir
    settings.images = task.getImages(settings)
    task.performCharacterisation(settings)
    flags = 0
    if create_jpeg:
     flags += SR_EELS_CharacterisationResults.JPEG
    if create_plots:
     flags += SR_EELS_CharacterisationResults.PLOTS
    if create_tiff:
     flags += SR_EELS_CharacterisationResults.TIFF
    if create_csv:
     flags += SR_EELS_CharacterisationResults.CSV
    if create_subdir:
        final_out_dir = File(out_dir, settings.toString())
    else:
        final_out_dir = out_dir
    task.saveResults(final_out_dir, flags)
def main():
    automated_characterisation = AutomatedCharacterisation()
    automated_characterisation.create_dataset_list()
    settings = SR_EELS_CharacterisationSettings()
    settings.stepSize = stepSize
    settings.filterRadius = math.sqrt(stepSize)
    settings.energyBorderLow = energyBorderLow
    settings.energyBorderHigh = energyBorderHigh
    settings.energyPosition = energyPosition
    settings.polynomialOrder = polynomialOrder
    settings.useThresholding = useThresholding
    settings.threshold = threshold
    finished = skipped = failed = 0
    dataset_count = len(automated_characterisation.datasets)
    IJ.log('Processing %d datasets.' % (dataset_count,))
    count = 0
    for dataset in automated_characterisation.datasets:
    	count += 1
        if not os.path.exists(os.path.join(dataset, settings.toString())):
            IJ.log('%d/%d Starting to process "%s".' % (count, dataset_count, dataset))
            images = ArrayList()
            for image in os.listdir(dataset):
                if re.search('Cal_\d+\.tif', image):
                    images.add(image)
            settings.images = images
            settings.path = File(dataset)
            try:
                characterisation = SR_EELS_CharacterisationPlugin()
                characterisation.performCharacterisation(settings)
                results_path = File(settings.path, settings.toString())                
                characterisation.saveResults(results_path, types)
                finished += 1
            except RuntimeException:
                IJ.log('%d/%d There was an error when processing "%s"!' % (count, dataset_count, dataset))
                failed += 1
        else:
            IJ.log('%d/%d Skipping "%s" as results for "%s" exist.' % (count, dataset_count, dataset, settings.toString()))
            skipped += 1
    IJ.log('\nFinished automated SR-EELS characterisation:')
    IJ.log('Finished: %d\nSkipped: %d\nFailed: %d' % (finished, skipped, failed))