Esempio n. 1
0
currentLayerPath = os.path.join(os.path.dirname(projectPath), 'currentLayer_' + namePlugin + '.txt')
currentWrittenLayer = fc.incrementCounter(currentLayerPath, increment = nLayersAtATime)
l = AtomicInteger(currentWrittenLayer)

# fc.startThreads(elasticMontage(), wait = 1, nThreads = nThreads) /!\ it does not work I do not understand why. Probably a java6 issue because it works in other scripts in java8 ...

threads = []
for p in range(nThreads):
	thread = Thread(elasticMontage)
	threads.append(thread)
	thread.start()
	time.sleep(0.5)
	
for thread in threads:
	thread.join()


IJ.log( namePlugin + ' layer ' + str(currentWrittenLayer))
fc.resizeDisplay(layerset)
project.save()

IJ.log('Sleeping in case the saving of the large project takes some time ...')
time.sleep(20)

# save all transforms
transformsPath = os.path.join(os.path.dirname(projectPath) , namePlugin + '_Transforms.txt')
if l.get() > nLayers-1:
	fc.writeAllAffineTransforms(project,transformsPath)

fc.shouldRunAgain(namePlugin, currentWrittenLayer, nLayers, MagCFolder, project, increment = nLayersAtATime)
		if k < min(nLayers, currentWrittenLayer + nLayersAtATime):
			IJ.log('Start exporting layer ' + str(k) + ' currentWrittenLayer - ' + str(currentWrittenLayer))
			fc.exportFlat(project, exportFolder, 1/float(downsamplingFactor), baseName = 'stitchedDownsampledEM', bitDepth = 8, layers = [k])

namePlugin = 'export_stitchedEMForAlignment'
MagCFolder = fc.startPlugin(namePlugin)
ControlWindow.setGUIEnabled(False)

MagCParams = fc.readMagCParameters(MagCFolder)
nLayersAtATime = min (MagCParams[namePlugin]['nLayersAtATime'], Runtime.getRuntime().availableProcessors())
nThreads = MagCParams[namePlugin]['nThreads']

# getting downsamplingFactor
downsamplingFactor = MagCParams['downsample_EM']['downsamplingFactor']

projectPath = fc.cleanLinuxPath(fc.findFilesFromTags(MagCFolder,['EM', 'Project'])[0])
exportFolder = fc.mkdir_p(os.path.join(os.path.dirname(projectPath), namePlugin))
project, loader, layerset, nLayers = fc.openTrakemProject(projectPath)

fc.resizeDisplay(layerset) # has been done in previous script but in case ...

currentLayerPath = os.path.join(os.path.dirname(projectPath), 'currentLayer_' + namePlugin + '.txt')
currentWrittenLayer = fc.incrementCounter(currentLayerPath, increment = nLayersAtATime)

atom = AtomicInteger(currentWrittenLayer)
fc.startThreads(exportLayer, wait = 0, nThreads = nThreads)

# project.save() # why do I save the project here ? To save mipmaps for subsequent faster processing ? Probably not needed ...
time.sleep(3)

fc.shouldRunAgain(namePlugin, currentWrittenLayer, nLayers, MagCFolder, project, increment = nLayersAtATime)