widthEM = imEM0.width
heightEM = imEM0.height
imEM0.close()
f = open(os.path.join(registrationFolder, 'lowResEMBounds'), 'w')
pickle.dump([widthEM, heightEM], f)
f.close()

registrationStatsPath = os.path.join(registrationFolder, 'registrationStats')
registrationStats = []

# create dummy trakem for applying affine and cropping LM in the first registration step
pZ, loaderZ, layersetZ, nLayersZ = fc.getProjectUtils(
    fc.initTrakem(temporaryFolder, 1))
layersetZ.setDimensions(0, 0, widthEM * 5, heightEM * 5)
layerZ = layersetZ.getLayers().get(0)

lock = threading.Lock()

# Setting up the parallel threads and starting them
atomicI = AtomicInteger(0)
fc.startThreads(computeRegistration, fractionCores=1, wait=0.5)

fc.closeProject(pZ)  # close dummy trakem

# save some stats on the registration
with open(registrationStatsPath, 'w') as f:
    pickle.dump(registrationStats, f)

fc.terminatePlugin(namePlugin, MagCFolder)
# fc.shouldRunAgain(namePlugin, currentLayer, nSections, MagCFolder, '', increment = nLayersAtATime)
Exemplo n.º 2
0
# alignment parameters
regParams = Register_Virtual_Stack_MT.Param()
regParams.minInlierRatio = 0
regParams.registrationModelIndex = 1
regParams.featuresModelIndex = 1

regParams.sift.fdBins = 8
regParams.sift.fdSize = 4
regParams.sift.initialSigma = 1.6
regParams.sift.maxOctaveSize = 1024
regParams.sift.minOctaveSize = 64
regParams.sift.steps = 6

regParams.interpolate = True
regParams.maxEpsilon = 25
regParams.minInlierRatio = 0
regParams.rod = 0.92

# perform alignment
if executeAlignment:
	fc.rigidAlignment(projectPath, regParams, name = namePlugin, boxFactor = boxFactor)

# open the project and save all transforms of all tiles in all sections
IJ.log('Saving the coordinates transforms of each patch of each layer')
project, loader, layerset, nLayers = fc.openTrakemProject(projectPath)
transformsPath = os.path.join(os.path.dirname(projectPath), namePlugin + 'transforms.txt')
fc.writeAllAffineTransforms(project,transformsPath)
fc.closeProject(project)

fc.terminatePlugin(namePlugin, MagCFolder)
Exemplo n.º 3
0
            patch.setCoordinateTransform(
                MLSTransform
            )  # does the order matter ? apparently yes, but I have to be sure that it is not an offset problem
            IJ.log('Setting the mlsTransform in layer ' + str(l) + ' ' +
                   str(MLSTransform))
            patch.updateBucket()

            if idChannel < len(channels) - 2:  # if it is a fluochannel
                MLSTransformedFolder = fc.mkdir_p(
                    os.path.join(LMFolder, 'MLS_Transformed_' + str(channel),
                                 ''))
                imp = loader.getFlatImage(layer, roiExport, 1, 0x7fffffff,
                                          ImagePlus.GRAY8, Patch,
                                          layer.getAll(Patch), True,
                                          Color.black, None)
                impPath = os.path.join(
                    MLSTransformedFolder, 'MLSTransformed_' + channel + '_' +
                    str(l).zfill(4) + '.tif')
                IJ.save(imp, impPath)

    IJ.log('Project ' + channel + ' assembled')

    # # Warning ! Should I resize or not ? does this not create an offset ?
    # fc.resizeDisplay(layerset)

    p.save()
    fc.closeProject(p)

IJ.log('Done')
fc.terminatePlugin(namePlugin, MagCFolder)