Ejemplo n.º 1
0
def _getFilenameSuggestion(dirname='', seriesname=SERIES_PATTERN):
    from PYME.IO.FileUtils import nameUtils
    from PYME.IO import clusterIO
    import os

    if dirname == '':
        dirname = nameUtils.genClusterDataFilepath()
    else:
        dirname = dirname.split(nameUtils.getUsername())[-1]

        dir_parts = dirname.split(os.path.sep)
        if len(dirname) < 1 or len(dir_parts) > 3:
            #path is either too complex, or too easy - revert to default
            dirname = nameUtils.genClusterDataFilepath()
        else:
            dirname = nameUtils.getUsername() + '/'.join(dir_parts)

    #dirname = defDir % nameUtils.dateDict
    seriesStub = dirname + '/' + seriesname % nameUtils.dateDict

    seriesCounter = 0
    seriesName = seriesStub % {'counter': nameUtils.numToAlpha(seriesCounter)}

    #try to find the next available serie name
    while clusterIO.exists(seriesName + '/'):
        seriesCounter += 1

        if '%(counter)' in seriesName:
            seriesName = seriesStub % {
                'counter': nameUtils.numToAlpha(seriesCounter)
            }
        else:
            seriesName = seriesStub + '_' + nameUtils.numToAlpha(seriesCounter)

    return seriesName
Ejemplo n.º 2
0
    def PopulateMetadata(self, mdh, acquiring=True):
        global lastCreator, lastSlideRef
        currentSlide[0] = self.slide

        creator = self.slide['creator']
        slideRef = self.slide['reference']
        sampleNotes = self.slide['notes']
        #notes = self.tNotes.GetValue()
        #sampleNotes = self.tSlideNotes.GetValue()

        if not slideRef == lastSlideRef or not creator == lastCreator:
            lastCreator = creator
            lastSlideRef = slideRef

            for f in WantSlideChangeNotification:
                f()

        #if len(creator) == 0:
        #    creator = '<none>'

        #if len(slideRef) == 0:
        #    slideRef = '<none>'

        #if len(notes) == 0:
        #    notes = '<none>'

        #if len(sampleNotes) == 0:
        #    sampleNotes = '<none>'
        
        mdh.setEntry('Sample.Creator', creator)
        mdh.setEntry('Sample.SlideRef', slideRef)
        if len(sampleNotes) > 0:
            mdh.setEntry('Sample.Notes', sampleNotes)
        #mdh.setEntry('AcquisitionNotes', notes)
        

#        labels = []
#        for i in range(self.gLabelling.GetNumberRows()):
#            labels.append((self.gLabelling.GetCellValue(i, 0),self.gLabelling.GetCellValue(i, 1)))

        #mdh.setEntry('Sample.Labelling', [(l.structure, l.dye.shortName) for l in self.slide.labelling.all()])
        mdh.setEntry('Sample.Labelling', self.slide['labels'])
        mdh['Sample.SlideID'] = self.slide['slideID']
        mdh['Sample.Specimen'] = self.slide['sample']

        mdh.setEntry('AcquiringUser', nameUtils.getUsername())

        #slide = models.Slide.Get(creator, slideRef)

#        if not self.slideExists:
#            for struct, label in self.labels:
#                l = models.Labelling(slideID=slide, structure=struct, label=label)
#                l.notes = sampleNotes
#                l.save()


        if acquiring:
            notes = self.tNotes.GetValue()
            mdh.setEntry('Notes', notes)
Ejemplo n.º 3
0
import wx.lib.mixins.listctrl as listmix
import sys
import os

import requests
import logging
logging.getLogger("requests").setLevel(logging.WARNING)
logging.getLogger("urllib3").setLevel(logging.WARNING)

from PYME.IO.FileUtils import nameUtils
from PYME.contrib import TextCtrlAutoComplete

#from PYME.SampleDB2 import populate #just to setup the Django environment
#from PYME.SampleDB2.samples import models

lastCreator = nameUtils.getUsername()
lastSlideRef = ''

currentSlide = [None]

WantSlideChangeNotification = []

from PYME.IO import MetaDataHandler
from PYME.IO.MetaDataHandler import NestedClassMDHandler

slideMD = NestedClassMDHandler()

if 'PYME_DATABASE_HOST' in os.environ.keys():
    dbhost = os.environ['PYME_DATABASE_HOST']
else:
    dbhost = 'dbsrv1'
def createImage(mdh, slide, comments=''):
    im = models.Image.GetOrCreate(mdh.getEntry('imageID'),
                                  nameUtils.getUsername(), slide,
                                  mdh.getEntry('StartTime'))
    im.comments = comments
    im.save()