コード例 #1
0
import glob
import logging
import os
import shutil
import sys

from filenameparser import ParseFilename, mapping
from nornir_buildmanager import metadatautils
from nornir_buildmanager.VolumeManagerETree import *
from nornir_buildmanager.importers import filenameparser
import nornir_shared.prettyoutput as prettyoutput
import nornir_shared.files


imageNameMappings = [mapping('Section', typefunc=int),
                     mapping('Channel', typefunc=str),
                     mapping('Filter', typefunc=str, default=None),
                     mapping('ImageSetName', typefunc=str, default=None),
                     mapping('Downsample', typefunc=int, default=1)]

def FillInMissingImageNameData(imageData):
    '''Not all image names will have the essential information on where the image belongs.
       The image name mapping system is not terribly sophisticated.  This
       function uses what is known to fill in the blanks'''

    try:
        imagesetisdownsample = int(imageData.ImageSetName)
        if imageData.Downsample == 1:
            Downsample = imagesetisdownsample
            imageData.ImageSetName = None
コード例 #2
0
    DirList = nornir_shared.files.RecurseSubdirectoriesGenerator(ImportPath, RequiredFiles="*." + extension, ExcludeNames=[], ExcludedDownsampleLevels=[])
    for path in DirList:
        for idocFullPath in glob.glob(os.path.join(path, '*.' + extension)):
            PMGImport.ToMosaic(VolumeElement, idocFullPath, VolumeElement.FullPath, *args, **kwargs)
            
    return VolumeElement


DEBUG = False

'''#PMG Files are expected to have this naming convention:
       # Slide#_Block#_Initials_Mag_Spot_Probe
       # Only the last two, Spot and Probe, are used as section #
       # and channel name respectively.  The others are appended
       # to the directory name'''
pmgMappings = [ mapping('Slide', typefunc=int),
               mapping('Block', typefunc=str),
               mapping('Section', typefunc=int, default=None),
               mapping('Initials', typefunc=str),
               mapping('Mag', typefunc=str),
               mapping('Spot', typefunc=int),
               mapping('Probe', typefunc=str)]

def ParsePMGFilename(PMGPath):

    return filenameparser.ParseFilename(PMGPath, pmgMappings)


class PMGInfo(filenameparser.FilenameInfo):

    def __init__(self, **kwargs):