MagCFolder = fc.startPlugin(namePlugin) # MagCFolder = r'E:\Users\Thomas\MixturesClean\MinimalPipelineTest5Sections_OneMoreTest04_07_17' ControlWindow.setGUIEnabled(False) width, height, nChannels, xGrid, yGrid, scaleX, scaleY, channels = fc.readSessionMetadata( MagCFolder) # channels = ['Brightfield', 'GFP', 'DsRed', 'contrastedBrightfield'] LMFolder = os.path.join(MagCFolder, 'MagC_LM') projectPath = fc.findFilesFromTags( MagCFolder, ['EM', 'Project' ])[0] # should I make 2 projects ? One for rigid, one for warped ? exportedEMFolder = fc.findFoldersFromTags( MagCFolder, ['export_alignedEMForRegistration'])[0] nLayers = len(os.listdir(exportedEMFolder)) registrationFolder = os.path.join(os.path.dirname(projectPath), 'LMEMRegistration') f = open(os.path.join(registrationFolder, 'lowResEMBounds'), 'r') widthEM, heightEM = pickle.load(f) f.close() pZ, loaderZ, layersetZ, nLayersZ = fc.getProjectUtils( fc.initTrakem(registrationFolder, 1)) layersetZ.setDimensions(0, 0, widthEM * 5, heightEM * 5) layerZ = layersetZ.getLayers().get(0) # create the folders
nSections = fc.readParameters(EMMetadataPath)['nSections'] # nSections = 20 BIB = False ordered_surface_ids_path = [ os.path.join(MagCFolder, n) for n in os.listdir(MagCFolder) if 'ordered_surface_ids' in n ] if len(ordered_surface_ids_path) != 0: ordered_surface_ids_path = ordered_surface_ids_path[0] ordered_surface_ids = readIds(ordered_surface_ids_path) BIB = True projectPath = fc.findFilesFromTags(MagCFolder, ['EM', 'Project'])[0] exportedEMFolder = fc.findFoldersFromTags( MagCFolder, ['export_alignedEMForRegistration'])[0] exportedLMFolder = fc.findFoldersFromTags( MagCFolder, ['exported_downscaled_1_' + channels[-1] ])[0] # finds the brightfield contrasted channel temporaryFolder = fc.mkdir_p( os.path.join(os.path.dirname(projectPath), 'temporary_LMEMRegistration')) # to save contrasted images registrationFolder = fc.mkdir_p( os.path.join(os.path.dirname(projectPath), 'LMEMRegistration')) # to save contrasted images imPaths = {} imPaths['EM'] = [ os.path.join(exportedEMFolder, imageName) for i, imageName in enumerate(fc.naturalSort(os.listdir(exportedEMFolder))) if os.path.splitext(imageName)[1] == '.tif'
from java.awt.geom import AffineTransform from java.awt import Rectangle from java.util import HashSet, ArrayList from ini.trakem2 import Project, ControlWindow from ini.trakem2.display import Patch from java.util.concurrent.atomic import AtomicInteger namePlugin = 'alignRigid_EM' MagCFolder = fc.startPlugin(namePlugin) ControlWindow.setGUIEnabled(False) MagC_EM_Folder = os.path.join(MagCFolder, 'MagC_EM', '') MagCParameters = fc.readMagCParameters(MagCFolder) regModel = MagCParameters[namePlugin]['regModel'] inputFolder = fc.findFoldersFromTags(MagCFolder, ['export_stitchedEMForAlignment'])[0] imagePaths = filter( lambda x: os.path.splitext(x)[1] == '.tif', fc.naturalSort( [os.path.join(inputFolder, x) for x in os.listdir(inputFolder)])) regParams = Register_Virtual_Stack_MT.Param() regParams.minInlierRatio = 0 regParams.registrationModelIndex = regModel # 1-Rigid, 2-Similarity, 3-Affine regParams.featuresModelIndex = regModel exportForRigidAlignmentFolder = inputFolder resultRigidAlignmentFolder = fc.mkdir_p( os.path.join(MagC_EM_Folder, 'resultRigidAlignment')) ################################################