Esempio n. 1
0
	def readImage(self, filename):
		imagedata = None
		if filename:
			imagedata = self.getImageFromDB(filename)
		if imagedata is None:
			if filename == '':
				if self.name in ['Hole Targeting','Subsquare Targeting']:
					filename = os.path.join(version.getInstalledLocation(),'sq_example.jpg')
				elif self.name in ['Square Targeting']:
					filename = os.path.join(version.getInstalledLocation(),'gr_example.jpg')
				else:
					filename = os.path.join(version.getInstalledLocation(),'hl_example.jpg')
			try:
				orig = mrc.read(filename)
			except Exception, e:
				try:
					orig = numpil.read(filename)
				except:
					self.logger.exception('Read image failed: %s' % e[-1])
					return
			self.currentimagedata = {'image':orig} 
 def readImage(self, filename):
         imagedata = None
         if filename:
                 imagedata = self.getImageFromDB(filename)
         if imagedata is None:
                 if filename == '':
                         if self.name in ['Hole Targeting','Subsquare Targeting']:
                                 filename = os.path.join(version.getInstalledLocation(),'sq_example.jpg')
                         elif self.name in ['Square Targeting']:
                                 filename = os.path.join(version.getInstalledLocation(),'gr_example.jpg')
                         else:
                                 filename = os.path.join(version.getInstalledLocation(),'hl_example.jpg')
                 try:
                         orig = mrc.read(filename)
                 except Exception, e:
                         try:
                                 orig = numpil.read(filename)
                         except:
                                 self.logger.exception('Read image failed: %s' % e[-1])
                                 return
                 self.currentimagedata = {'image':orig} 
		if h['mz'] == 1:
			if nframes > 1:
				# mrc2014 image stack
				frame_str = raw_input('This is an image stack of %d frames.\n Enter 0 to %d to select a frame to load: ' % (nframes,nframes-1))
				frame = int(frame_str)
		else:
			if nframes > 1:
				slice_str = raw_input('This is a stack of %d volume.\n Enter 0 to %d to select a slice to load: ' % (nframes,h['nz']-1))
			else:
				slice_str = raw_input('This is a volume.\n Enter 0 to %d to select a slice to load: ' % (h['nz']-1))
			frame = int(slice_str)
		image = mrc.read(filename,frame)
		array = image.astype(numpy.float32)

	elif filename[-4:] == '.tif':
		# This is only for RawImage tiff files taken from DirectElectron DE camera
		from pyami import tifffile
		tif = tifffile.TIFFfile(filename)
		a = tif.asarray()
		a = numpy.asarray(a,dtype=numpy.float32)
		# DE RawImage tiff files is mirrored horizontally from Leginon
		array = a[:,::-1]
	else:
		from pyami import numpil
		array = numpil.read(filename)
	#start gui
	app = MyApp(0,box)
	app.panel.setImage(array)
	app.MainLoop()

                    % (nframes, nframes - 1))
                frame = int(frame_str)
        else:
            if nframes > 1:
                slice_str = raw_input(
                    'This is a stack of %d volume.\n Enter 0 to %d to select a slice to load: '
                    % (nframes, h['nz'] - 1))
            else:
                slice_str = raw_input(
                    'This is a volume.\n Enter 0 to %d to select a slice to load: '
                    % (h['nz'] - 1))
            frame = int(slice_str)
        image = mrc.read(filename, frame)
        array = image.astype(numpy.float32)

    elif filename[-4:] == '.tif':
        # This is only for RawImage tiff files taken from DirectElectron DE camera
        from pyami import tifffile
        tif = tifffile.TIFFfile(filename)
        a = tif.asarray()
        a = numpy.asarray(a, dtype=numpy.float32)
        # DE RawImage tiff files is mirrored horizontally from Leginon
        array = a[:, ::-1]
    else:
        from pyami import numpil
        array = numpil.read(filename)
    #start gui
    app = MyApp(0, box)
    app.panel.setImage(array)
    app.MainLoop()
                        self.panel.setTargets('Target Practice', [])
                        # integration half box size
                        self.panel.box = box

                        self.sizer.Add(self.panel, 1, wx.EXPAND|wx.ALL)
                        frame.SetSizerAndFit(self.sizer)
                        self.SetTopWindow(frame)
                        frame.Show(True)
                        return True

        app = MyApp(0,box)
        if filename is None:
                app.panel.setImage(None)
        elif filename[-4:] == '.mrc':
                image = mrc.read(filename)
                app.panel.setImage(image.astype(numpy.float32))
        elif filename[-4:] == '.tif':
                # This is only for RawImage tiff files taken from DirectElectron DE camera
                from pyami import tifffile
                tif = tifffile.TIFFfile(filename)
                a = tif.asarray()
                a = numpy.asarray(a,dtype=numpy.float32)
                # DE RawImage tiff files is mirrored horizontally from Leginon
                a = a[:,::-1]
                app.panel.setImage(a)
        else:
                from pyami import numpil
                app.panel.setImage(numpil.read(filename))
        app.MainLoop()

Esempio n. 6
0
                                     target=True)
            self.panel.setTargets('Target Practice', [])
            # integration half box size
            self.panel.box = box

            self.sizer.Add(self.panel, 1, wx.EXPAND | wx.ALL)
            frame.SetSizerAndFit(self.sizer)
            self.SetTopWindow(frame)
            frame.Show(True)
            return True

    app = MyApp(0, box)
    if filename is None:
        app.panel.setImage(None)
    elif filename[-4:] == '.mrc':
        image = mrc.read(filename)
        app.panel.setImage(image.astype(numpy.float32))
    elif filename[-4:] == '.tif':
        # This is only for RawImage tiff files taken from DirectElectron DE camera
        from pyami import tifffile
        tif = tifffile.TIFFfile(filename)
        a = tif.asarray()
        a = numpy.asarray(a, dtype=numpy.float32)
        # DE RawImage tiff files is mirrored horizontally from Leginon
        a = a[:, ::-1]
        app.panel.setImage(a)
    else:
        from pyami import numpil
        app.panel.setImage(numpil.read(filename))
    app.MainLoop()