【发布时间】:2021-03-31 22:07:08
【问题描述】:
我正在尝试模仿 GMS v3 中的自动保存功能,以便可以在版本 1 和 2 中使用。我想首先承认脚本的主要内容来自 Bernhard Schaffer 博士的“如何编写脚本...数字显微照片脚本手册”。我对其进行了一些修改,以便相机记录的任何新图像都可以自动保存到文件中。但是,我遇到了一些问题,因为如果我决定单击实时取景图像并移动图像,或者使用 live-fft,实时取景图像或 FFT 图像也会被保存。我的想法之一是使用标记组信息,例如“Acquisition:Parameters:Parameter Set Name”,因为对于实时视图或实时 FFT,这将处于搜索或焦点模式。另一个想法是使用文档 ID,例如 iDocID = idoc.ImageDocumentGETID() 来定位实时图像的 ID。但是,我不知道如何使用这些信息将它们排除在自动保存之外。谁能指出我如何继续这个脚本? 下面是脚本
Class PeriodicAutoSave : Object
{
Number output
PeriodicAutoSave(Object self) Result("\n Object ID"+self.ScriptObjectGetID()+" created.")
~PeriodicAutoSave(Object self) Result("\n Object ID"+self.ScriptObjectGetID()+" destroyed")
Void Init2(Object self, Number op)
output=op
Void AutoSave_SaveAll(Object self)
{
String path, name, targettype, targettype1, area, mag, mode, search, result1
ImageDocument idoc
Number nr_idoc, count, index_i, index, iDocID, iDocID_search
path = "c:\\path\\"
name = "test"
targettype=="Gatan Format (*.dm4)"
targettype1 = "dm4"
If (output) Result("\n AutoSave...")
nr_idoc = CountImageDocuments()
For (count = 1; count<nr_idoc; count++)
{
idoc = GetImageDocument(count) //imagedocument
index = 1 // user decide the index to start with
index_i= nr_idoc - index
If (idoc.ImageDocumentIsDirty())
{
idoc = getfrontimagedocument()
iDocID = idoc.ImageDocumentGetID()
TagGroup tg = ImageGetTagGroup(idoc.ImageDocumentGetImage(0)) // cannot declare an 'img' for this line as it will prompt an error?
tg.TagGroupGetTagAsString("Microscope Info:Formatted Indicated Mag", mag)
Try{
{
idoc.ImageDocumentSavetoFile( "Gatan Format", path+index_i+"-"+name+"-"+mag+".dm4")
idoc.ImageDocumentSetName(index_i + "-"+name+"-"+mag+".dm4")
idoc.ImageDocumentClean()
}
If (Output) Result("\n\t saving: "+idoc.ImageDocumentGetCurrentFile())
}
Catch{
Result("\n image cannot be saved at the moment:" + GetExceptionString())
Break
}
Result("\ Continue autosave...")
}
}
}
}
Void LaunchAutoSave()
{
Object obj = Alloc(PeriodicAutoSave)
obj.Init2(2)
Number task_id = obj.AddMainThreadPeriodicTask("AutoSave_SaveALL",6)
//Sleep(10)
while(!shiftdown()) 1==2
RemoveMainThreadTask(task_id)
}
LaunchAutoSave()
【问题讨论】:
标签: dm-script