def initTrakem(path, nbLayers, mipmaps = False): #initialize a project path = cleanLinuxPath(path) ControlWindow.setGUIEnabled(False) project = Project.newFSProject("blank", None, path) project.getLoader().setMipMapsRegeneration(mipmaps) layerset = project.getRootLayerSet() for i in range(nbLayers): # create the layers layerset.getLayer(i, 1, True) project.getLayerTree().updateList(layerset) #update the LayerTree Display.updateLayerScroller(layerset) # update the display slider IJ.log('TrakEM project initialized with ' + str(nbLayers) + ' layers and stored in ' + path + ' (but not saved yet)') return project
from java.lang import Runtime, Thread from java.util.concurrent.atomic import AtomicInteger def elasticMontage(): IJ.log('Thread called **************************') while l.get() < min(nLayers, currentWrittenLayer + nLayersAtATime + 1) : k = l.getAndIncrement() if k < min(nLayers, currentWrittenLayer + nLayersAtATime): IJ.log('Start montaging elastically layer ' + str(k)) if layerset.getLayers().get(k).getNDisplayables() > 1: # some EM projects have a single large tile AlignTask().montageLayers(params, layerset.getLayers(k, k)) namePlugin = 'montage_ElasticEM' MagCFolder = fc.startPlugin(namePlugin) ControlWindow.setGUIEnabled(False) MagCParams = fc.readMagCParameters(MagCFolder) nLayersAtATime = MagCParams[namePlugin]['nLayersAtATime'] nThreads = MagCParams[namePlugin]['nThreads'] projectPath = fc.cleanLinuxPath(fc.findFilesFromTags(MagCFolder,['EM', 'Project'])[0]) project, loader, layerset, nLayers = fc.openTrakemProject(projectPath) IJ.log('Sleeping in case the opening of the large project takes some time ...') time.sleep(20) # parameters for elastic montage params = ElasticMontage.Param().clone() params.bmScale = 0.5