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

 

Multiple Modify Operator and Specimen
Function
Allows the Microscope Info tag data - operator and specimen - to be modified on all currently open images.
Version
version:20021101, v1.0
Author
D. R. G. Mitchell
Acknowledgements
-
Comments
This is useful where images have been acquired with the incorrect operator and/or specimen details. See the companion scripts 'Display Operator and Specimen' and 'Set Operator and Specimen'.
System Requirements
Should be compatible with all recent versions of DigitalMicrograph.
Known Issues
Images to be modified must be first saved.
Supported
Yes
Included Files
Main script file.
Source Code

If (shiftdown())

{

documentwindow reswin

reswin =getresultswindow(1)

if(reswin.windowisvalid()) windowclose(reswin,0)

reswin =getresultswindow(1)

WindowSetFramePosition( reswin, 142, 482)

WindowSetFrameSize( reswin, 750, 220 )

WindowSetTitle( reswin, "Instructions")

 

result("This script edits existing files to modify the Microscope Info tags: operator and specimen."+"\n")

result("Use this script to correct files which you saved with the wrong specimen and/or username by mistake."+"\n\n")

result("1 Make sure all the images of interest are open then run the script."+"\n")

result("2 Enter the revised User Name and Specimen number and the files will then be saved over the originals."+"\n")

result("3 This script only works on images which have already been saved"+"\n\n")

result("D. Mitchell, Nov 2002.")

exit(0)

}

 

// version:20021101

// v1.0

// D. R. G. Mitchell, Nov. 2002

// adminnospam@dmscripting.com (remove the nospam to make this email address work)

 

// Count the number of open images (type 5) and exit if none shown

 

number shownimages=countdocumentwindowsoftype(5)

if(shownimages<1) exit(0)

 

 

// Setting up the foremost image and defining the variables

 

image frontimage:=getfrontimage()

string filename= getname(frontimage)

string tempstring

number count, length, tempno, i

string username, specname

 

 

while(3>2)

{

 

if(!getstring("Enter Operator Name - be consistent","TEM User",username)) exit(0)

if (username!="TEM User") break

}

 

 

while (3>2)

{

if(!getstring("Enter Specimen Name","Specimen No",specname)) exit(0)

if (specname!="Specimen No") break

}

 

 

// Loop to save each image

 

for(i=0; i<shownimages;++i)

{

frontImage := GetFrontImage()

 

// Regardless of whether a tag exists or not, Operator Name and Specimen Name are written

 

 

SetStringNote( frontimage, "Microscope Info:Operator", username )

SetStringNote( frontimage, "Microscope Info:Specimen", specname )

save(frontimage)

deleteimage(frontimage)

}

okdialog("Finished!")