- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# C:/AngioLocalizeNoAuto/MevisLabNoAutoReg/STUMevisApp/Angiolocalize/Modules/Macros/STUImgRegManual/ImgRegManual.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 ImgRegManual
    00037 #/*!
    00038 # \file    ImgRegManual.py
    00039 # \author  Lina Liu and Dimitre Hristov
    00040 # \date    2009-01-23
    00041 #
    00042 #
    00043 #*/
    00044 #----------------------------------------------------------------------------------
    00045
    00046 from mevis import *
    00047 ## Global Variable
    00048 transWin = None;
    00049
    00050 ## initialize the module
    00051 def init():
    00052   ctx.field("reformat.resetMatrix").touch();
    00053 #  ctx.field("reformat.translation").connectFrom(ctx.field("AngioTransformEdit.translation"));
    00054 #  ctx.field("AngioTransformEdit.translation").connectFrom(ctx.field("reformat.translation"));
    00055 #  ctx.field("reformat.rotationAngles").connectFrom(ctx.field("AngioTransformEdit.rotation"));
    00056 #  ctx.field("AngioTransformEdit.rotation").connectFrom(ctx.field("reformat.rotationAngles"));
    00057 #  ctx.addModule("AutoRegistration");
    00058 #  ctx.field("AutoRegistration.input0").connectFrom(ctx.field("ROISelectSource.outImage"));
    00059 #  ctx.field("AutoRegistration.input1").connectFrom(ctx.field("ROISelectTarget.outImage"));
    00060
    00061 ## get the Final Matrix which will be saved to database
    00062 def getFinalMatrix():
    00063   MLAB.log("InitialAlignMent:" + ctx.field("InitialAlignment.matrix").stringValue());
    00064   ctx.field("MatrixArithmetic.matrixA").setStringValue(ctx.field("InitialAlignment.matrix").stringValue());
    00065   ctx.field("MatrixArithmetic.matrixB").setStringValue(ctx.field("reformat.matrix").stringValue());
    00066   ctx.field("MatrixArithmetic.operation").setStringValue("Multiply");
    00067   return ctx.field("MatrixArithmetic.outputMatrixC").stringValue();
    00068
    00069 ## show/close AngioTransformEdit module window
    00070 def showAngioTranformEdit():
    00071   global transWin;
    00072   if (ctx.field("interactive").boolValue() == True):
    00073 #    transWin = ctx.module("AngioTransformEdit").showWindow();
    00074     ctx.field("reformat.resetMatrix").touch();
    00075   #else:
    00076   #  if (transWin != None):
    00077   #   transWin.close();
    00078   #   transWin = None;
    00079 ## shows a panel for selection of ROIs for the automatic registration
    00080 def turnOnROI():
    00081   if (ctx.field("roiOn").boolValue() == True):
    00082     ctx.field("ROICombineSelect.ReferenceImage").connectFrom(ctx.field("ReferenceIm.output0"));
    00083     ctx.field("ROICombineSelect.InputImage").connectFrom(ctx.field("reformat.output0"));
    00084     ctx.addModule("AutoRegistration");
    00085     ctx.field("AutoRegistration.input0").connectFrom(ctx.field("ROICombineSelect.outRefROI"));
    00086     ctx.field("AutoRegistration.input1").connectFrom(ctx.field("ROICombineSelect.outModelROI"));
    00087   else:
    00088     ctx.disconnectField("ROICombineSelect.ReferenceImage");
    00089     ctx.disconnectField("ROICombineSelect.InputImage");
    00090     ctx.module("AutoRegistration").remove();
    00091 #    ctx.field("boxOn").value=False ;
    00092
    00093 ## performs autoregistration
    00094 def autoRegister():
    00095 # to prevent unnecessary double clicks ideally we should disable the control
    00096 # start the registration
    00097 #  ctx.field("AutoRegistration.Accuracy").setStringValue(ctx.field("accuracy").stringValue());
    00098   ctx.field("AutoRegistration.start").touch();
    00099
    00100 # create a new matrix that captures all current transformations
    00101   MLAB.log("InitialAlignMent:" + ctx.field("InitialAlignment.matrix").stringValue());
    00102   ctx.field("MatrixArithmetic.matrixA").setStringValue(ctx.field("InitialAlignment.matrix").stringValue());
    00103   ctx.field("MatrixArithmetic.matrixB").setStringValue(ctx.field("reformat.matrix").stringValue());
    00104   ctx.field("MatrixArithmetic.operation").setStringValue("Multiply");
    00105
    00106 # generates the total transformation before the automatic registration
    00107   ctx.field("MatrixArithmetic.matrixA").setStringValue(ctx.field("MatrixArithmetic.outputMatrixC").stringValue());
    00108   ctx.field("MatrixArithmetic.matrixB").setStringValue(ctx.field("AutoRegistration.Matrix").stringValue());
    00109   ctx.field("MatrixArithmetic.operation").setStringValue("Multiply");
    00110   ctx.field("roiOn").value=False;
    00111
    00112 #sets the resulting transformation as an initial one for subsequent manual adjustments
    00113   ctx.field("initialAlignMatrix").setStringValue(ctx.field("MatrixArithmetic.outputMatrixC").stringValue());
    00114   ctx.field("initialAlignMatrix").touch();
    00115   ctx.field("MemCache.clear").touch();
    00116   ctx.field("MemCache.update").touch();
    00117   ctx.field("reformat.resetMatrix").touch();
    00118   ctx.field("MemCache.update").touch();
    00119
    00120 ## set the Matrix in reformat field
    00121 def setMatrix():
    00122   ctx.field("reformat.matrix").setStringValue(ctx.parent().field("regMatrix").stringValue());
    00123   ctx.field("reformat.matrix").touch();
    00124
    00125 ## trigger the callback of parent module when user clicks save
    00126 def saveOnRegManual():
    00127   ctx.field("saveReg").touch();
    00128
    00129 ## trigger the callback of parent module when user clicks approve and save
    00130 def approveOnRegManual():
    00131   ctx.field("saveApprove").touch();
    00132
    00133 ## close the window when user clicks cancel button
    00134 def cancelonRegManual():
    00135   ctx.closeWindow();
    00136   ctx.field("cancel").touch();
    00137
    00138 ## show Help for ImgRegManual module
    00139 def helponRegManual():
    00140   ctx.showHtmlHelp();
    00141
    00142 ## close the Window
    00143 def closeTransWin():
    00144    global transWin;
    00145    if (transWin != None):
    00146       transWin.close();
    00147
    00148 #//# MeVis signature v1
    00149 #//# key: MFowDQYJKoZIhvcNAQEBBQADSQAwRgJBANEfsmYse2e1dRhkQ9AQbreCq9uxwzWLoGom13MNYmyfwoJqQOEXljLFAgw2eEjaT12G4CdqKWhRxh9ANP6n7GMCARE=:VI/mB8bT4u+mRtf/ru8yUQi8BzpaS3UeL2x62YxsUYnVqCWuLrVNLiukIIjnJMKQXlc8ezmgOIcVAV7pgvgKpQ==
    00150 #//# owner: MeVis
    00151 #//# date: 2009-06-10T04:12:25
    00152 #//# hash: vHSfj+Qt8xrIkDVP4W0Rep0YH6a3+MySa0+Cs+AoqEK/IbB+f5szwmyVTENOjzz/JEgm2t31FtHmUUMFcQg5VQ==
    00153 #//# MeVis end
    00154

All Classes Namespaces Files Functions Variables Enumerator Friends