- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# C:/AngioLocalizeNoAuto/MevisLabNoAutoReg/STUMevisApp/Angiolocalize/Modules/Macros/STULocalizationWrapper/LocalizationWrapper.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 LocalizationWrapper
    00037 #/*!
    00038 # \file    LocalizationWrapper.py
    00039 # \author  Lina Liu and Dimitre Hristov
    00040 # \date    2009-12-10
    00041 #
    00042 #
    00043 #*/
    00044 #----------------------------------------------------------------------------------
    00045
    00046 from mevis import *
    00047 import os;
    00048
    00049 ## Global varibles
    00050 src3D = ""
    00051 target3D = ""
    00052 Img2D1 = ""
    00053 Img2D2 = ""
    00054 winHandle = None
    00055 win3D = None
    00056
    00057 ## initialize some varibles when window pops up
    00058 def initWindow():
    00059   ctx.field("PatientID").setValue(ctx.parent().field("PatientID").value);
    00060   ctx.field("PatientsName").setValue(ctx.parent().field("PatientsName").value);
    00061   ctx.field("PatientsBirthDate").setValue(ctx.parent().field("PatientsBirthDate").value);
    00062   ctx.field("PatientsSex").setValue(ctx.parent().field("PatientsSex").value);
    00063   ctx.field("ImgLoad2D1.autoLoad").touch();
    00064   ctx.field("ImgLoad2D2.autoLoad").touch();
    00065   ctx.field("ImgLoad3DTarget.autoLoad").touch();
    00066   ctx.field("ImgLoad3DSource.autoLoad").touch();
    00067   ctx.field("Localization.View2DImage1.ext.annotation.annotationMode").setValue("ANNO_MODE_USER");
    00068   ctx.field("Localization.View2DImage1.ext.annotation.annotationUserBottomLeft").setValue("Timepoint: $(slice) \n$(sizex),$(sizey),$(sizec) \n$(voxelx),$(voxely) \n$(SeriesDescription)");
    00069   ctx.field("Localization.View2DImage1.ext.annotation.showOrientation").setValue("ANNO_ORIENTATION_OFF");
    00070   ctx.field("Localization.View2DImage2.ext.annotation.annotationMode").setValue("ANNO_MODE_USER");
    00071   ctx.field("Localization.View2DImage2.ext.annotation.annotationUserBottomLeft").setValue("Timepoint: $(slice) \n$(sizex),$(sizey),$(sizec) \n$(voxelx),$(voxely) \n$(SeriesDescription)");
    00072   ctx.field("Localization.View2DImage2.ext.annotation.showOrientation").setValue("ANNO_ORIENTATION_OFF");
    00073   patientID = getPatientRecordID();
    00074   if (patientID != "0"):
    00075     loadGUILists(patientID);
    00076
    00077 ## clean Up the module. Disconnect all the image inputs and other connections that may cause performance slow down
    00078 def cleanUp():
    00079   disconnectFields();
    00080   ctx.field("ImgLoad2D1.close").touch();
    00081   ctx.field("ImgLoad2D2.close").touch();
    00082   ctx.field("ImgLoad3DSource.close").touch();
    00083   ctx.field("ImgLoad3DTarget.close").touch();
    00084
    00085 ## reset and disconnect fields
    00086 def disconnectFields():
    00087   ctx.disconnectField("Localization.image3Dtarget");
    00088   ctx.disconnectField("Localization.image3Dsource");
    00089   ctx.disconnectField("Localization.image2D1");
    00090   ctx.disconnectField("Localization.Image2D2");
    00091   ctx.disconnectField("Localization.TargetView3D.inInvPreLUT");
    00092   ctx.disconnectField("Localization.CSOPerspectiveTransformation1.apply");
    00093   ctx.disconnectField("Localization.CSOPerspectiveTransformation2.apply");
    00094
    00095 ## pop up the 3D selection context menu
    00096 def selectChanged3D():
    00097   ctx.control("popup3D").popup();
    00098
    00099 ## pop up the 2D select context menu
    00100 def selectChanged2D():
    00101   ctx.control("popup2D").popup();
    00102
    00103 ## send a query to the Database and return the result set
    00104 def sendQuery(query):
    00105   ctx.field("DBConn.Statement").setValue(query);
    00106   dbModule = ctx.module("DBConn");
    00107   result = dbModule.call("sendQuery");
    00108   if (result == -1):
    00109     MLAB.log("The following query to database failed: \n" + query + "\n.");
    00110   dbModule.call("close");
    00111   return result;
    00112
    00113 ## get the Image File Name
    00114 def getImageFileName(imgID):
    00115   queryString = "select imageName, imageDir from images where imageID = " + str(imgID);
    00116   result = sendQuery(queryString);
    00117   imgName = None;
    00118   for item in result:
    00119     imgName = item["imagename"];
    00120   return imgName;
    00121
    00122 ## The function specifies actions taken when user selects 3D image as a source
    00123 def select3DAsSource():
    00124   global src3D;
    00125   list3D = ctx.control("list3D");
    00126   srcItem = list3D.selectedItem();
    00127   src3D = srcItem.text(0);
    00128   loadImage(src3D,1);
    00129
    00130 ## load image given a fileName and src or Target type
    00131 def loadImage(imageID, srcOrTgt):
    00132   srcF = getImageFileName(imageID);
    00133   src = os.path.normpath(srcF + ".dcm");
    00134   fileName = os.path.normpath(src);
    00135   if (srcOrTgt == 1):
    00136     if fileName!= None:
    00137       ctx.field("ImgLoad3DSource.filename").setValue(fileName);
    00138     ctx.control("src1Label").setTitle("3D Source Image file:" + fileName);
    00139     ctx.field("ImgLoad3DSource.load").touch();
    00140     MLAB.log("source selected:" + fileName);
    00141   else:
    00142     if fileName!= None:
    00143       ctx.field("ImgLoad3DTarget.filename").setValue(fileName);
    00144       ctx.field("TargetImgID").setValue(imageID);
    00145     ctx.control("target1Label").setTitle("3D Target Image file:" + fileName);
    00146     ctx.field("ImgLoad3DTarget.load").touch();
    00147     MLAB.log("target selected:" + fileName);
    00148
    00149 ## The function specifies actions taken when user selects 3D image as a target
    00150 def select3DAsTarget():
    00151   global target3D;
    00152   list3D = ctx.control("list3D");
    00153   targetItem = list3D.selectedItem();
    00154   target3D = targetItem.text(0);
    00155   loadImage(target3D,2);
    00156
    00157 ## The function specifies the actions taken when the user selects approve and finish registration
    00158 def regExistAndApproved(target, src):
    00159   queryString = "SELECT matrixID as Num FROM REGMATRICES WHERE srcImage = " + str(src) + " AND targetImage = " + str(target) + ";";
    00160   result = sendQuery(queryString);
    00161   number = 0;
    00162   if (str(result) == "()"):
    00163     return number;
    00164
    00165   number = result[0]["num"];
    00166   approvalID = 0;
    00167   if (number != 0):
    00168      queryString = "select userID from approvals where approvalStatus = 1 and objType = 0 and objID = " + str(number);
    00169      result = sendQuery(queryString);
    00170      if (str(result) == "()"):
    00171        return 0;
    00172      approvalID = result[0]["userid"];
    00173   if (approvalID == 0):
    00174     return 0;
    00175   else:
    00176     return number;
    00177
    00178 ## The function  is called when user selects cancel button
    00179 def cancel():
    00180   global src3D;
    00181   global target3D;
    00182   global Img2D1;
    00183   global Img2D2;
    00184   src3D = ""
    00185   target3D = ""
    00186   Img2D1 = ""
    00187   Img2D2 = ""
    00188   ctx.controlDebug("target1Label").setTitle("3D Target Image:");
    00189   ctx.controlDebug("src1Label").setTitle("3D Source Image:" );
    00190   ctx.controlDebug("src2Label").setTitle("2D Image 1:");
    00191   ctx.controlDebug("target2Label").setTitle("2D Image 2:");
    00192   cleanUp();
    00193
    00194 ## It specifies the actions that were taken when user clicks go button
    00195 def go():
    00196   global winHandle;
    00197   global win3D;
    00198   global src3D;
    00199   global target3D;
    00200   global Img2D1;
    00201   global Img2D2;
    00202   disconnectFields();
    00203   winHandle = ctx.window();
    00204   title = "Patient: " + ctx.field("PatientsName").value + "   with MRO: " + ctx.field("PatientID").value + " DOB: " + ctx.field("PatientsBirthDate").value + " " + ctx.field("PatientsSex").value;
    00205   if (src3D == "" and target3D != "" and Img2D1 == "" and Img2D2 == ""):
    00206     ctx.connectField("Localization.image3Dtarget", "ImgLoad3DTarget.output0");
    00207     manager = ctx.module("Localization");
    00208     setWindows(False, True, False, False, False);
    00209     win3D = manager.showWindow("Two2DTwo3D");
    00210     win3D.setTitle(title);
    00211     win3D.showMaximized();
    00212     reloadCSO(target3D);
    00213   elif (target3D != "" and Img2D1 != "" and src3D == "" and Img2D2 ==""):
    00214     if (regExistAndApproved(target3D, Img2D1) == 0):
    00215       info = "The image " + str(target3D) + " and " + str(Img2D1) +" is not registered. You have to register them first.";
    00216       MLAB.showInformation(info);
    00217       return;
    00218     ctx.connectField("Localization.image3Dtarget", "ImgLoad3DTarget.output0");
    00219     ctx.connectField("Localization.image2D1", "ImgLoad2D1.output0");
    00220     manager = ctx.module("Localization");
    00221     fillInMatrices(target3D, Img2D1, 0);
    00222     ctx.field("Localization.StructureManager.useRepaintNotification").setValue(True);
    00223     ctx.connectField("Localization.CSOPerspectiveTransformation1.apply", "Localization.StructureManager.notifyOnRepaint");
    00224     setWindows(False, True, True, False, False);
    00225     win3D = manager.showWindow("Two2DTwo3D");
    00226     win3D.setTitle(title);
    00227     win3D.showMaximized();
    00228     reloadCSO(target3D);
    00229   elif (target3D != "" and Img2D1 != "" and Img2D2 !=""):
    00230     if (regExistAndApproved(target3D, Img2D1) == 0):
    00231       info = "The image " + str(target3D) + " and " + str(Img2D1) +" is not registered. You have to register them first.";
    00232       MLAB.showInformation(info);
    00233       return;
    00234     if (regExistAndApproved(target3D, Img2D2) == 0):
    00235       info = "The image " + str(target3D) + " and " + str(Img2D2) +" is not registered. You have to register them first.";
    00236       MLAB.showInformation(info);
    00237       return;
    00238     ctx.connectField("Localization.image3Dtarget", "ImgLoad3DTarget.output0");
    00239     ctx.connectField("Localization.image2D1", "ImgLoad2D1.output0");
    00240     ctx.connectField("Localization.Image2D2", "ImgLoad2D2.output0");
    00241     fillInMatrices(target3D, Img2D1, 0);
    00242     fillInMatrices(target3D, Img2D2, 1);
    00243     manager = ctx.module("Localization");
    00244     reloadCSO(target3D);
    00245     ctx.field("Localization.StructureManager.useRepaintNotification").setValue(True);
    00246     ctx.connectField("Localization.CSOPerspectiveTransformation1.apply", "Localization.StructureManager.notifyOnRepaint");
    00247     ctx.connectField("Localization.CSOPerspectiveTransformation2.apply", "Localization.StructureManager.notifyOnRepaint");
    00248     if (src3D == ""):
    00249       setWindows(False, True, True, True, False);
    00250       win3D = manager.showWindow("Two2DTwo3D");
    00251       win3D.setTitle(title);
    00252       win3D.showMaximized();
    00253     else:
    00254       if (regExistAndApproved(target3D, src3D) == 0):
    00255         info = "The image " + str(target3D) + " and " + str(src3D) +" is not registered. You have to register them first.";
    00256         MLAB.showInformation(info);
    00257         return;
    00258       ctx.connectField("Localization.image3Dsource", "ImgLoad3DSource.output0");
    00259       ctx.field("Localization.SourceView3D.worldPosition").connectFrom(ctx.field("Localization.TargetView3D.worldPosition"));
    00260       ctx.field("Localization.TargetView3D.worldPosition").connectFrom(ctx.field("Localization.SourceView3D.worldPosition"));
    00261       fillInAffineMatrix(src3D, target3D);
    00262       setWindows(True, True, True, True, True);
    00263       win3D = manager.showWindow("Two2DTwo3D");
    00264       win3D.setTitle(title);
    00265       win3D.showMaximized();
    00266   else:
    00267     MLAB.showInformation("Please choose one of the following combinations: \n1) one 3D source, one 3D target and two 2D images \n2) one 3D target \n3) one 3D target and two 2D images \n4)one 3D target and one 2D image as Image1.");
    00268 ## get the AffineMatrix for 3D src and 3D target and fill In the Localization panel
    00269 def fillInAffineMatrix(src3D, target3D):
    00270   queryString = "select affineM from regmatrices where type = 0 and srcImage = " + str(src3D) + " and targetImage = " + str(target3D) + ";";
    00271   result = sendQuery(queryString);
    00272   if (str(result) == "()"):
    00273       return;
    00274   affineM = None;
    00275   for item in result:
    00276     affineM = item["affinem"];
    00277   ctx.field("Localization.set3DRegistration.matrix").setStringValue(affineM);
    00278
    00279 ## fill In the projection matrixes fields
    00280 def fillInMatrices(target3D, Img2D1, pairNumber):
    00281   ##pairNumber: 0 is the first set of 2D img, 1 is the second set of 2D img
    00282   queryString = "select b.affineM as affineM, b.perspectM as perspectM, b.postAffineM as postAffineM from images a, regmatrices b, images c, approvals d where b.srcImage = " + str(Img2D1) + " and a.ImageID = " + str(Img2D1) + " and d.objID = b.matrixID and d.approvalStatus = 1 and b.targetImage = " + str(target3D) + " and c.ImageID = " + str(target3D) + " and a.patientID = " + getPatientRecordID() + " and c.patientID = " + getPatientRecordID() + ";";
    00283   result = sendQuery(queryString);
    00284   if (str(result) == "()"):
    00285       return;
    00286   for item in result:
    00287     postAffineM = item["postaffinem"];
    00288     perspectM = item["perspectm"];
    00289     affineM = item["affinem"];
    00290     if (pairNumber == 0):
    00291       ctx.field("Localization.AffinePostProjMatrix1").setStringValue(postAffineM);
    00292       ctx.field("Localization.AffinePostProjMatrix1").touch();
    00293       ctx.field("MatrixArithmetic.matrixA").setStringValue(perspectM);
    00294       ctx.field("MatrixArithmetic.matrixB").setStringValue(affineM);
    00295       ctx.field("MatrixArithmetic.operation").setStringValue("Multiply");
    00296       MLAB.log("projectiong matrix1:" + ctx.field("MatrixArithmetic.outputMatrixC").stringValue());
    00297       MLAB.log("postAffine Matrix1:" + ctx.field("Localization.AffinePostProjMatrix1").stringValue());
    00298       ctx.field("Localization.projectionMatrix1").setStringValue(ctx.field("MatrixArithmetic.outputMatrixC").stringValue());
    00299       ctx.field("Localization.projectionMatrix1").touch();
    00300       ctx.field("Localization.CSOPerspectiveTransformation1.apply").touch();
    00301     else:
    00302       ctx.field("Localization.AffinePostProjMatrix2").setStringValue(postAffineM);
    00303       ctx.field("Localization.AffinePostProjMatrix2").touch();
    00304       ctx.field("MatrixArithmetic.matrixA").setStringValue(perspectM);
    00305       ctx.field("MatrixArithmetic.matrixB").setStringValue(affineM);
    00306       ctx.field("MatrixArithmetic.operation").setStringValue("Multiply");
    00307       MLAB.log("projectiong matrix2:" + ctx.field("MatrixArithmetic.outputMatrixC").stringValue());
    00308       MLAB.log("postAffine Matrix2:" + ctx.field("Localization.AffinePostProjMatrix2").stringValue());
    00309       ctx.field("Localization.projectionMatrix2").setStringValue(ctx.field("MatrixArithmetic.outputMatrixC").stringValue());
    00310       ctx.field("Localization.projectionMatrix2").touch();
    00311       ctx.field("Localization.CSOPerspectiveTransformation2.apply").touch();
    00312
    00313 ## when the user select "selection", the background Image and registration list will be popped up in the front
    00314 def raiseW():
    00315   global winHandle;
    00316   if (winHandle != None):
    00317     winHandle.raiseWindow();
    00318
    00319 ## reload the CSO for Image with ID "targetID"
    00320 def reloadCSO(targetID):
    00321   ctx.field("Localization.StructureManager.removeAllCSOsAndGroups").touch();
    00322   query = "select filename from CSOList where srcImage = " + str(targetID);
    00323   result = sendQuery(query);
    00324   if (str(result) == "()"):
    00325       return;
    00326   CSOFileName = "";
    00327   for item in result:
    00328     CSOFileName = item["filename"];
    00329   if (CSOFileName != ""):
    00330     ctx.field("Localization.StructureLoad.fileName").setValue(os.path.normpath(CSOFileName));
    00331     ctx.field("Localization.StructureLoad.apply").touch();
    00332     ctx.connectField("Localization.StructureManager.inCSOList", "Localization.StructureLoad.outCSOList");
    00333
    00334 ## update CSOList in the list panel
    00335 def updateCSOList():
    00336    loadCSOList();
    00337
    00338 ## The function specifies the action when user selects Image2D1
    00339 def Image2D1():
    00340   load2DImage(1);
    00341
    00342 ## The function specifies the action when user selects Image2D2
    00343 def Image2D2():
    00344   load2DImage(2);
    00345
    00346 ## load 2D image data from file
    00347 def load2DImage(num):
    00348   list2D = ctx.control("list2D");
    00349   Item = list2D.selectedItem();
    00350   image2D1F = getImageFileName(Item.text(0));
    00351   file2D = os.path.normpath(image2D1F + ".dcm");
    00352   image2D = os.path.normpath(file2D);
    00353   if (num == 1):
    00354     global Img2D1;
    00355     Img2D1 = Item.text(0);
    00356     if Img2D1!= None:
    00357       ctx.field("ImgLoad2D1.filename").setValue(image2D);
    00358     ctx.field("ImgLoad2D1.load").touch();
    00359     ctx.control("src2Label").setTitle("2D image 1:" + image2D);
    00360     MLAB.log("2D image 1:" + image2D);
    00361   else:
    00362     global Img2D2;
    00363     Img2D2 = Item.text(0);
    00364     if Img2D2!= None:
    00365       ctx.field("ImgLoad2D2.filename").setValue(image2D);
    00366     ctx.field("ImgLoad2D2.load").touch();
    00367     ctx.control("target2Label").setTitle("2D image 2:" + image2D);
    00368     MLAB.log("2D image 2:" + image2D);
    00369
    00370 ## get the patient record ID
    00371 def getPatientRecordID():
    00372   patientID = 0;
    00373   if (ctx.field("PatientID").value == ""):
    00374     return str(patientID);
    00375   queryString = "SELECT PatientID FROM Patients WHERE MRO = " + "'" + ctx.field("PatientID").value + "'";
    00376   result = sendQuery(queryString);
    00377
    00378   for item in result:
    00379     patientID = item["patientid"];
    00380   return str(patientID);
    00381
    00382 ## init DB and load the 2D images, 3D images and registrations existed in DB
    00383 def loadGUILists(patientID):
    00384     load3DImageList(patientID);
    00385     load2DImageList(patientID);
    00386     loadRegItem();
    00387     loadCSOList();
    00388     MLAB.log("Query has been made in reg tab.");
    00389
    00390 ## load the CSOList existed in DB
    00391 def loadCSOList():
    00392     CSOList = ctx.controlDebug("CSOList");
    00393     CSOList.clearItems();
    00394     patientID = getPatientRecordID();
    00395     if (patientID == "0"):
    00396       return;
    00397     queryString = "SELECT CSOId, srcImage, approvalStatus from CSOList, approvals where CSOList.patientID = " + patientID + " and approvals.objType = 1 and approvals.objID = csoList.CSOId;";
    00398     result = sendQuery(queryString);
    00399     if (str(result) == "()"):
    00400       return;
    00401     for item in result:
    00402       csoID = item["csoid"];
    00403       srcImage = item["srcimage"];
    00404       status = item["approvalstatus"];
    00405       approvalS = "false";
    00406       if (status == 1):
    00407         approvalS = "true";
    00408       CSOList.insertItem([str(csoID), srcImage, approvalS]);
    00409
    00410
    00411 ## load the 3D image List
    00412 def load3DImageList(patientID):
    00413     imgList = ctx.controlDebug("list3D");
    00414     imgList.clearItems();
    00415     #init DB
    00416     queryString = "select imageID, modality, seriesDescr from images where imagetype = 2 and patientID = " + patientID + ";";
    00417     result = sendQuery(queryString);
    00418     if (str(result) == "()"):
    00419       return;
    00420     for item in result:
    00421       imgName = item["imageid"];
    00422       imgM = item["modality"];
    00423       series = item["seriesdescr"];
    00424       imgList.insertItem([str(imgName), imgM, series]);
    00425
    00426 ## close the Window
    00427 def closePWin():
    00428   global win3D;
    00429   if (win3D != None):
    00430     win3D.close();
    00431
    00432 ## loaded 2D image list
    00433 def load2DImageList(patientID):
    00434     imgList = ctx.controlDebug("list2D");
    00435     imgList.clearItems();
    00436     #init DB
    00437     queryString = "select imageID, modality, seriesDescr from images where imagetype = 1 and patientID = " + patientID + ";";
    00438     result = sendQuery(queryString);
    00439     if (str(result) == "()"):
    00440       return;
    00441     for item in result:
    00442       imgName = item["imageid"];
    00443       imgM = item["modality"];
    00444       series = item["seriesdescr"];
    00445       imgList.insertItem([str(imgName), imgM, series]);
    00446
    00447
    00448 ## load the registrations existed in DB
    00449 def loadRegItem():
    00450     regImage = ctx.controlDebug("registeredImg");
    00451     regImage.clearItems();
    00452     patientID = getPatientRecordID();
    00453     if (patientID == "0"):
    00454       return;
    00455     queryString = "select b.affineM as matrixA, b.perspectM as matrixB, b.postAffineM as matrixC, b.srcImage as src, a.modality as srcM, a.seriesDescr as srcDesc, c.modality as trgM, c.seriesDescr as tgtDesc, b.targetImage as target , d.approvalStatus as status, to_char(d.approvaldate,'YYYY-MM-DD HH12:MI:SS') as savedTime, b.status as genre from images a, regmatrices b, images c, approvals d where b.srcImage = a.imageID and b.targetImage = c.imageID and d.approvalStatus =1 and d.objType = 0 and d.objID = b.matrixID and a.patientID = " + patientID + ";"
    00456     result = sendQuery(queryString);
    00457     if (str(result) == "()"):
    00458       return;
    00459     for item in result:
    00460       matrixReg = item["matrixa"];
    00461       perspectiveM = item["matrixb"];
    00462       postAffineM = item["matrixc"];
    00463       srcImg = item["src"];
    00464       tgtImg = item["target"];
    00465       srcMod = item["srcm"];
    00466       srcDesc = item["srcdesc"];
    00467       targetMod = item["trgm"];
    00468       targetDesc = item["tgtdesc"];
    00469       statusNum = item["status"];
    00470       approvalDate = item["savedtime"];
    00471       genreNum = item["genre"];
    00472       status = None;
    00473       genre = None;
    00474       if (statusNum == 0):
    00475         status = "false";
    00476       else:
    00477         status = "true";
    00478       if (genreNum == 0):
    00479         genre = "direct";
    00480       else:
    00481         genre = "inferred";
    00482       regImage.insertItem([str(srcImg), srcMod, srcDesc, str(tgtImg), targetMod, targetDesc, status, genre, approvalDate, matrixReg, perspectiveM, postAffineM]);
    00483
    00484 ## update changes from CSO manager
    00485 def CSOManagerUpdate():
    00486   ctx.field("Localization.CSOPerspectiveTransformation1.apply").touch();
    00487   ctx.field("Localization.CSOPerspectiveTransformation2.apply").touch();
    00488
    00489 ## set up whether source, target 2D image viewers will be shown
    00490 def setWindows(sourceV, targetV, image1V, image2V, two2Dtwo3D):
    00491   ctx.field("Localization.showSource").setBoolValue(sourceV);
    00492   ctx.field("Localization.showTarget").setBoolValue(targetV);
    00493   ctx.field("Localization.showImage1").setBoolValue(image1V);
    00494   ctx.field("Localization.showImage2").setBoolValue(image2V);
    00495   ctx.field("Localization.two2Dtwo3D").setBoolValue(two2Dtwo3D);
    00496
    00497 ## help function
    00498 def help():
    00499    ctx.showHtmlHelp();
    00500 #//# MeVis signature v1
    00501 #//# key: MFowDQYJKoZIhvcNAQEBBQADSQAwRgJBANEfsmYse2e1dRhkQ9AQbreCq9uxwzWLoGom13MNYmyfwoJqQOEXljLFAgw2eEjaT12G4CdqKWhRxh9ANP6n7GMCARE=:VI/mB8bT4u+mRtf/ru8yUQi8BzpaS3UeL2x62YxsUYnVqCWuLrVNLiukIIjnJMKQXlc8ezmgOIcVAV7pgvgKpQ==
    00502 #//# owner: MeVis
    00503 #//# date: 2009-06-10T04:12:25
    00504 #//# hash: vHSfj+Qt8xrIkDVP4W0Rep0YH6a3+MySa0+Cs+AoqEK/IbB+f5szwmyVTENOjzz/JEgm2t31FtHmUUMFcQg5VQ==
    00505 #//# MeVis end
    00506

All Classes Namespaces Files Functions Variables Enumerator Friends