- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# C:/AngioLocalizeNoAuto/MevisLabNoAutoReg/STUMevisApp/Angiolocalize/Modules/Macros/STUAngioExport/AngioExport.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 AngioExport
    00037 #/*!
    00038 # \file    AngioExport.py
    00039 # \author  LinaLiu
    00040 # \date    2009-12-10
    00041 #
    00042 # This is the module that exports CSO
    00043 #*/
    00044 #----------------------------------------------------------------------------------
    00045
    00046 from mevis import *
    00047 import os;
    00048
    00049 ##Global variables
    00050 wind = None
    00051
    00052 ## init export window
    00053 def initWindow():
    00054   ctx.field("PatientID").setValue(ctx.parent().field("PatientID").value);
    00055   ctx.field("PatientsName").setValue(ctx.parent().field("PatientsName").value);
    00056   ctx.field("PatientsBirthDate").setValue(ctx.parent().field("PatientsBirthDate").value);
    00057   ctx.field("PatientsSex").setValue(ctx.parent().field("PatientsSex").value);
    00058   ctx.field("CSOConvertToImage.copyInputImage").setBoolValue(True);
    00059   patientID = getPatientRecordID();
    00060   if (patientID != "0"):
    00061     loadCSOList(patientID);
    00062
    00063 ## load CSO list in GUI
    00064 def loadCSOList(patientID):
    00065   CSOlist = ctx.controlDebug("list");
    00066   CSOlist.clearItems();
    00067   queryString = "select CSOId,  srcImage, filename from csolist, approvals where CSOId = objID AND objType = 1 and approvalStatus = 1 and approvals.patientID = csolist.patientID and csolist.patientID =  " + getPatientRecordID() + ";"
    00068   result = sendQuery(queryString);
    00069   if (str(result) != "()"):
    00070     for item in result:
    00071       CSOId = item["csoid"];
    00072       srcImg = item["srcimage"];
    00073       fileName = item["filename"];
    00074       CSOlist.insertItem([str(CSOId), srcImg, fileName, "true"]);
    00075
    00076 ## get the DB record ID for a patient given MRO number
    00077 def getPatientRecordID():
    00078   patientID = 0;
    00079   if (ctx.field("PatientID").value == ""):
    00080     return str(patientID);
    00081
    00082   queryString = "SELECT PatientID FROM Patients WHERE MRO = " + "'" + ctx.field("PatientID").value + "'";
    00083   result = sendQuery(queryString);
    00084
    00085   if (str(result) != "()"):
    00086     for item in result:
    00087       patientID = item["patientid"];
    00088   return str(patientID);
    00089
    00090 ## send a query to the Database and return the result set
    00091 def sendQuery(query):
    00092   ctx.field("DBConn.Statement").setValue(query);
    00093   dbModule = ctx.module("DBConn");
    00094   result = dbModule.call("sendQuery");
    00095   if (result == -1):
    00096     MLAB.logError("The following query to database failed. \n" + query + "\n.");
    00097   dbModule.call("close");
    00098   return result;
    00099
    00100 ## export selected CSO
    00101 def export():
    00102   global wind;
    00103   list = ctx.control("list");
    00104   selectedItem = list.selectedItem();
    00105   queryString = "Select imageName from images where ImageID = " + selectedItem.text(1);
    00106   result = sendQuery(queryString);
    00107   if(str(result) != "()"):
    00108     for item in result:
    00109       imageName = item["imagename"];
    00110       imageLegalName = os.path.normpath(imageName + ".dcm");
    00111       ctx.field("LoadApprovedReferenceImage.filename").setValue(imageLegalName);
    00112       ctx.field("LoadApprovedReferenceImage.load").touch();
    00113   fullName = os.path.normpath(selectedItem.text(2));
    00114   ctx.field("LoadApprovedStructure.fileName").setValue(fullName);
    00115   ctx.field("LoadApprovedStructure.apply").touch();
    00116   ctx.field("CSOConvertToImage.apply").touch();
    00117   wind = ctx.showWindow("orthoView2DW");
    00118   title = "Patient: " + ctx.field("PatientsName").value + "   with MRO: " + ctx.field("PatientID").value + " DOB: " + ctx.field("PatientsBirthDate").value + " " + ctx.field("PatientsSex").value;
    00119   wind.setTitle(title);
    00120   wind.showMaximized();
    00121
    00122 ## cancel the OrthView2D window
    00123 def closeWin():
    00124   global wind;
    00125   if (wind != None):
    00126     wind.close();
    00127     wind = None;
    00128
    00129 ## If user would like to save selected CSO, the DicomSave panel will be pop up
    00130 def save():
    00131   closeWin();
    00132   #ctx.module("DicomTool").showWindow();
    00133   ctx.module("RTStructExportTool").showWindow();
    00134
    00135 ## provides help for the user
    00136 def help():
    00137   ctx.showHtmlHelp();
    00138
    00139 ## cleanUp
    00140 def cleanUp():
    00141   ctx.field("LoadApprovedReferenceImage.close").touch();
    00142   ctx.field("LoadApprovedStructure.fileName").setValue("");
    00143   ctx.field("LoadApprovedStructure.fileName").touch();
    00144
    00145 ## export To RT Structure
    00146 def exportRTStruct():
    00147   global wind;
    00148   list = ctx.control("list");
    00149   selectedItem = list.selectedItem();
    00150   queryString = "Select imageName from images where ImageID = " + selectedItem.text(1);
    00151   result = sendQuery(queryString);
    00152   if(str(result) != "()"):
    00153     for item in result:
    00154       imageName = item["imagename"];
    00155       imageLegalName = os.path.normpath(imageName + ".dcm");
    00156       ctx.field("LoadApprovedReferenceImage.filename").setValue(imageLegalName);
    00157       ctx.field("LoadApprovedReferenceImage.load").touch();
    00158   fullName = os.path.normpath(selectedItem.text(2));
    00159   ctx.field("LoadApprovedStructure.fileName").setValue(fullName);
    00160   ctx.field("LoadApprovedStructure.apply").touch();
    00161   ctx.field("CSOToRTStructure.rtStructFile").setValue(ctx.field("rtStructFile").value);
    00162   ctx.field("CSOToRTStructure.apply").touch();

All Classes Namespaces Files Functions Variables Enumerator Friends