Example #1
0
    def loadImage(self, filename, frame_num=0):
        success = False

        # Deals with a file system race condition?
        # Or is it a acquisition software problem?
        time.sleep(0.05)
        tries = 0
        while (not success) and (tries < 4):
            try:
                movie = datareader.reader(filename)
                frame = movie.loadAFrame(frame_num)
                movie.closeFilePtr()
                success = True

            except IOError:
                print "Failed to load:" + filename + " frame " + str(frame_num)
                frame = None
                time.sleep(0.05)
            tries += 1

        if type(frame) == type(numpy.array([])):

            #
            # If we are working off-line we might need to load the mosaic
            # settings first.
            #
            if not self.got_settings:
                coord.Point.pixels_to_um = movie.xml.get("mosaic.pixels_to_um")
                i = 1
                while movie.xml.has("mosaic.obj" + str(i)):
                    obj_data = movie.xml.get("mosaic.obj" + str(i))
                    self.newObjectiveData.emit(obj_data.split(","))
                    i += 1

            if movie.xml.get("mosaic.flip_horizontal"):
                frame = numpy.fliplr(frame)
            if movie.xml.get("mosaic.flip_vertical"):
                frame = numpy.flipud(frame)
            if movie.xml.get("mosaic.transpose"):
                frame = numpy.transpose(frame)
            image = Image(frame, movie.filmSize(), movie.filmParameters())

            self.captureComplete.emit(image)

        else:
            self.captureComplete.emit(False)
Example #2
0
    def loadImage(self, filename, frame_num = 0):
        success = False

        # Deals with a file system race condition?
        # Or is it a acquisition software problem?
        time.sleep(0.05)
        tries = 0
        while (not success) and (tries < 4):
            try:
                movie = datareader.reader(filename)
                frame = movie.loadAFrame(frame_num)
                movie.closeFilePtr()
                success = True

            except IOError:
                print "Failed to load:" + filename + " frame " + str(frame_num)
                frame = None
                time.sleep(0.05)
            tries += 1

        if type(frame) == type(numpy.array([])):

            #
            # Check if the movie contains all the XML or if the XML is
            # just faked, for example by generating it from a .inf file.
            #
            if movie.xml.get("faked_xml", False):
                
                # Prompt user for settings for the first film.
                if not self.fake_got_settings:
                    settings = mosaicDialog.execMosaicDialog()
                    coord.Point.pixels_to_um = settings[0]
                    self.newObjectiveData.emit(settings[4:])
                    self.fake_got_settings = True
                    self.fake_objective += 1

                obj_name = "obj" + str(self.fake_objective)
                settings = mosaicDialog.getMosaicSettings()
                
                movie.xml.set("mosaic." + obj_name, ",".join(map(str, settings[4:])))
                movie.xml.set("mosaic.objective", obj_name)
                movie.xml.set("mosaic.flip_horizontal", settings[0])
                movie.xml.set("mosaic.flip_vertical", settings[1])
                movie.xml.set("mosaic.transpose", settings[2])

            else:
                
                #
                # If we are working off-line we might need to load the mosaic
                # settings first.
                #
                if not self.got_settings:
                    coord.Point.pixels_to_um = movie.xml.get("mosaic.pixels_to_um")
                    i = 1
                    while movie.xml.has("mosaic.obj" + str(i)):
                        obj_data = movie.xml.get("mosaic.obj" + str(i))
                        self.newObjectiveData.emit(obj_data.split(","))
                        i += 1
                        
            if movie.xml.get("mosaic.flip_horizontal", False):
                frame = numpy.fliplr(frame)
            if movie.xml.get("mosaic.flip_vertical", False):
                frame = numpy.flipud(frame)
            if movie.xml.get("mosaic.transpose", False):
                frame = numpy.transpose(frame)
            image = Image(frame,
                          movie.filmSize(),
                          movie.filmParameters())

            self.captureComplete.emit(image)

        else:
            self.captureComplete.emit(False)
Example #3
0
    def loadImage(self, filename, frame_num=0):
        success = False

        # Deals with a file system race condition?
        # Or is it a acquisition software problem?
        time.sleep(0.05)
        tries = 0
        while (not success) and (tries < 4):
            try:
                movie = datareader.reader(filename)
                frame = movie.loadAFrame(frame_num)
                movie.closeFilePtr()
                success = True

            except IOError:
                print "Failed to load:" + filename + " frame " + str(frame_num)
                frame = None
                time.sleep(0.05)
            tries += 1

        if type(frame) == type(numpy.array([])):

            #
            # Check if the movie contains all the XML or if the XML is
            # just faked, for example by generating it from a .inf file.
            #
            if movie.xml.get("faked_xml", False):

                # Prompt user for settings for the first film.
                if not self.fake_got_settings:
                    settings = mosaicDialog.execMosaicDialog()
                    self.newObjectiveData.emit(settings[4:])
                    self.fake_got_settings = True
                    self.fake_objective += 1

                obj_name = "obj" + str(self.fake_objective)
                settings = mosaicDialog.getMosaicSettings()

                movie.xml.set("mosaic." + obj_name,
                              ",".join(map(str, settings[4:])))
                movie.xml.set("mosaic.objective", obj_name)
                movie.xml.set("mosaic.flip_horizontal", settings[0])
                movie.xml.set("mosaic.flip_vertical", settings[1])
                movie.xml.set("mosaic.transpose", settings[2])

            else:

                #
                # If we are working off-line we might need to load the mosaic
                # settings first.
                #
                if not self.got_settings:
                    i = 1
                    while movie.xml.has("mosaic.obj" + str(i)):
                        obj_data = movie.xml.get("mosaic.obj" + str(i))
                        self.newObjectiveData.emit(obj_data.split(","))
                        i += 1

            if movie.xml.get("mosaic.flip_horizontal", False):
                frame = numpy.fliplr(frame)
            if movie.xml.get("mosaic.flip_vertical", False):
                frame = numpy.flipud(frame)
            if movie.xml.get("mosaic.transpose", False):
                frame = numpy.transpose(frame)
            image = Image(frame, movie.filmSize(), movie.filmParameters())

            self.captureComplete.emit(image)

        else:
            self.captureComplete.emit(False)