首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在DM-script中排除Gatan Digital Micrograph (GMS)中自动保存的某些图像

如何在DM-script中排除Gatan Digital Micrograph (GMS)中自动保存的某些图像
EN

Stack Overflow用户
提问于 2021-04-01 06:07:09
回答 2查看 60关注 0票数 1

我正在尝试模仿GMS v3中的自动保存功能,以便可以在版本1和版本2中使用。我想首先承认,该脚本的主要部分来自Bernhard Schaffer博士的“如何编写脚本...数字微图脚本手册”。我对它做了一些修改,这样相机记录的任何新图像都可以自动保存到文件中。然而,我遇到了一些问题,因为如果我决定单击实时视图图像并四处移动图像,或者使用live- FFT,实时视图图像或FFT图像也将被保存。我的一个想法是使用标记组信息,例如“Acquisition:Parameters:Parameters Set Name”,因为对于实时视图或实时FFT,这将处于搜索或聚焦模式。另一个想法是使用文档ID,例如iDocID = idoc.ImageDocumentGETID()来定位实时图像的ID。然而,我不知道如何使用这些信息将它们从自动保存中排除。有没有人能告诉我如何使用这个脚本?以下是脚本

代码语言:javascript
复制
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()
EN

回答 2

Stack Overflow用户

发布于 2021-04-01 14:42:17

你的过滤想法很好,但是你的for循环有些奇怪。

在……里面

代码语言:javascript
复制
 nr_idoc = CountImageDocuments()
        For (count = 1; count<nr_idoc; count++)
            {
            idoc = GetImageDocument(count) //imagedocument

遍历所有当前打开的imageDocuments (除了第一个!?)一个接一个地获取它们,但随后在

代码语言:javascript
复制
 If (idoc.ImageDocumentIsDirty())
                {
                idoc = getfrontimagedocument()     

实际上,您每次都会得到最前面(选定)的文档。你为什么要这么做?

为什么不这样做:

代码语言:javascript
复制
number nr_idoc = CountImageDocuments()
for (number count = 0; count<nr_idoc; count++)
{
    imagedocument idoc = GetImageDocument(count)
    If (idoc.ImageDocumentIsDirty())
    {
        // now find out what is a filter condition and skip if it is true
        number skip = 0
        
        TagGroup tg = idoc.ImageDocumentGetImage(0).ImageGetTagGroup()
        skip = tg.TagGroupDoesTagExist("Microscope Info:Formatted Indicated Mag")
        if (skip) continue
        
        // do saving
    }
}
票数 0
EN

Stack Overflow用户

发布于 2021-04-03 07:36:14

非常感谢你的指点!我已经尝试过了,它与我的脚本工作得很好。因为“TagGroupDoesTagExist”只指标签组,所以我进一步修改以包括我想要过滤的标签,例如“搜索”或“焦点”,它似乎工作得很好。我为您现有的脚本修改的脚本如下:

代码语言:javascript
复制
If (idoc.ImageDocumentIsDirty())
                    {
                        
                        //now find out what is a filter condition and skip if it is true
                        skip = 0
                        TagGroup tg = idoc.ImageDocumentGetImage(0).ImageGetTagGroup()
                        tg.TagGroupGetTagAsString("Microscope Info:Formatted Indicated Mag", mag)
                        tg.TagGroupGetTagAsString("Acquisition:Parameters:Parameter Set Name", mode)
                        skip = tg.TagGroupDoesTagExist("Acquisition:Parameters:Parameter Set Name")
                
                        if(skip && (mode == "Search" || mode== "Focus")) continue
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66895943

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档