def buildSummaryMetadata(WorkingDir,importMicrographs,summaryFile,MDL_TYPE):
    md = xmipp.MetaData()
    importMd = xmipp.MetaData(importMicrographs)
    importMd.removeDisabled()
    for id in importMd:
        inputFile = importMd.getValue(MDL_TYPE,id)
        micrographName = os.path.basename(inputFile)
        shortname = replaceFilenameExt(micrographName, '')
        micrographDir = join(WorkingDir, 'extra', shortname)                    
        
        objId = md.addObject()
        md.setValue(MDL_TYPE, inputFile, objId)
        ctfparam = _getFilename('ctfparam', micrographDir=micrographDir)
        labels = [xmipp.MDL_PSD, xmipp.MDL_PSD_ENHANCED, xmipp.MDL_CTF_MODEL,xmipp.MDL_IMAGE1, xmipp.MDL_IMAGE2]
        if exists(ctfparam): # Get filenames
            keys = ['psd', 'enhanced_psd', 'ctfparam', 'ctfmodel_quadrant', 'ctfmodel_halfplane']
            values = [_getFilename(key, micrographDir=micrographDir) for key in keys]
        else: # No files
            values = ['NA'] * len(labels)

        # Set values in metadata
        for label, value in zip(labels, values):
            md.setValue(label, value, objId)
    
    if not md.isEmpty():
        md.sort(MDL_TYPE)
        md.write(summaryFile)