def newImageVersion(self, oldimagedata, newimagedata, correct):
        ## store EMData to DB to prevent referencing errors
        self.publish(newimagedata["scope"], database=True)
        self.publish(newimagedata["camera"], database=True)

        ## convert CameraImageData to AcquisitionImageData
        newimagedata = leginondata.AcquisitionImageData(initializer=newimagedata)
        ## then add stuff from old imagedata
        newimagedata["preset"] = oldimagedata["preset"]
        newimagedata["label"] = oldimagedata["label"]
        newimagedata["target"] = oldimagedata["target"]
        newimagedata["list"] = oldimagedata["list"]
        newimagedata["emtarget"] = oldimagedata["emtarget"]
        newimagedata["version"] = oldimagedata["version"] + 1
        dim = newimagedata["camera"]["dimension"]
        newimagedata["pixels"] = dim["x"] * dim["y"]
        newimagedata["pixeltype"] = str(newimagedata["image"].dtype)
        target = newimagedata["target"]
        if target is not None and "grid" in target and target["grid"] is not None:
            newimagedata["grid"] = target["grid"]

            ## set the 'filename' value
        if newimagedata["label"] == "RCT":
            rctacquisition.setImageFilename(newimagedata)
        else:
            acquisition.setImageFilename(newimagedata)

        newimagedata.attachPixelSize()

        self.logger.info("Publishing new version of image...")
        self.publish(newimagedata, database=True, dbforce=True)
        return newimagedata
Esempio n. 2
0
	def newImageVersion(self, oldimagedata, newimagedata, correct):
		## store EMData to DB to prevent referencing errors
		self.publish(newimagedata['scope'], database=True)
		self.publish(newimagedata['camera'], database=True)

		## convert CameraImageData to AcquisitionImageData
		newimagedata = leginondata.AcquisitionImageData(initializer=newimagedata)
		## then add stuff from old imagedata
		newimagedata['preset'] = oldimagedata['preset']
		newimagedata['label'] = oldimagedata['label']
		newimagedata['target'] = oldimagedata['target']
		newimagedata['list'] = oldimagedata['list']
		newimagedata['emtarget'] = oldimagedata['emtarget']
		newimagedata['version'] = oldimagedata['version'] + 1
		dim = newimagedata['camera']['dimension']
		newimagedata['pixels'] = dim['x'] * dim['y']
		newimagedata['pixeltype'] = str(newimagedata['image'].dtype)
		target = newimagedata['target']
		if target is not None and 'grid' in target and target['grid'] is not None:
			newimagedata['grid'] = target['grid']

		## set the 'filename' value
		if newimagedata['label'] == 'RCT':
			rctacquisition.setImageFilename(newimagedata)
		else:
			acquisition.setImageFilename(newimagedata)

		newimagedata.attachPixelSize()

		self.logger.info('Publishing new version of image...')
		self.publish(newimagedata, database=True, dbforce=True)
		return newimagedata
Esempio n. 3
0
def setImageFilename(imagedata, tiltnumber=None):
    acquisition.setImageFilename(imagedata)
    if tiltnumber is None:
        tiltnumber = imagedata['tiltnumber']
    if tiltnumber is not None:
        imagedata['filename'] = imagedata['filename'] + '_%02d' % (
            tiltnumber, )
        def newImageVersion(self, oldimagedata, newimagedata, correct):
                ## store EMData to DB to prevent referencing errors
                self.publish(newimagedata['scope'], database=True)
                self.publish(newimagedata['camera'], database=True)

                ## convert CameraImageData to AcquisitionImageData
                newimagedata = leginondata.AcquisitionImageData(initializer=newimagedata)
                ## then add stuff from old imagedata
                newimagedata['preset'] = oldimagedata['preset']
                newimagedata['label'] = oldimagedata['label']
                newimagedata['target'] = oldimagedata['target']
                newimagedata['list'] = oldimagedata['list']
                newimagedata['emtarget'] = oldimagedata['emtarget']
                newimagedata['version'] = oldimagedata['version'] + 1
                dim = newimagedata['camera']['dimension']
                newimagedata['pixels'] = dim['x'] * dim['y']
                newimagedata['pixeltype'] = str(newimagedata['image'].dtype)
                target = newimagedata['target']
                if target is not None and 'grid' in target and target['grid'] is not None:
                        newimagedata['grid'] = target['grid']

                ## set the 'filename' value
                if newimagedata['label'] == 'RCT':
                        rctacquisition.setImageFilename(newimagedata)
                else:
                        acquisition.setImageFilename(newimagedata)

                newimagedata.attachPixelSize()

                self.logger.info('Publishing new version of image...')
                self.publish(newimagedata, database=True, dbforce=True)
                return newimagedata
 def setImageFilename(self, imagedata, spot_x=None, spot_y=None):
     acquisition.setImageFilename(imagedata)
     if spot_x is None or spot_y is None:
         spot_x = imagedata['spot_x']
         spot_y = imagedata['spot_y']
     if spot_x is not None and spot_y is not None:
         imagedata['filename'] = imagedata['filename'] + '_%02d_%02d' % (spot_x, spot_y, )
     else:
         imagedata['filename'] = imagedata['filename'] + '_%02d_%02d' % (self.spotX, self.spotY, )
     self.logger.info('Filename -> %s' % imagedata['filename'])
Esempio n. 6
0
def setImageFilename(imagedata, tiltnumber=None, spot_x=None, spot_y=None):
    acquisition.setImageFilename(imagedata)
    if tiltnumber is None:
        tiltnumber = imagedata['tiltnumber']
    if tiltnumber is not None:
        imagedata['filename'] = imagedata['filename'] + '_%02d' % (tiltnumber,)
    if spot_x is None or spot_y is None:
        spot_x = imagedata['spot_x']
        spot_y = imagedata['spot_y']
        if spot_x is not None and spot_y is not None:
            imagedata['filename'] = imagedata['filename'] + '_%02d_%02d' % (spot_x, spot_y, )
Esempio n. 7
0
	def copyImage(self, oldimage):
		imagedata = leginondata.AcquisitionImageData()
		imagedata.update(oldimage)
		version = self.recentImageVersion(oldimage)
		imagedata['version'] = version + 1
		imagedata['filename'] = None
		imagedata['image'] = oldimage['image']
		## set the 'filename' value
		if imagedata['label'] == 'RCT':
			rctacquisition.setImageFilename(imagedata)
		else:
			acquisition.setImageFilename(imagedata)
		self.logger.info('Publishing new copied image...')
		self.publish(imagedata, database=True)
		return imagedata
 def copyImage(self, oldimage):
         imagedata = leginondata.AcquisitionImageData()
         imagedata.update(oldimage)
         version = self.recentImageVersion(oldimage)
         imagedata['version'] = version + 1
         imagedata['filename'] = None
         imagedata['image'] = oldimage['image']
         ## set the 'filename' value
         if imagedata['label'] == 'RCT':
                 rctacquisition.setImageFilename(imagedata)
         else:
                 acquisition.setImageFilename(imagedata)
         self.logger.info('Publishing new copied image...')
         self.publish(imagedata, database=True)
         return imagedata
Esempio n. 9
0
	def reacquire(self, targetdata):
		oldimage = None
		targetlist = targetdata['list']
		tquery = leginondata.AcquisitionImageTargetData(session=self.session, list=targetlist, number=targetdata['number'], type=targetdata['type'])
		aquery = leginondata.AcquisitionImageData(target=tquery)
		results = aquery.query(readimages=False, results=1)
		if len(results) > 0:
			oldimage = results[0]
		if oldimage is None:
			print "can not find an image that is acquired with this target"
			print targetdata.dbid
			return None
		oldemtarget = oldimage['emtarget']
		movetype = oldemtarget['movetype']
		try:
			emtarget = self.targetToEMTargetData(targetdata,movetype)
		except InvalidStagePosition:
			self.logger.error('Invalid new emtarget')
			return None
		oldpresetdata = oldimage['preset']
		presetname = oldpresetdata['name']
		channel = int(oldimage['correction channel']==0)
		self.presetsclient.toScope(presetname, emtarget, keep_shift=False)
		targetdata = emtarget['target']
		imagedata = self.acquireCorrectedCameraImageData(channel)
		currentpresetdata = self.presetsclient.getCurrentPreset()
		## convert CameraImageData to AcquisitionImageData
		dim = imagedata['camera']['dimension']
		pixels = dim['x'] * dim['y']
		pixeltype = str(imagedata['image'].dtype)
		## Fix me: Not sure what image list should go in here nor naming of the file
		imagedata = leginondata.AcquisitionImageData(initializer=imagedata, preset=currentpresetdata, label=self.name, target=targetdata, list=oldimage['list'], emtarget=emtarget, pixels=pixels, pixeltype=pixeltype,grid=oldimage['grid'])
		version = self.recentImageVersion(oldimage)
		imagedata['version'] = version + 1
		## set the 'filename' value
		if imagedata['label'] == 'RCT':
			rctacquisition.setImageFilename(imagedata)
		else:
			acquisition.setImageFilename(imagedata)
		## store EMData to DB to prevent referencing errors
		self.publish(imagedata['scope'], database=True)
		self.publish(imagedata['camera'], database=True)
		self.logger.info('Publishing new transformed image...')
		self.publish(imagedata, database=True)
		self.setImage(imagedata['image'], 'Image')
		return imagedata
def setImageFilename(imagedata, tiltnumber=None):
		acquisition.setImageFilename(imagedata)
		if tiltnumber is None:
			tiltnumber = imagedata['tiltnumber']
		if tiltnumber is not None:
			imagedata['filename'] = imagedata['filename'] + '_%02d' % (tiltnumber,)
                currentpresetdata = self.presetsclient.getCurrentPreset()
                ## convert CameraImageData to AcquisitionImageData
                dim = imagedata['camera']['dimension']
                pixels = dim['x'] * dim['y']
                pixeltype = str(imagedata['image'].dtype)
                ## Fix me: Not sure what image list should go in here nor naming of the file
                # This does not include tilt series nor tilt number.  If included,
                # rct filenaming becomes corrupted
                imagedata = leginondata.AcquisitionImageData(initializer=imagedata, preset=currentpresetdata, label=self.name, target=targetdata, list=oldimage['list'], emtarget=emtarget, pixels=pixels, pixeltype=pixeltype,grid=oldimage['grid'],mover=oldimage['mover'])
                version = self.recentImageVersion(oldimage)
                imagedata['version'] = version + 1
                ## set the 'filename' value
                if imagedata['label'] == 'RCT':
                        rctacquisition.setImageFilename(imagedata)
                else:
                        acquisition.setImageFilename(imagedata)
                ## store EMData to DB to prevent referencing errors
                self.publish(imagedata['scope'], database=True)
                self.publish(imagedata['camera'], database=True)
                self.logger.info('Publishing new transformed image...')
                self.publish(imagedata, database=True)
                self.setImage(imagedata['image'], 'Image')
                return imagedata

        def _moveToLastFocusedStageZ(self):
                '''
                Set stage z to the height of an image acquired by the last focusing.
                This should only be called from inside TrasnformManage
                '''
                self.moveToLastFocusedStageZ(self.target_to_transform)