Vaa3D加快調試方法、快速屏蔽對應功能、自動載入圖像和marker等、自動選取文件保存位置、marker點即時更新

Vaa3d調試的主要步驟中一般包括打開圖片、打開marker文件、打開swc文件這三個打開操作,GUI參數的輸入操作,對話框選取文件保存位置的操作等,這幾個步驟都會佔用調試的時間而且當針對同一張圖片時,圖片、marker文件、參數等基本不發生變化,這就給我們節省調試時間帶來了方便。

同時,將程序分塊並加入在if(1)模塊內可以保證當不需要該功能時可以快速屏蔽該功能。
同時,每一個if(1)

快速屏蔽對應功能

通過預處理命令,能夠實現對應的功能的開關。

#define readMarkerFromFile 1


if(readMarkerFromFile)
{
	//readMarkerFromFile
}

自動讀入圖像、marker、swc

    //首先給定圖片文件名、marker文件名、swc文件名
    //在已打開圖片、已存在marker、swc時不執行該代碼,從而使得能夠避免意外
	QString img_name_need_read;
    QString marker_name_need_read;
    QString nt_name_need_read;
    unsigned char threthold;
    switch (2) {
    case 1:
        //fruitfly5_cut.tif
        img_name_need_read="***\\fruitfly5_cut.tif";
        marker_name_need_read="***\\fruitfly5_cut.tif_1.marker";
        nt_name_need_read="***\\fruitfly5_cut.tif_oneBranch_sort.swc";
        threthold=20;
        break;
    case 2:
        //fruitfly1
        img_name_need_read="***\\fruitfly4_cut.tif";
        marker_name_need_read="***\\fruitfly4_cut.tif_1.marker";
        nt_name_need_read="***\\fruitfly4_cut.tif_oneBranch_sort.swc";
        threthold=20;
        break;
        
    default:
        return;
    }
//此處讀取圖片
if(1)
    {
    
        //fetch image
        QFileInfo img_name_info(img_name_need_read);
        if(!img_name_info.exists())
        {
            cout<<"!img_name_info.exists()"<<endl;
            return;
        }
        if(!callback.currentImageWindow())
        {
            cout<<"read image from img_name_need_read"<<endl;
            Image4DSimple * newimg=callback.loadImage(img_name_need_read.toUtf8().data());
            v3dhandle newwin=callback.newImageWindow(img_name_need_read);
//                    Image4DSimple
            callback.setImage(newwin,newimg);
        }
    }
    v3dhandle curwin = callback.currentImageWindow();
    if (!curwin)
    {
        v3d_msg("You don't have any image open in the main window.");
        return;
    }
NeuronTree nt;
if(1)
    {
    //此處nt只用於處理  沒有顯示在圖上   如需顯示可以自行添加代碼
//        cout<<"read SWC from 3d Viewer  "<<endl;
        bool exist_neuronTree=false;
        QList <V3dR_MainWindow *> list_3dviewer = callback.getListAll3DViewers();
        if (list_3dviewer.size() >= 1)
        {
            V3dR_MainWindow *surface_win = list_3dviewer[0];
            if (surface_win)
            {
                QList<NeuronTree> * mTreeList = callback.getHandleNeuronTrees_Any3DViewer(surface_win);
                if(mTreeList->size()>0)
                {
                    nt=mTreeList->at(mTreeList->size()-1);
                    exist_neuronTree=true ;
                }
            }
        }
        if(!exist_neuronTree)
        {  
            cout<<"read neuronTree from nt_name_need_read"<<endl;
            QFileInfo nt_name_info(nt_name_need_read);
            if(!nt_name_info.exists())
            {
                cout<<"!nt_name_info.exists()"<<endl;
                return;
            }
            nt=readSWC_file(nt_name_need_read);
            if(nt.listNeuron.isEmpty())
            {
                cout<<"nt.listNeuron.isEmpty()"<<endl;
                return;
            }
        }
        cout<<"read SWC from 3d Viewer over  "<<endl;   
    }
    if(1)
    {
    //fetch marker
        QFileInfo marker_name_info(marker_name_need_read);
        if(!marker_name_info.exists())
        {
            cout<<"!marker_name_info.exists()"<<endl;
            return;
        }
        if(callback.getLandmark(curwin).isEmpty())
        {
        //避免已經輸出marker而覆蓋
            cout<<"read marker from marker_name_need_read"<<endl;
            LandmarkList s=ReadLandmarkList(marker_name_need_read);
            if(s.isEmpty())
            {cout<<"s.isEmpty()"<<endl;return;}
            callback.setLandmark(curwin,s);
            callback.open3DWindow(curwin);
            callback.pushObjectIn3DWindow(curwin);
        }
    }

選取文件保存位置。

if(1)
    {
        QString swcfile="D:\\111\\";
        QFileInfo fileinfo(QString(p4DImage->getFileName()));
        swcfile.append(fileinfo.baseName());
        swcfile.append(QString::number(rand()%200+100));
        //加100保證隨機數都是三位數
        swcfile.append("_tracing.swc");
        writeSWC_file(swcfile,outTree);
        cout<<"over\n\n"<<endl;
        
    }

marker點在程序運行完成以後即時更新

if(1)
    {
    	//這樣可以避免在3D界面上按下“Sync Tri-view Objs”marker點才更新顯示的問題
		//從而加快調試進度
    	callback.open3DWindow(curwin);
        callback.setLandmark(curwin,needtoshow);
        callback.pushObjectIn3DWindow(curwin);
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章