Ver código fonte

Merge branch 'master' of wiscigt.powertheword.com:oil/EMBRACE

Andrej Studen @ VBOX 3 anos atrás
pai
commit
181bfc65af

+ 373 - 0
LICENSE

@@ -0,0 +1,373 @@
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+    means each individual or legal entity that creates, contributes to
+    the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+    means the combination of the Contributions of others (if any) used
+    by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+    means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+    means Source Code Form to which the initial Contributor has attached
+    the notice in Exhibit A, the Executable Form of such Source Code
+    Form, and Modifications of such Source Code Form, in each case
+    including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+    means
+
+    (a) that the initial Contributor has attached the notice described
+        in Exhibit B to the Covered Software; or
+
+    (b) that the Covered Software was made available under the terms of
+        version 1.1 or earlier of the License, but not also under the
+        terms of a Secondary License.
+
+1.6. "Executable Form"
+    means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+    means a work that combines Covered Software with other material, in
+    a separate file or files, that is not Covered Software.
+
+1.8. "License"
+    means this document.
+
+1.9. "Licensable"
+    means having the right to grant, to the maximum extent possible,
+    whether at the time of the initial grant or subsequently, any and
+    all of the rights conveyed by this License.
+
+1.10. "Modifications"
+    means any of the following:
+
+    (a) any file in Source Code Form that results from an addition to,
+        deletion from, or modification of the contents of Covered
+        Software; or
+
+    (b) any new file in Source Code Form that contains any Covered
+        Software.
+
+1.11. "Patent Claims" of a Contributor
+    means any patent claim(s), including without limitation, method,
+    process, and apparatus claims, in any patent Licensable by such
+    Contributor that would be infringed, but for the grant of the
+    License, by the making, using, selling, offering for sale, having
+    made, import, or transfer of either its Contributions or its
+    Contributor Version.
+
+1.12. "Secondary License"
+    means either the GNU General Public License, Version 2.0, the GNU
+    Lesser General Public License, Version 2.1, the GNU Affero General
+    Public License, Version 3.0, or any later versions of those
+    licenses.
+
+1.13. "Source Code Form"
+    means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+    means an individual or a legal entity exercising rights under this
+    License. For legal entities, "You" includes any entity that
+    controls, is controlled by, or is under common control with You. For
+    purposes of this definition, "control" means (a) the power, direct
+    or indirect, to cause the direction or management of such entity,
+    whether by contract or otherwise, or (b) ownership of more than
+    fifty percent (50%) of the outstanding shares or beneficial
+    ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+    Licensable by such Contributor to use, reproduce, make available,
+    modify, display, perform, distribute, and otherwise exploit its
+    Contributions, either on an unmodified basis, with Modifications, or
+    as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+    for sale, have made, import, and otherwise transfer either its
+    Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+    or
+
+(b) for infringements caused by: (i) Your and any other third party's
+    modifications of Covered Software, or (ii) the combination of its
+    Contributions with other software (except as part of its Contributor
+    Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+    its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+    Form, as described in Section 3.1, and You must inform recipients of
+    the Executable Form how they can obtain a copy of such Source Code
+    Form by reasonable means in a timely manner, at a charge no more
+    than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+    License, or sublicense it under different terms, provided that the
+    license for the Executable Form does not attempt to limit or alter
+    the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+*                                                                      *
+*  6. Disclaimer of Warranty                                           *
+*  -------------------------                                           *
+*                                                                      *
+*  Covered Software is provided under this License on an "as is"       *
+*  basis, without warranty of any kind, either expressed, implied, or  *
+*  statutory, including, without limitation, warranties that the       *
+*  Covered Software is free of defects, merchantable, fit for a        *
+*  particular purpose or non-infringing. The entire risk as to the     *
+*  quality and performance of the Covered Software is with You.        *
+*  Should any Covered Software prove defective in any respect, You     *
+*  (not any Contributor) assume the cost of any necessary servicing,   *
+*  repair, or correction. This disclaimer of warranty constitutes an   *
+*  essential part of this License. No use of any Covered Software is   *
+*  authorized under this License except under this disclaimer.         *
+*                                                                      *
+************************************************************************
+
+************************************************************************
+*                                                                      *
+*  7. Limitation of Liability                                          *
+*  --------------------------                                          *
+*                                                                      *
+*  Under no circumstances and under no legal theory, whether tort      *
+*  (including negligence), contract, or otherwise, shall any           *
+*  Contributor, or anyone who distributes Covered Software as          *
+*  permitted above, be liable to You for any direct, indirect,         *
+*  special, incidental, or consequential damages of any character      *
+*  including, without limitation, damages for lost profits, loss of    *
+*  goodwill, work stoppage, computer failure or malfunction, or any    *
+*  and all other commercial damages or losses, even if such party      *
+*  shall have been informed of the possibility of such damages. This   *
+*  limitation of liability shall not apply to liability for death or   *
+*  personal injury resulting from such party's negligence to the       *
+*  extent applicable law prohibits such limitation. Some               *
+*  jurisdictions do not allow the exclusion or limitation of           *
+*  incidental or consequential damages, so this exclusion and          *
+*  limitation may not apply to You.                                    *
+*                                                                      *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+  This Source Code Form is subject to the terms of the Mozilla Public
+  License, v. 2.0. If a copy of the MPL was not distributed with this
+  file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+  This Source Code Form is "Incompatible With Secondary Licenses", as
+  defined by the Mozilla Public License, v. 2.0.

+ 0 - 318
dataExplorer/dataExplorer.py

@@ -1,318 +0,0 @@
-import os
-import unittest
-import vtk, qt, ctk, slicer
-from slicer.ScriptedLoadableModule import *
-import logging
-import slicerNetwork
-import json
-import loadPatient
-
-#
-# dataExplorer
-#
-
-class dataExplorer(ScriptedLoadableModule):
-  """Uses ScriptedLoadableModule base class, available at:
-  https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/ScriptedLoadableModule.py
-  """
-
-  def __init__(self, parent):
-    ScriptedLoadableModule.__init__(self, parent)
-    self.parent.title = "dataExplorer" # TODO make this more human readable by adding spaces
-    self.parent.categories = ["EMBRACE"]
-    self.parent.dependencies = []
-    self.parent.contributors = ["Andrej Studen (University of Ljubljana)"] # replace with "Firstname Lastname (Organization)"
-    self.parent.helpText = """
-This is an example of scripted loadable module bundled in an extension.
-It performs a simple thresholding on the input volume and optionally captures a screenshot.
-"""
-    self.parent.helpText += self.getDefaultModuleDocumentationLink()
-    self.parent.acknowledgementText = """
-This extension developed within Medical Physics research programe of ARRS
-""" # replace with organization, grant and thanks.
-
-#
-# dataExplorerWidget
-#
-
-class dataExplorerWidget(ScriptedLoadableModuleWidget):
-  """Uses ScriptedLoadableModuleWidget base class, available at:
-  https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/ScriptedLoadableModule.py
-  """
-
-  def setup(self):
-    ScriptedLoadableModuleWidget.setup(self)
-    self.loadPatientLogic=loadPatient.loadPatientLogic(self)
-    # Instantiate and connect widgets ...
-
-    #
-    # Parameters Area
-    #
-    basePath=os.path.join(os.path.expanduser('~'),'.EMBRACE')
-    #'D:\\Sw\\src\\EMBRACE'
-    netConfig=os.path.join(basePath,'onko-nix.json')
-    self.sNet=slicerNetwork.labkeyURIHandler()
-    self.sNet.parseConfig(netConfig)
-    self.sNet.initRemote()
-
-    self.loadPatientLogic.setURIHandler(self.sNet)
-    self.project="EMBRACE/Studija"
-    self.dataset="ImagingVisitsManaged"
-
-
-    datasetCollapsibleButton = ctk.ctkCollapsibleButton()
-    datasetCollapsibleButton.text = "Dataset"
-    self.layout.addWidget(datasetCollapsibleButton)
-    # Layout within the dummy collapsible button
-    datasetFormLayout = qt.QFormLayout(datasetCollapsibleButton)
-
-    self.datasetButton=qt.QPushButton("Load")
-    self.datasetButton.connect('clicked(bool)',self.onDatasetLoadButtonClicked)
-    datasetFormLayout.addRow("Data:",self.datasetButton)
-
-    self.patientId=qt.QLineEdit("LJU004")
-    datasetFormLayout.addRow("Patient ID:",self.patientId)
-
-    loadCTButton=qt.QPushButton("CT")
-    loadCTButton.clicked.connect(self.onLoadCTButtonClicked)
-    datasetFormLayout.addRow("Load:",loadCTButton)
-
-    loadCTRSButton=qt.QPushButton("CT-RS")
-    loadCTRSButton.clicked.connect(self.onLoadCTRSButtonClicked)
-    datasetFormLayout.addRow("Load:",loadCTRSButton)
-
-    loadDMRButton=qt.QPushButton("DMR")
-    loadDMRButton.clicked.connect(self.onLoadDMRButtonClicked)
-    datasetFormLayout.addRow("Load:",loadDMRButton)
-
-
-
-    dataCollapsibleButton = ctk.ctkCollapsibleButton()
-    dataCollapsibleButton.text = "Data"
-    self.layout.addWidget(dataCollapsibleButton)
-    # Layout within the dummy collapsible button
-    dataFormLayout = qt.QVBoxLayout(dataCollapsibleButton)
-
-    self.data=qt.QTableWidget(3,3)
-    dataFormLayout.addWidget(self.data)
-
-    patientsCollapsibleButton = ctk.ctkCollapsibleButton()
-    patientsCollapsibleButton.text = "Patients"
-    self.layout.addWidget(patientsCollapsibleButton)
-    # Layout within the dummy collapsible button
-    self.patientsFormLayout = qt.QVBoxLayout(patientsCollapsibleButton)
-    self.signalMapper=qt.QSignalMapper()
-    self.signalMapper.connect(self.signalMapper, qt.SIGNAL("mapped(const QString &)"), self.onPatientButtonClicked)
-
-
-  def cleanup(self):
-    pass
-
-
-
-  def onDatasetLoadButtonClicked(self):
-
-      ds=self.sNet.loadDataset(self.project,self.dataset)
-      #loaded a JSON object -> convert to suitable display
-      columns=ds['columnModel']
-      self.data.setColumnCount(len(columns))
-      self.data.setRowCount(len(ds['rows']))
-      columnNames=[f['header'] for f in columns]
-      self.data.setHorizontalHeaderLabels(columnNames)
-      columnID=[f['dataIndex'] for f in columns]
-      insertRowID=0
-      for row in ds['rows']:
-          insertColumnID=0
-          for c in columnID:
-              item=qt.QTableWidgetItem(str(row[c]))
-              self.data.setItem(insertRowID,insertColumnID,item)
-              insertColumnID+=1
-          insertRowID+=1
-
-      #clear patient list
-      while self.patientsFormLayout.count():
-           child=self.patientsFormLayout.takeAt(0)
-           if child.widget():
-               self.signalMapper.removeMapping(child.widget())
-               child.widget().deleteLater()
-
-      #populate patient list
-      patientList=[f['EMBRACE_ID'] for f in ds['rows']]
-      #remove duplicates
-      patientSet=set(patientList)
-      for p in patientSet:
-           patientButton=qt.QPushButton(p)
-           patientButton.connect(patientButton, qt.SIGNAL("clicked()"),
-                self.signalMapper, qt.SLOT("map()"))
-           self.patientsFormLayout.addWidget(patientButton)
-           self.signalMapper.setMapping(patientButton,p)
-
-  def onPatientButtonClicked(self, label):
-      print "onPatientButtonClicked() for {}".format(label)
-      self.loadPatientLogic.load(label)
-
-  def onLoadCTButtonClicked(self):
-      self.CT=self.loadPatientLogic.loadCT(self.patientId.text)
-      self.CT[0]['node'].SetName(self.patientId.text+"_CT")
-
-  def onLoadCTRSButtonClicked(self):
-      self.CTRS=self.loadPatientLogic.loadCTRS(self.patientId.text)
-
-  def onLoadDMRButtonClicked(self):
-      self.DMR=self.loadPatientLogic.loadDMR(self.patientId.text)
-      self.DMR[0]['node'].SetName(self.patientId.text+"_DMR")
-
-#
-# dataExplorerLogic
-#
-
-class dataExplorerLogic(ScriptedLoadableModuleLogic):
-  """This class should implement all the actual
-  computation done by your module.  The interface
-  should be such that other python code can import
-  this class and make use of the functionality without
-  requiring an instance of the Widget.
-  Uses ScriptedLoadableModuleLogic base class, available at:
-  https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/ScriptedLoadableModule.py
-  """
-
-  def hasImageData(self,volumeNode):
-    """This is an example logic method that
-    returns true if the passed in volume
-    node has valid image data
-    """
-    if not volumeNode:
-      logging.debug('hasImageData failed: no volume node')
-      return False
-    if volumeNode.GetImageData() is None:
-      logging.debug('hasImageData failed: no image data in volume node')
-      return False
-    return True
-
-  def isValidInputOutputData(self, inputVolumeNode, outputVolumeNode):
-    """Validates if the output is not the same as input
-    """
-    if not inputVolumeNode:
-      logging.debug('isValidInputOutputData failed: no input volume node defined')
-      return False
-    if not outputVolumeNode:
-      logging.debug('isValidInputOutputData failed: no output volume node defined')
-      return False
-    if inputVolumeNode.GetID()==outputVolumeNode.GetID():
-      logging.debug('isValidInputOutputData failed: input and output volume is the same. Create a new volume for output to avoid this error.')
-      return False
-    return True
-
-  def takeScreenshot(self,name,description,type=-1):
-    # show the message even if not taking a screen shot
-    slicer.util.delayDisplay('Take screenshot: '+description+'.\nResult is available in the Annotations module.', 3000)
-
-    lm = slicer.app.layoutManager()
-    # switch on the type to get the requested window
-    widget = 0
-    if type == slicer.qMRMLScreenShotDialog.FullLayout:
-      # full layout
-      widget = lm.viewport()
-    elif type == slicer.qMRMLScreenShotDialog.ThreeD:
-      # just the 3D window
-      widget = lm.threeDWidget(0).threeDView()
-    elif type == slicer.qMRMLScreenShotDialog.Red:
-      # red slice window
-      widget = lm.sliceWidget("Red")
-    elif type == slicer.qMRMLScreenShotDialog.Yellow:
-      # yellow slice window
-      widget = lm.sliceWidget("Yellow")
-    elif type == slicer.qMRMLScreenShotDialog.Green:
-      # green slice window
-      widget = lm.sliceWidget("Green")
-    else:
-      # default to using the full window
-      widget = slicer.util.mainWindow()
-      # reset the type so that the node is set correctly
-      type = slicer.qMRMLScreenShotDialog.FullLayout
-
-    # grab and convert to vtk image data
-    qimage = ctk.ctkWidgetsUtils.grabWidget(widget)
-    imageData = vtk.vtkImageData()
-    slicer.qMRMLUtils().qImageToVtkImageData(qimage,imageData)
-
-    annotationLogic = slicer.modules.annotations.logic()
-    annotationLogic.CreateSnapShot(name, description, type, 1, imageData)
-
-  def run(self, inputVolume, outputVolume, imageThreshold, enableScreenshots=0):
-    """
-    Run the actual algorithm
-    """
-
-    if not self.isValidInputOutputData(inputVolume, outputVolume):
-      slicer.util.errorDisplay('Input volume is the same as output volume. Choose a different output volume.')
-      return False
-
-    logging.info('Processing started')
-
-    # Compute the thresholded output volume using the Threshold Scalar Volume CLI module
-    cliParams = {'InputVolume': inputVolume.GetID(), 'OutputVolume': outputVolume.GetID(), 'ThresholdValue' : imageThreshold, 'ThresholdType' : 'Above'}
-    cliNode = slicer.cli.run(slicer.modules.thresholdscalarvolume, None, cliParams, wait_for_completion=True)
-
-    # Capture screenshot
-    if enableScreenshots:
-      self.takeScreenshot('dataExplorerTest-Start','MyScreenshot',-1)
-
-    logging.info('Processing completed')
-
-    return True
-
-
-class dataExplorerTest(ScriptedLoadableModuleTest):
-  """
-  This is the test case for your scripted module.
-  Uses ScriptedLoadableModuleTest base class, available at:
-  https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/ScriptedLoadableModule.py
-  """
-
-  def setUp(self):
-    """ Do whatever is needed to reset the state - typically a scene clear will be enough.
-    """
-    slicer.mrmlScene.Clear(0)
-
-  def runTest(self):
-    """Run as few or as many tests as needed here.
-    """
-    self.setUp()
-    self.test_dataExplorer1()
-
-  def test_dataExplorer1(self):
-    """ Ideally you should have several levels of tests.  At the lowest level
-    tests should exercise the functionality of the logic with different inputs
-    (both valid and invalid).  At higher levels your tests should emulate the
-    way the user would interact with your code and confirm that it still works
-    the way you intended.
-    One of the most important features of the tests is that it should alert other
-    developers when their changes will have an impact on the behavior of your
-    module.  For example, if a developer removes a feature that you depend on,
-    your test should break so they know that the feature is needed.
-    """
-
-    self.delayDisplay("Starting the test")
-    #
-    # first, get some data
-    #
-    import urllib
-    downloads = (
-        ('http://slicer.kitware.com/midas3/download?items=5767', 'FA.nrrd', slicer.util.loadVolume),
-        )
-
-    for url,name,loader in downloads:
-      filePath = slicer.app.temporaryPath + '/' + name
-      if not os.path.exists(filePath) or os.stat(filePath).st_size == 0:
-        logging.info('Requesting download %s from %s...\n' % (name, url))
-        urllib.urlretrieve(url, filePath)
-      if loader:
-        logging.info('Loading %s...' % (name,))
-        loader(filePath)
-    self.delayDisplay('Finished with download and loading')
-
-    volumeNode = slicer.util.getNode(pattern="FA")
-    logic = dataExplorerLogic()
-    self.assertIsNotNone( logic.hasImageData(volumeNode) )
-    self.delayDisplay('Test passed!')

+ 0 - 176
dataExplorer/loadPatient.py

@@ -1,176 +0,0 @@
-import slicer
-import loadDicom
-import re
-import slicerNetwork
-import os
-import subprocess
-import importDicom
-
-fValue=loadDicom.dicomValue
-dicomModify="/afs/f9.ijs.si/home/studen/software/install/"
-dicomModify+="dicomModify/bin/dicomModify"
-
-class loadPatient(slicer.ScriptedLoadableModule.ScriptedLoadableModule):
-    def __init__(self,parent):
-        slicer.ScriptedLoadableModule.ScriptedLoadableModule.__init__(self, parent)
-        self.className="loadPatient"
-        self.parent.title="loadPatient"
-        self.parent.categories = ["EMBRACE"]
-        self.parent.contributors = ["Andrej Studen (UL/FMF)"] 
-
-class loadPatientLogic(slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic):
-    def __init__(self,parent):
-       slicer.ScriptedLoadableModule.ScriptedLoadableModuleLogic.__init__(self, parent)
-
-       #self.plugin=slicer.modules.dicomPlugins['DicomRtImportExportPlugin']()
-       #self.volumePlugin=slicer.modules.dicomPlugins['DICOMScalarVolumePlugin']()
-       self.dicomLoader=loadDicom.loadDicomLogic(self)
-       self.dicomImporter=importDicom.importDicomLogic(self)
-       self.dicomImporter.local=self.local
-       self.dicomImporter.basePath=self.basePath
-       self.dicomLoader.local=self.local
-       self.dicomLoader.basePath=self.basePath
-       self.project="EMBRACE/Studija"
-       self.imagingDataset="ImagingVisitsManaged"
-       self.idDataset="PopisneStevilke"
-       self.dicomProject="Test/Transfer"
-       self.dicomDataset="Imaging"
-       self.dicomPath=self.dicomProject+'/%40files/dicom'
-
-
-       #self.rtReader=slicer.vtkSlicerDicomRtReader()
-
-       #start SSL/TLS configuration
-
-    def setURIHandler(self, net):
-        self.sNet=net
-
-    def setLocal(self,basePath):
-        self.dicomImporter.setLocal(basePath)
-        self.dicomLoader.setLocal(basePath)
-       
-    def getOICode(self, label):
-        filter=[]
-        filterID={"variable":"EMBRACE_ID",
-            "oper":"eq",
-            "value":label}
-        filter.append(filterID)
-        fSet=self.sNet.filterDataset(self.project,self.idDataset,filter)
-        try:
-            row=fSet["rows"][0]
-        except:
-            print("OI code for {} not found").format(label)
-            return None
-        return row["OICode"]
-
-
-    def load(self,label):
-        #clear previous data
-        debug=True
-        loadDicom.clearNodes()
-
-        dirUrl=self.project+"/@files"
-        dir=dirUrl+'/'+label
-        #load segmentations
-        rs=dir+"/RS/DICOM";
-        self.dicomLoader.load(self.sNet,rs)
-
-
-        rsMatch='None'
-        filter=[]
-        filterID={"variable":"EMBRACE_ID",
-            "oper":"eq",
-            "value":label}
-        filter.append(filterID)
-        filterType={"variable":"Type",
-                "oper":"eq",
-                "value":"RS"}
-        filter.append(filterType)
-        fSet=self.sNet.filterDataset(self.project,self.dataset,filter)
-        fData=fSet['rows']
-        row=fData[0] #first match
-
-        if row['rsMatch']==None:
-            return
-
-        if row['rsMatch']=='NONE':
-            return
-
-        dicomDir=dir+'/'+row['rsMatch']+'/DICOM'
-        if debug:
-            print "Loading {}".format(dicomDir)
-        self.dicomLoader.load(self.sNet,dicomDir)
-
-    def findEmbrace(self,embraceId,imageType):
-        filter=[]
-        filterID={"variable":"EMBRACE_ID",
-            "oper":"eq",
-            "value":embraceId}
-        filter.append(filterID)
-        filterType={"variable":"Type",
-                "oper":"eq",
-                "value":imageType}
-        filter.append(filterType)
-        fSet=self.sNet.filterDataset(self.project,self.imagingDataset,filter)
-        try:
-            seqNum=fSet["rows"][0]["pseudoTransverseID"]
-        except:
-            print("CT data for patient {} not found").format(label)
-            return None
-
-        OIcode=self.getOICode(embraceId)
-        dicomFilter=[]
-        filterID={"variable":"PatientId",
-            "oper":"eq",
-            "value":OIcode}
-        dicomFilter.append(filterID)
-        filterSeq={"variable":"SequenceNum",
-            "oper":"eq",
-            "value":str(seqNum)}
-        dicomFilter.append(filterSeq)
-        fSet=self.sNet.filterDataset(self.dicomProject,self.dicomDataset,dicomFilter)
-        try:
-            row=fSet['rows'][0]
-        except:
-            print("Dicom for patient {}/{} not found").format(label,OIcode)
-            return None
-        return {'Study':row['Study'],'Series':row['Series']}
-
-    def loadCT(self,label):
-        studySeries=self.findEmbrace(label,"CT")
-        if studySeries==None:
-            return
-        relativePath=self.dicomPath+'/'+studySeries['Study']+'/'+studySeries['Series']
-        dicomReadFilter={'seriesNumber':"SeriesLabel",
-                        'studyInstanceUid':None,
-                        'frameOfReferenceInstanceUid':None}
-        return self.dicomImporter.loadVolumes(self.sNet,relativePath,dicomReadFilter)
-
-    def loadCTRS(self,label):
-        studySeries=self.findEmbrace(label,"CT-RS")
-        if studySeries==None:
-            return
-        relativePath=self.dicomPath+'/'+studySeries['Study']+'/'+studySeries['Series']
-        dicomReadFilter={'seriesNumber':"SeriesLabel",
-                        'studyInstanceUid':None,
-                        'frameOfReferenceInstanceUid':None}
-        print("Loading segmentation: {}").format(relativePath)
-        return self.dicomLoader.loadSegmentations(self.sNet,relativePath,dicomReadFilter)
-
-
-    def loadDMR(self,label):
-        #clear previous data
-        debug=True
-
-        dirUrl=self.project+"/@files"
-        dir=dirUrl+'/'+label
-        #load segmentations
-        rs=dir+"/DMR/DICOM";
-
-        dicomReadFilter={'seriesNumber':"SeriesLabel",
-                        'sequenceName':"*tse2d1_3",
-                        'percentPhaseFieldOfView':90,
-                        'studyInstanceUid':None,
-                        'frameOfReferenceInstanceUid':None}
-
-        return self.dicomImporter.loadVolumes(self.sNet,rs,dicomReadFilter)

+ 115 - 0
loadPatient.py

@@ -0,0 +1,115 @@
+#load all relevant patient data
+#requires labkeyInterface through labkeyDatabrowser db, labkeyFileBrowser fb, fbDMR, importDicom iDicom and loadDicom lDicom
+
+       
+def getOICode(db, project, label):
+        idFilter={"variable":"EMBRACE_ID",
+            "oper":"eq",
+            "value":label}
+        fSet=db.selectRows(project,'study','PopisneStevilke',[idFilter])
+        try:
+            row=fSet["rows"][0]
+        except:
+            print("OI code for {} not found").format(label)
+            return None
+        return row["OICode"]
+
+
+def load(db,fb,fbDMR,iDicom,lDicom,project,label):
+
+    print('loadPatient.load ver: 1.0.3')
+
+
+
+    idFilter={'variable':'EMBRACE_ID','value':label,'oper':'eq'}
+    ctFilter={'variable':'type','value':'CT','oper':'eq'}
+    dsCT=db.selectRows(project,'study','ImagingVisitsManaged',[idFilter,ctFilter])
+    returnObj={}
+
+    try:
+        ctRow=dsCT['rows'][0]
+    except IndexError:
+        return returnObj
+    
+    oiCode=getOICode(db,project,label)
+    
+    #load ct
+    seqNum=ctRow['pseudoTransverseID']
+    oiFilter={'variable':'PatientId','value':oiCode,'oper':'eq'}
+    sFilter={'variable':'SequenceNum','value':'{:.0f}'.format(seqNum),'oper':'eq'}
+    
+    dsDicom=db.selectRows('Test/Transfer','study','Imaging',[oiFilter,sFilter])
+    try:
+        rDicom=dsDicom['rows'][0]
+    except IndexError:
+        return returnObj
+    
+    iPath=['dicom',rDicom['Study'],rDicom['Series']]
+    dicomReadFilter={'seriesNumber':"SeriesLabel",
+                        'studyInstanceUid':None,
+                        'frameOfReferenceInstanceUid':None}
+
+    ctVolumes=iDicom.loadVolumes(fb,'Test/Transfer',iPath,dicomReadFilter)
+    ctNode=ctVolumes[0]['node']
+    ctNode.SetName(label+'_CT')
+
+    #load dmr
+    #uses different server!!!
+    dmrFilter={'variable':'type','value':'DMR','oper':'eq'}
+    dsDMR=db.selectRows(project,'study','ImagingVisitsManaged',[idFilter,dmrFilter])
+    try:
+        dmrRow=dsDMR['rows'][0]
+    except IndexError:
+        return returnObj
+    
+    dmrName=dmrRow['Name']
+    iPath=['PRETVORJENE',dmrName,'DICOM']
+    dicomReadFilter={'seriesNumber':"SeriesLabel",
+                        'sequenceName':"*tse2d1_3",
+                        'percentPhaseFieldOfView':90,
+                        'studyInstanceUid':None,
+                        'frameOfReferenceInstanceUid':None,
+                        'scanningSequence':None,
+                        'sequenceVariant':None}
+
+    dmrVolumes=iDicom.loadVolumes(fbDMR,project,iPath,dicomReadFilter)
+    try:
+        dmrNode=dmrVolumes[0]['node']
+        dmrNode.SetName(label+'_DMR')
+    except IndexError:
+        return returnObj
+
+    #load CT-RS
+    ctrsFilter={'variable':'type','value':'CT-RS','oper':'eq'}
+    dsCTRS=db.selectRows(project,'study','ImagingVisitsManaged',[idFilter,ctrsFilter])
+    try:
+        ctrsRow=dsCTRS['rows'][0]
+        print('CTRS: {}'.format(len(dsCTRS['rows'])))
+    except IndexError:
+        return returnObj
+    seqNum=ctrsRow['pseudoTransverseID']
+    sFilter={'variable':'SequenceNum','value':'{:.0f}'.format(seqNum),'oper':'eq'}
+    
+    dsDicomRT=db.selectRows('Test/Transfer','study','Imaging',[oiFilter,sFilter])
+    try:
+        rDicomRT=dsDicomRT['rows'][0]
+        print('CT-RS Dicom: {}'.format(len(dsDicomRT['rows'])))
+        print('ID: {}'.format(rDicomRT['PatientId']))
+    except IndexError:
+        return returnObj
+
+    iPath=['dicom',rDicomRT['Study'],rDicomRT['Series']]
+    dicomReadFilter={'seriesNumber':"SeriesLabel",
+                       'studyInstanceUid':None,
+                       'frameOfReferenceInstanceUid':None}
+
+    rtSeg=lDicom.loadSegmentations(fb,'Test/Transfer',iPath,dicomReadFilter)
+    rtNode=rtSeg[0]['node']
+    rtNode.SetName(label+'_CTRS')
+
+    return {'CT':ctNode,'DMR':dmrNode,'CTRS':rtNode,
+        'metadataCT':ctVolumes[0]['metadata'],
+        'metadataDMR':dmrVolumes[0]['metadata'],
+        'metadataCTRS':rtSeg[0]['metadata']
+        }
+

+ 0 - 0
dataExplorer/CTRegistration.py → slicerModules/CTRegistration.py


+ 0 - 0
dataExplorer/Resources/Icons/dataExplorer.png → slicerModules/Resources/Icons/dataExplorer.png


+ 0 - 0
dataExplorer/Testing/CMakeLists.txt → slicerModules/Testing/CMakeLists.txt


+ 0 - 0
dataExplorer/Testing/Python/CMakeLists.txt → slicerModules/Testing/Python/CMakeLists.txt