Exemplo n.º 1
0
def pageFolderActions(abfFolder, parentNote):

    abfPath = os.path.join(abfFolder.path, parentNote.abfID) + ".abf"
    urlParent = "/ABFparent" + abfBrowse.getUrl(abfPath)
    urlAnalyze = "/ABFanalyze" + abfBrowse.getUrl(abfFolder.path)
    urlExperiment = "/ABFexperiment" + abfBrowse.getUrl(abfFolder.path)

    html = ""
    html += "<div style='background-color: #F6F6F6; padding: .5em; color: gray'>"

    html += "<code>"
    unanalyzedAbfs = abfFolder.abfsRequiringAnalysis()
    if len(unanalyzedAbfs):
        with open(abfBrowse.AUTOANALYSIS_COMMAND_FILE) as f:
            commandText = f.read()
        html += f"Folder contains {len(unanalyzedAbfs)} unanalyzed ABFs | "
        if abfFolder.path in commandText:
            html += "this folder is in the auto-analysis list | "
        else:
            html += f"<a href='{urlAnalyze}' class='abfAnalysisNeeded'>auto-analyze this folder</a> | "
            #html += f"<span class='abfAnalysisNeeded'>Auto-analysis disabled (COVID-19). Analyze with pyABFauto.</span> | "
    else:
        html += f"<a href='{urlAnalyze}' style='color: gray;'>No ABFs require analysis</a> | "

    html += f"<a href='{urlParent}?deleteGraphsForChildren' class='' style='color: gray;'>delete graphs</a> | "
    html += f"<a href='{urlExperiment}' class=''>experiment notes</a>"
    html += "</code>"
    html += "</div>"
    return html
Exemplo n.º 2
0
def getHtmlForImageFilePaths(abfFolder, filePaths):
    html = ""
    for imagePath in filePaths:
        imagePath = abfFolder.analysisFolder+"/"+imagePath
        imageUrl = abfBrowse.getUrl(imagePath)
        html += f"<a href='{imageUrl}'><img src='{imageUrl}' class='analysisImage'></a> "
    return html
Exemplo n.º 3
0
def getNotesForm(pathLocal):

    expNotes = abfBrowse.experimentNotes.ExperimentNotes(pathLocal)
    xDriveFilePath = abfBrowse.getXdrivePath(expNotes.path)
    experimentText = expNotes.getText()
    if not experimentText:
        experimentText = "## Experiment Notes ##\n"
        experimentText += "Goal: \n"
        experimentText += "Animal: \n"
        experimentText += "Internal: \n"
        experimentText += "Bath: \n"
        experimentText += "Drugs: \n"

    url = "/ABFexperiment" + abfBrowse.getUrl(pathLocal)
    url = url.replace("X:/", "/X/")

    html = ""
    html += f"<div style='font-size: 80%; font-family: consolas, monospace;'>{xDriveFilePath}</div>"
    html += f"<div style='color: #ccc; font-size: 80%;'><i>{expNotes.getEditDateString()}</i></div>"

    # add warnings here

    html += f"<form action='{url}' method='post' style='margin: 0px;'>"
    html += f"<textarea name='experimentText' class='editBox' style='margin-top: 20px;'>{experimentText}</textarea>"
    html += f"<input class='submitButton' type='submit' value='SAVE' style='margin-top: 20px;'>"
    html += f"</form>"

    return html
Exemplo n.º 4
0
def menuParentCellList(abfFolder):
    urlExperiment = "/ABFexperiment" + abfBrowse.getUrl(abfFolder.path)
    urlOrigin = "/ABForigin" + abfBrowse.getUrl(abfFolder.path)
    html = ""
    html += "<div class='menuEphysProject'>"
    html += "<span class='title'>Electrophysiology Project</span><br>"
    html += f"<div><a href='{urlExperiment}' target='content'>Experiment Notes</a></div>"
    html += f"<div><a href='{urlOrigin}' target='content'>Origin Commands</a></div>"
    html += "</div>"

    cells = abfBrowse.CellsFile(abfFolder.path)
    unknownCells = cells.getUnknownCells(abfFolder.abfList.family.keys())
    activeCellMarkerId = 0

    if len(cells.cellNotes):
        html += "<div class='menuCellList'>"
        for line in cells.cellNotes:
            if isinstance(line, str):
                html += f"<br><div class='title'><b>{line}</b></div>"
            elif isinstance(line, abfBrowse.CellNote):
                abfUrl = abfBrowse.getUrl(abfFolder.path + "/" + line.abfID +
                                          ".abf")
                activeCellMarkerId += 1
                abfLink = f"<a href='/ABFparent{abfUrl}' target='content' onclick='setClicked({activeCellMarkerId})' style='background-color: {line.color};'>{line.abfID}</a>"
                if line.abfID in abfFolder.abfList.family:
                    abfCount = f"({len(abfFolder.abfList.family[line.abfID])})"
                else:
                    abfCount = f"(?)"
                abfComment = f"<span class='menuCellComments'>{line.comment}</span>"
                activeCellMarker = f"<span class='abftick' style='visibility: hidden' id='{activeCellMarkerId}'>»</span>"
                html += f"<div>{activeCellMarker}{abfLink} {abfCount} {abfComment}</div>"
        html += "</div>"

    if len(unknownCells):
        html += "<div class='menuCellList'>"
        html += f"<div class='title'><b>Unlabeled:</b></div>"
        for unknownCellID in unknownCells:
            abfUrl = abfBrowse.getUrl(abfFolder.path + "/" + unknownCellID +
                                      ".abf")
            abfCount = len(abfFolder.abfList.family[unknownCellID])
            activeCellMarkerId += 1
            activeCellMarker = f"<span class='abftick' style='visibility: hidden' id='{activeCellMarkerId}'>»</span>"
            html += f"<div>{activeCellMarker}<a href='/ABFparent{abfUrl}' target='content' onclick='setClicked({activeCellMarkerId})'>{unknownCellID}</a> ({abfCount})</div>"
        html += "</div>"

    return html
Exemplo n.º 5
0
def pageParentNotes(abfFolder, parentNote):
    assert isinstance(abfFolder, abfBrowse.AbfFolder)
    assert isinstance(parentNote, abfBrowse.cellsFile.CellNote)

    abfPath = os.path.join(abfFolder.path, parentNote.abfID) + ".abf"
    url = "/ABFparent" + abfBrowse.getUrl(abfPath)
    urlMenu = "/ABFmenu" + abfBrowse.getUrl(os.path.dirname(abfPath))

    html = ""
    html += f"<form action='{url}' method='post' style='margin: 0px;'>"
    html += f"<input type='hidden' name='abfFolderPath' value='{abfFolder.path}' />"
    html += f"<input type='hidden' name='abfID' value='{parentNote.abfID}' />"
    html += f"<div style='background-color: #DDD; padding: .5em;'>"
    html += getColorBoxesHTML(parentNote.colorCode)
    html += f"<input style='margin-top: 8px;' type='text' size='35' name='comment' value='{parentNote.comment}'> "
    html += f"<input type='submit' value='Submit'> "
    html += f"<a href='{urlMenu}' target='menu'>refresh menu</a>"
    html += "</div>"
    html += "</form>"
    return html
Exemplo n.º 6
0
def menuFolderContents(abfFolder):

    subFolders = glob.glob(abfFolder.path + "/*/")

    fileNames = abfFolder.abfList.fileNamesOther
    fileNames = [x for x in fileNames if not x.lower().endswith(".tif")]
    fileNames = [x for x in fileNames if not x.lower().endswith(".ignored")]
    fileNames = [x for x in fileNames if "." in x]

    html = ""
    if len(subFolders) or len(fileNames):
        html += "<div class='menuFileBrowser'>"
        html += "<div class='title'>Folder Contents:</div>"
        for subFolder in subFolders:
            subFolder = os.path.basename(subFolder[:-1])
            # TODO: make this top level
            url = abfBrowse.getUrl(os.path.join(abfFolder.path, subFolder))
            html += f"<div><a href='/ABFviewer{url}' target='_top'>{subFolder}/</a></div>"
        for fileName in fileNames:
            url = abfBrowse.getUrl(abfFolder.path + "/" + fileName)
            html += f"<div><a href='{url}' target='content'>{fileName}</a></div>"
        html += "</div>"

    return html
Exemplo n.º 7
0
def menuDirectoryNavigator(currentPath):
    """
    Given a filesystem path, return HTML links where each subfolder
    is on a new line and nested by depth.
    """

    allPaths = [currentPath]
    baseNames = [os.path.basename(currentPath)]
    while baseNames[-1]:
        shorterPath = os.path.dirname(allPaths[-1])
        allPaths.append(shorterPath)
        baseNames.append(os.path.basename(shorterPath))
    allPaths.reverse()
    baseNames.reverse()

    # remove root drive letter
    baseNames.pop(0)
    allPaths.pop(0)

    # remove folder (server only)
    if baseNames[0] == "X_Drive":
        baseNames.pop(0)
        allPaths.pop(0)

    html = "<div class='menuFileBrowser'>"
    html += "<span class='title'>Project Browser</span><br>"
    html += "<div style='color: blue;'>X:</div>"
    for i in range(len(allPaths)):
        padding = "&nbsp;" * (i + 1)
        url = abfBrowse.getUrl(allPaths[i])
        html += f"<div>{padding}<a href='/ABFviewer{url}' target='_top'>{baseNames[i]}</a></div>"
    html += "<hr>"
    html += abfBrowse.htmlTools.copyButton(
        "copy path", abfBrowse.getXdrivePath(allPaths[i]))
    html += abfBrowse.htmlTools.refreshButton()
    html += "</div>"

    return html