def loadClassifierResult(scanName, scanPath, expandPath): # Get scanInformation = loadScanInformation(scanPath, expandPath) # Get classifierInformation classifierPath = expandPath(scanInformation['probabilities']['classifier']['path']) classifierInformation = store.loadInformation(classifierPath) # Get datasetInformation datasetPath = expandPath(classifierInformation['dataset']['path']) datasetInformation = store.loadInformation(datasetPath) # Get sourceInformation sourceWindowPaths = map(expandPath, store.unstringifyStringList(datasetInformation['sources']['window paths'])) sourcePatchPatchs = map(expandPath, store.unstringifyStringList(datasetInformation['sources']['patch paths'])) sourceInformation = { 'windows': [loadSourceWindowInformation(x, expandPath) for x in sourceWindowPaths], 'patches': [loadSourcePatchInformation(x, expandPath) for x in sourcePatchPatchs], } # Get most recent patchInformation using probabilityPath folderStore = folder_store.Store(os.path.dirname(expandPath('.'))) patchInformation = loadPatchInformationFromProbabilityPath(folderStore, scanPath) # Append return { 'patches': patchInformation, 'scans': scanInformation, 'classifiers': classifierInformation, 'datasets': datasetInformation, 'sources': sourceInformation, 'name': scanName, }
def loadScanInformation(probabilityPath, expandPath): # Initialize information = store.loadInformation(probabilityPath) scanInformation = { 'probabilities': information, } imagePath = expandPath(information['probability']['image path']) regionPath = expandPath(information['probability']['region path']) regionInformation = store.loadInformation(regionPath) if regionInformation: scanInformation['regions'] = regionInformation scanInformation['images'] = store.loadInformation(imagePath) # Return return scanInformation
def loadSourcePatchInformation(sourcePath, expandPath): # Get patchInformation patchInformation = store.loadInformation(sourcePath) if not patchInformation: return {} # Get scanInformation probabilityPath = patchInformation['patches']['probability path'] scanInformation = loadScanInformation(probabilityPath, expandPath) # Assemble scanInformation['patches'] = patchInformation # Return return scanInformation
def loadSourceWindowInformation(sourcePath, expandPath): # Get windowInformation windowInformation = store.loadInformation(sourcePath) if not windowInformation: return {} # Add extra information sourceName = getName(pattern_sourceName, os.path.dirname(sourcePath)) windowInformation['parameters'] = queueReader.getInformation_sampleWindows(sourceName) # Initialize sourceWindowInformation = { 'windows': windowInformation, } # Get regionInformation regionPath = expandPath(windowInformation['regions']['path']) regionInformation = store.loadInformation(regionPath) if regionInformation: # Get imageInformation imagePath = expandPath(regionInformation['parameters']['image path']) imageInformation = store.loadInformation(imagePath) # Store sourceWindowInformation['regions'] = regionInformation sourceWindowInformation['images'] = imageInformation # Return return sourceWindowInformation
def loadInformations(informationName, path): # Initialize informationByPath = {} folderName = folder_store.folderNameByName[informationName] fileName = folder_store.fileNameByFolderName[informationName] # For each folder, for basePath, folderNames, fileNames in os.walk(path): # Skip Subversion files if '.svn' in basePath: continue # Only pay attention a specific folder if '%s/' % folderName in basePath: # Get information informationPath = os.path.join(basePath, fileName) information = store.loadInformation(informationPath) # If we have information, if information: # Store informationByPath[basePath] = information # Return return informationByPath