Scripting Resources for DigitalMicrograph™

banner

Dave Mitchell's DigitalMicrograph™ Scripting Website

Home | Scripts | Examples | Functions | Recent Updates | Tutorials | Resources | Publications | Consulting | Projects | Contact & Bio |PyJEM| Search

 

Folder Rebinner
Function
Rebins folders of images.
Version
version:20220223, v1.1
Author
D. R. G. Mitchell
Acknowledgements
Thanks to Lachlan Smillie for testing this script.
Comments

This dialog-based script will rebin folders of 2D .dm4 images. The dialog provides an option to add 'binning Nx' to the end of the filename (where N is the rebinning used (2, 4 or 8x)). Rebinned files can be either saved as a copy (nested inside the target folder in a folder called 'Rebinned') or they can overwrite existing files - but only where the option to add the rebinning value to the filename is not used ie the source data is always preserved. Any 1D or 3D images, such as spectra or spectrum images, are ignored. Rebinned images are flagged that they have been rebinned. If an attempt to rebin such an image is detected, the option to proceed or cancel is provided.

Updated in v1.1 to deal with a change in the rebin() function between GMS 2 and 3. The function changes the image in place in GMS 2.x, but in GMS 3.x it returns a rebinned image. In order to make this script universal, I used my own rebinning function to get around this difference.

System Requirements
Tested under GMS 2.3 and GMS 3.2 but should work with earlier versions.
Known Issues

GMS 2.x (at least my installation of it) has some permissions issues which prevent it from creating a new folder in which to save files. In this script when the Copy option is selected, the script should create a folder called Rebinned, nested within the folder containing the target images, and all rebinned images should get saved there. In GMS 2.x this option throws an error, saying 'this type of directory is not recognised'. In GMS 3.x it works fine. If you are using GMS 2.x and this happens to you, you can get round the problem by choosing the Replace instead of the Copy option and select the option to append . . rebin Nx to the filename. This will create copies of the files with revised names and the original data files will not get written over.

Supported
Yes
Included Files
Script file.
Source Code

See attached zip archive