Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for referencedSeriesSequence in refSeriesSequence.ReferencedSeriesSequence:
for refSOPSequence in referencedSeriesSequence.ReferencedSOPSequence:
if refSOPSequence.ReferencedSOPClassUID == self.UID_SegmentationStorage:
logging.debug("Found referenced segmentation")
loadable.ReferencedSegmentationInstanceUIDs[uid].append(referencedSeriesSequence.SeriesInstanceUID)
elif refSOPSequence.ReferencedSOPClassUID == self.UID_RealWorldValueMappingStorage: # handle SUV mapping
logging.debug("Found referenced RWVM")
loadable.ReferencedRWVMSeriesInstanceUIDs.append(referencedSeriesSequence.SeriesInstanceUID)
else:
# TODO: those are not used at all
logging.debug( "Found other reference")
loadable.ReferencedOtherInstanceUIDs.append(refSOPSequence.ReferencedSOPInstanceUID)
for segSeriesInstanceUID in loadable.ReferencedSegmentationInstanceUIDs[uid]:
segLoadables = segPlugin.examine([slicer.dicomDatabase.filesForSeries(segSeriesInstanceUID)])
for segLoadable in segLoadables:
loadable.referencedInstanceUIDs += segLoadable.referencedInstanceUIDs
loadable.referencedInstanceUIDs = list(set(loadable.referencedInstanceUIDs))
if len(loadable.ReferencedSegmentationInstanceUIDs[uid])>1:
logging.warning("SR references more than one SEG. This has not been tested!")
for segUID in loadable.ReferencedSegmentationInstanceUIDs:
loadable.referencedSegInstanceUIDs.append(segUID)
if len(loadable.ReferencedRWVMSeriesInstanceUIDs)>1:
logging.warning("SR references more than one RWVM. This has not been tested!")
# not adding RWVM instances to referencedSeriesInstanceUIDs
return loadable
def importDICOMSeries(self):
indexer = ctk.ctkDICOMIndexer()
db = slicer.dicomDatabase
fileList = self.getFileList(self._intraopDataDir)
newFileList = list(set(fileList) - set(self.currentFileList))
for currentFile in newFileList:
currentFile = os.path.join(self._intraopDataDir, currentFile)
indexer.addFile(db, currentFile, None)
series = self.makeSeriesNumberDescription(currentFile)
if series and series not in self.seriesList and self.isDICOMSeriesEligible(series):
self.seriesList.append(series)
self.createLoadableFileListForSeries(series)
indexer.addDirectory(db, self._intraopDataDir)
indexer.waitForImportFinished()
def generateSlicenamesTextfile(ctDicomSeriesUID, slicenamesFilename, outputFolder):
""" Generate slicenames.txt file, with list of ct dicom slices, in increasing slice order (IS direction)
"""
filePaths = slicer.dicomDatabase.filesForSeries(ctDicomSeriesUID)
if len(filePaths) == 0:
logging.error('Failed to find files in DICOM database for UID ' + str(ctDicomSeriesUID))
return False
from DICOMLib import DICOMUtils
unsortedFileList = slicer.dicomDatabase.filesForSeries(ctDicomSeriesUID)
sortedFileList, distances, warnings = DICOMUtils.getSortedImageFiles(unsortedFileList)
outFile = open(os.path.join(outputFolder, slicenamesFilename), "w")
counter = 1
numDicomFiles = len(sortedFileList)
for sliceFileName in sortedFileList:
outFile.write(sliceFileName)
if counter != numDicomFiles:
outFile.write("\n")
counter += 1
def loadSeriesByFileName(self, filename):
seriesUID = slicer.dicomDatabase.seriesForFile(filename)
self.loadSeries(seriesUID)
def loadTestData(self, collection="MRHead",
uid="2.16.840.1.113662.4.4168496325.1025306170.548651188813145058"):
if not len(slicer.dicomDatabase.filesForSeries(uid)):
sampleData = TestDataLogic.downloadAndUnzipSampleData(collection)
TestDataLogic.importIntoDICOMDatabase(sampleData['volume'])
self.loadSeries(uid)
masterNode = slicer.util.getNodesByClass('vtkMRMLScalarVolumeNode')[-1]
tableNode = slicer.vtkMRMLTableNode()
tableNode.SetAttribute("QuantitativeReporting", "Yes")
slicer.mrmlScene.AddNode(tableNode)
self.measurementReportSelector.setCurrentNode(tableNode)
self.segmentEditorWidget.editor.setMasterVolumeNode(masterNode)
self.retrieveTestDataButton.enabled = False