- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# C:/AngioLocalizeNoAuto/MevisLabNoAutoReg/STUMevisApp/Angiolocalize/Modules/Macros/STURegistration_3D_2D/Registration_3D_2D.py

    00001 """
    00002 * Copyright (c) 2009 Stanford University, School of Medicine All rights reserved.
    00003 *
    00004 * STANFORD ACADEMIC SOFTWARE LICENSE AGREEMENT
    00005 * FOR AngioLocalize SOURCE CODE:
    00006 *
    00007 * 1.  This is a legal agreement between you, RECIPIENT, and STANFORD UNIVERSITY.
    00008 *       By accepting, receiving, and using AngioLocalize.including any accompanying information, materials or
    00009 *       manuals (Program), you are agreeing to be bound by the terms of this Agreement.
    00010 *       If you do not agree to the terms of this Agreement, promptly return the Program to the STANFORD.
    00011
    00012 * 2.  STANFORD grants to RECIPIENT a royalty-free, nonexclusive, and nontransferable license to use the Program
    00013 *       and accompanying source code furnished hereunder, upon the terms and conditions set out below.
    00014 *       documentation and/or other materials provided with the distribution.
    00015 * 3.  RECIPIENT acknowledges that the Program is a research tool still in the development stage and that
    00016 *       it is being supplied as is, without any accompanying services, support or improvements from STANFORD.
    00017 * 4.  RECIPIENT agrees to use the Program solely for internal non-commercial purposes.
    00018 * 5.  RECIPIENT may create derivatives and further transfer the Program under the following terms and conditions:
    00019 *        A) Recipient agrees to not commercially exploit the Program and agrees all uses will be for non-commercial purposes; and,
    00020 *        B) Recipient may not mark any derivatives with the title of Program and may not to use iPad mark for any derivatives; and,
    00021 *        C) Recipient agrees to mark and acknowledge all derivatives as follows: "This is a derivative work based on AngioLocalize:
    00022 *           Frameless AVM localization with 2D Digital Subtraction Angiography (DSA) and 3D Rotational Angiography (DRA) Images developed
    00023 *           by Dimitre Hristov, Lina Liu.
    00024 *        D) Recipient agrees to make all improvements, enhancements and derivatives available under
    00025 *           similar terms and conditions to the research community.
    00026 * 6.   RECIPIENT warrants that RECIPIENT will not remove or export any part of the software or Program from the United
    00027 *       States except in full compliance with all United States and other applicable laws and regulations.
    00028 * 7.  RECIPIENT will use the Program in compliance with all applicable laws, policies and regulations including, but not
    00029 *       limited to, any approvals, informed consent and patient confidentiality principles.
    00030 * 8.   RECIPIENT will indemnify, hold harmless, and defend Stanford against any claim of any kind arising out of or
    00031 *       related to the exercise of any rights granted under this Agreement or the breach of this Agreement by RECIPIENT.
    00032 * 9.  Title and copyright to the Program and any associated documentation shall at all times remain with STANFORD,
    00033 *       and RECIPIENT agrees to preserve same.
    00034 """
    00035 #----------------------------------------------------------------------------------
    00036 #! Macro module Registration_3D_2D
    00037 #/*!
    00038 # \file    Registration_3D_2D.py
    00039 # \author  Dimitre Hristov
    00040 # \date    2009-12-10
    00041 #
    00042 #
    00043 #*/
    00044 #----------------------------------------------------------------------------------
    00045
    00046 from mevis import *
    00047 from PythonQt import *
    00048
    00049 ## Current Frame global variable
    00050 currentFrame=0;
    00051
    00052 ## Picks up image thresholds and ROI from the viewer
    00053 ## and segments the centerline of the 3D DSA vessels
    00054 def segment3DMarkers():
    00055   center=ctx.field("VesselViewer.greyCenter").value;
    00056   width=ctx.field("VesselViewer.greyWidth").value;
    00057   ctx.field("Segment3Dtree.threshMin").value=ctx.field("image3D.input0").minValue()+(ctx.field("image3D.input0").maxValue()-ctx.field("image3D.input0").minValue())*center;
    00058   ctx.field("Segment3Dtree.threshMax").value=ctx.field("image3D.input0").maxValue();
    00059   ctx.field("SelectRoi.apply").touch();
    00060   ctx.field("centerline.clear").touch();
    00061   ctx.field("centerline.update").touch();
    00062   ctx.field("MarkedCenterline.update").touch();
    00063
    00064 ## Shows an MPR view of the 3D image and segmented vessel tree
    00065 ## additional landmarks can be added by placing markers
    00066 def showMPRview():
    00067   ctx.control("Display").selectTabAtIndex(2);
    00068
    00069 ## Displays the projection of the segmented 3D centerline and
    00070 ## lets the user select a frame for the 2D segmentation
    00071 def reviewDSAframes():
    00072   ctx.field("View2DSelection.drawingOn").value = False ;
    00073   ctx.control("Display").selectTabAtIndex(0);
    00074   ctx.disconnectField("SelectFrame.input0");
    00075   ctx.connectField("View2D.inImage","image2D.output0");
    00076   ctx.connectField("WorldVoxelConvert.input0","image2D.output0");
    00077   ctx.field("SoView2DCSOEditor.self").disconnectOutputs();
    00078
    00079 ## select DSA Frame
    00080 def selectDSAframe():
    00081   global currentFrame;
    00082   currentFrame=ctx.field("View2D.startSlice").value;
    00083 #  print currentFrame
    00084
    00085 ## Set up the data flow by setting the single frame the user set up
    00086 ## in select DSA frame
    00087 def setSingleDSAframe():
    00088   ctx.control("Display").selectTabAtIndex(0);
    00089   ctx.field("CSOManager.removeAllCSOsAndGroups").touch();
    00090   ctx.field("View2DSelection.drawingOn").value = True ;
    00091   ctx.field("Mask.input1").connectFrom(ctx.field("CSOConvertToImage.output0"));
    00092   ctx.field("Mask.mode").value = "Original";
    00093   ctx.connectField("SelectFrame.input0","image2D.output0");
    00094   ctx.field("SelectFrame.fullSize").touch();
    00095   global currentFrame;
    00096   ctx.field("SelectFrame.z").value=currentFrame;
    00097   ctx.field("SelectFrame.sz").value=1;
    00098   ctx.field("SelectFrame.apply").touch();
    00099   ctx.connectField("View2D.inImage","SelectFrame.output0");
    00100   ctx.connectField("WorldVoxelConvert.input0","SelectFrame.output0")
    00101
    00102 ## turn on ROI
    00103 def turnROIon():
    00104   ctx.field("SoView2DCSOEditor.self").disconnectOutputs();
    00105   ctx.module("SoGroup").addChild(ctx.module("SoView2DCSOEditor").field("self"));
    00106   ctx.field("View2DItems.i05showItem").value=False ;
    00107   ctx.field("View2DItems.i06showItem").value=True ;
    00108   print "test i5"
    00109   return ;
    00110
    00111 ## turn off ROI
    00112 def turnROIoff():
    00113   ctx.field("SoView2DCSOEditor.self").disconnectOutputs();
    00114   ctx.field("View2DItems.i05showItem").value=True;
    00115   ctx.field("View2DItems.i06showItem").value=False;
    00116   return;
    00117
    00118 ## change the display
    00119 def changeDisplay():
    00120   selection=ctx.field("View2DSelection.lastSelectedId").value;
    00121   if selection == 'DSAframe':
    00122     ctx.connectField("View2D.inImage","SelectFrame.output0");
    00123   elif selection == 'Skeleton':
    00124     if ctx.field("DtfSkeletonization.output0").isValid():
    00125       ctx.field("View2D.inImage").connectFrom(ctx.field("DtfSkeletonization.output0"));
    00126   elif selection == 'Distance':
    00127     if ctx.field("EuclideanDTF.output0").isValid():
    00128       ctx.field("View2D.inImage").connectFrom(ctx.field("MemCache.output0"));
    00129   elif selection == 'Threshold':
    00130     ctx.field("View2D.inImage").connectFrom(ctx.field("IntervalThresh.output0"));
    00131   elif selection == 'ROI_ON':
    00132     print "ROI on selected"
    00133     turnROIon();
    00134   elif selection == 'ROI_OFF':
    00135     print "ROI off selected"
    00136     turnROIoff();
    00137
    00138 ## segment 2D markers
    00139 def segment2DMarkers():
    00140   ctx.field("CSOConvertToImage.apply").touch();
    00141   if ctx.field("CSOConvertToImage.output0").isValid():
    00142     ctx.field("Mask.mode").value = "MaskedOriginal";
    00143   else:
    00144     ctx.field("Mask.mode").value = "Original";
    00145   ctx.field("DtfSkeletonization.clear").touch();
    00146   ctx.field("DtfSkeletonization.update").touch();
    00147   ctx.field("EuclideanDTF.clear").touch();
    00148   ctx.field("EuclideanDTF.update").touch();
    00149   ctx.field("MemCache.clear").touch();
    00150   ctx.field("MemCache.update").touch();
    00151   ctx.field("ChamferMatching.input0").connectFrom(ctx.field("MemCache.output0"));
    00152   print "test";
    00153
    00154 ## automatic registration
    00155 def automaticRegistration():
    00156   ctx.control("Display").selectTabAtIndex(0);
    00157   ctx.field("Mask.input1").disconnect();
    00158   ctx.field("CSOManager.removeAllCSOsAndGroups").touch();
    00159   ctx.field("View2DSelection.drawingOn").value = True ;
    00160   if ctx.field("CSOConvertToImage.input0").isValid():
    00161       ctx.field("CSOConvertToImage.apply").touch();
    00162
    00163 ## start the registration
    00164 def startRegistration():
    00165   if ctx.field("CSOConvertToImage.input0").isValid():
    00166       ctx.field("CSOConvertToImage.apply").touch();
    00167       ctx.field("ChamferMatching.input1").connectFrom(ctx.field("CSOConvertToImage.output0"));
    00168   ctx.field("ChamferMatching.start").touch();
    00169   ctx.field("ChamferMatching.input1").disconnect();
    00170
    00171 ## An interactive registration tab
    00172 def InteractiveRegistration():
    00173 ## We have selected the interactive registration tab
    00174   ctx.field("MatrixArithmetic.matrixA").value=ctx.field("ChamferMatching.matrix1").value;
    00175   ctx.field("AngioTransformEdit.reset").touch();
    00176   ctx.control("Display").selectTabAtIndex(0);
    00177   ctx.field("View2DSelection.drawingOn").value = False ;
    00178   ctx.disconnectField("SelectFrame.input0");
    00179   ctx.connectField("View2D.inImage","image2D.output0");
    00180   ctx.connectField("WorldVoxelConvert.input0","image2D.output0");
    00181   global currentFrame;
    00182   print currentFrame
    00183   ctx.field("View2D.startSlice").value=currentFrame;
    00184   ctx.field("SoView2DCSOEditor.self").disconnectOutputs();
    00185
    00186 ## trigger the parent callback function when "save" button is clicked.
    00187 def saveOnRegManual():
    00188   ctx.field("saveReg").touch();
    00189
    00190 ## trigger the parent callback function when "approve and save" button is clicked
    00191 def approveOnRegManual():
    00192   ctx.field("saveApprove").touch();
    00193
    00194 ## trigger the parent callback function when "cancel" button is clicked
    00195 def cancelonRegManual():
    00196   ctx.field("cancel").touch();
    00197
    00198 ## show help when "help" button is clicked
    00199 def helponRegManual():
    00200   ctx.showHtmlHelp();
    00201
    00202
    00203
    00204
    00205
    00206
    00207 #//# MeVis signature v1
    00208 #//# key: MFowDQYJKoZIhvcNAQEBBQADSQAwRgJBANEfsmYse2e1dRhkQ9AQbreCq9uxwzWLoGom13MNYmyfwoJqQOEXljLFAgw2eEjaT12G4CdqKWhRxh9ANP6n7GMCARE=:VI/mB8bT4u+mRtf/ru8yUQi8BzpaS3UeL2x62YxsUYnVqCWuLrVNLiukIIjnJMKQXlc8ezmgOIcVAV7pgvgKpQ==
    00209 #//# owner: MeVis
    00210 #//# date: 2009-06-10T04:12:25
    00211 #//# hash: vHSfj+Qt8xrIkDVP4W0Rep0YH6a3+MySa0+Cs+AoqEK/IbB+f5szwmyVTENOjzz/JEgm2t31FtHmUUMFcQg5VQ==
    00212 #//# MeVis end
    00213

All Classes Namespaces Files Functions Variables Enumerator Friends