Beispiel #1
0
        def _export():
            self.applet.busy = True
            self.applet.appletStateUpdateRequested.emit()

            t_from = None
            # determine from_time (it could has been changed in the GUI meanwhile)            
            for t_from, label2color_at in enumerate(self.mainOperator.label2color):
                if len(label2color_at) == 0:                
                    continue
                else:
                    break
            
            if t_from is None:
                self._criticalMessage("There is nothing to export.")
                return
            
            t_from = int(t_from)

            logger.info( "Saving first label image..." )
            key = []
            for idx, flag in enumerate(axisTagsToString(self.mainOperator.LabelImage.meta.axistags)):
                if flag is 't':
                    key.append(slice(t_from,t_from+1))
                elif flag is 'c':
                    key.append(slice(0,1))                
                else:
                    key.append(slice(0,self.mainOperator.LabelImage.meta.shape[idx]))                        
            
        
            roi = SubRegion(self.mainOperator.LabelImage, key)
            labelImage = self.mainOperator.LabelImage.get(roi).wait()
            labelImage = labelImage[0,...,0]
            
            try:
                # write_events([], str(directory), t_from, labelImage)
                
                events = self.mainOperator.EventsVector.value
                logger.info( "Saving events..." )
                logger.info( "Length of events " + str(len(events)) )
                
                num_files = float(len(events))

                for i in sorted(events.keys()):
                    events_at = events[i]
                    i = int(i)
                    t = t_from + i            
                    key[0] = slice(t,t+1)
                    roi = SubRegion(self.mainOperator.LabelImage, key)
                    labelImage = self.mainOperator.LabelImage.get(roi).wait()
                    labelImage = labelImage[0,...,0]
                    if self.withMergers:                
                        write_events(events_at, str(directory), t, labelImage, self.mainOperator.mergers)
                    else:
                        write_events(events_at, str(directory), t, labelImage)
                    _handle_progress(i/num_files * 100)
            except IOError as e:                    
                self._criticalMessage("Cannot export the tracking results. Maybe these files already exist. "\
                                      "Please delete them or choose a different directory.")
                return
Beispiel #2
0
        def _export():
            self.applet.busy = True
            self.applet.appletStateUpdateRequested.emit()

            if hasattr(self.mainOperator, "RelabeledImage"):
                labelImageSlot = self.mainOperator.RelabeledImage
            else:
                labelImageSlot = self.mainOperator.LabelImage

            logger.info("Saving first label image...")
            key = []
            for idx, flag in enumerate(
                    axisTagsToString(labelImageSlot.meta.axistags)):
                if flag is 't':
                    key.append(slice(0, labelImageSlot.meta.shape[idx])
                               )  #slice(t_from,t_from+1))
                elif flag is 'c':
                    key.append(slice(0, 1))
                else:
                    key.append(slice(0, labelImageSlot.meta.shape[idx]))

            try:
                events = self.mainOperator.EventsVector.value
                logger.info("Saving events...")
                logger.info("Length of events " + str(len(events)))

                num_files = float(len(events))

                for i in sorted(events.keys()):
                    events_at = events[i]
                    i = int(i)
                    t = i
                    key[0] = slice(t, t + 1)
                    roi = SubRegion(labelImageSlot, key)
                    labelImage = labelImageSlot.get(roi).wait()
                    labelImage = labelImage[0, ..., 0]
                    write_events(events_at, str(directory), t, labelImage)
                    _handle_progress(i / num_files * 100)
            except IOError as e:
                self._criticalMessage("Cannot export the tracking results. Maybe these files already exist. "\
                                      "Please delete them or choose a different directory.")
                return
        def _export():
            self.applet.busy = True
            self.applet.appletStateUpdateRequested.emit()

            if hasattr(self.mainOperator,"RelabeledImage"):
                labelImageSlot = self.mainOperator.RelabeledImage
            else:
                labelImageSlot = self.mainOperator.LabelImage

            logger.info( "Saving first label image..." )
            key = []
            for idx, flag in enumerate(axisTagsToString(labelImageSlot.meta.axistags)):
                if flag is 't':
                    key.append(slice(0,labelImageSlot.meta.shape[idx]))#slice(t_from,t_from+1))
                elif flag is 'c':
                    key.append(slice(0,1))
                else:
                    key.append(slice(0,labelImageSlot.meta.shape[idx]))

            try:
                events = self.mainOperator.EventsVector.value
                logger.info( "Saving events..." )
                logger.info( "Length of events " + str(len(events)) )

                num_files = float(len(events))

                for i in sorted(events.keys()):
                    events_at = events[i]
                    i = int(i)
                    t = i
                    key[0] = slice(t,t+1)
                    roi = SubRegion(labelImageSlot, key)
                    labelImage = labelImageSlot.get(roi).wait()
                    labelImage = labelImage[0,...,0]
                    write_events(events_at, str(directory), t, labelImage)
                    _handle_progress(i/num_files * 100)
            except IOError as e:
                self._criticalMessage("Cannot export the tracking results. Maybe these files already exist. "\
                                      "Please delete them or choose a different directory.")
                return
        def _export():
            t_from = None
            # determine from_time (it could has been changed in the GUI meanwhile)
            for t_from, label2color_at in enumerate(
                    self.mainOperator.label2color):
                if len(label2color_at) == 0:
                    continue
                else:
                    break

            if t_from == None:
                return

            print "Saving first label image..."
            key = []
            for idx, flag in enumerate(
                    axisTagsToString(
                        self.mainOperator.LabelImage.meta.axistags)):
                if flag is 't':
                    key.append(slice(t_from, t_from + 1))
                elif flag is 'c':
                    key.append(slice(0, 1))
                else:
                    key.append(
                        slice(0, self.mainOperator.LabelImage.meta.shape[idx]))

            roi = SubRegion(self.mainOperator.LabelImage, key)
            labelImage = self.mainOperator.LabelImage.get(roi).wait()
            labelImage = labelImage[0, ..., 0]

            try:
                write_events([], str(directory), t_from, labelImage)

                events = self.mainOperator.events
                print "Saving events..."
                print "Length of events " + str(len(events))

                num_files = float(len(events))
                for i, events_at in enumerate(events):
                    t = t_from + i
                    key[0] = slice(t + 1, t + 2)
                    roi = SubRegion(self.mainOperator.LabelImage, key)
                    labelImage = self.mainOperator.LabelImage.get(roi).wait()
                    labelImage = labelImage[0, ..., 0]
                    if self.withMergers:
                        write_events(events_at, str(directory), t + 1,
                                     labelImage, self.mainOperator.mergers)
                    else:
                        write_events(events_at, str(directory), t + 1,
                                     labelImage)
                    _handle_progress(i / num_files * 100)
            except IOError as e:
                self._criticalMessage("Cannot export the tracking results. Maybe these files already exist. "\
                                      "Please delete them or choose a different directory.")
                return
 def _export():
     t_from = None
     # determine from_time (it could has been changed in the GUI meanwhile)            
     for t_from, label2color_at in enumerate(self.mainOperator.label2color):
         if len(label2color_at) == 0:                
             continue
         else:
             break
     
     if t_from == None:
         return
     
     print "Saving first label image..."
     key = []
     for idx, flag in enumerate(axisTagsToString(self.mainOperator.LabelImage.meta.axistags)):
         if flag is 't':
             key.append(slice(t_from,t_from+1))
         elif flag is 'c':
             key.append(slice(0,1))                
         else:
             key.append(slice(0,self.mainOperator.LabelImage.meta.shape[idx]))                        
     
     roi = SubRegion(self.mainOperator.LabelImage, key)
     labelImage = self.mainOperator.LabelImage.get(roi).wait()
     labelImage = labelImage[0,...,0]
     
     try:
         write_events([], str(directory), t_from, labelImage)
         
         events = self.mainOperator.events
         print "Saving events..."
         print "Length of events " + str(len(events))
         
         num_files = float(len(events))
         for i, events_at in enumerate(events):
             t = t_from + i            
             key[0] = slice(t+1,t+2)
             roi = SubRegion(self.mainOperator.LabelImage, key)
             labelImage = self.mainOperator.LabelImage.get(roi).wait()
             labelImage = labelImage[0,...,0]
             if self.withMergers:                
                 write_events(events_at, str(directory), t+1, labelImage, self.mainOperator.mergers)
             else:
                 write_events(events_at, str(directory), t+1, labelImage)
             _handle_progress(i/num_files * 100)
     except IOError as e:                    
         self._criticalMessage("Cannot export the tracking results. Maybe these files already exist. "\
                               "Please delete them or choose a different directory.")
         return
Beispiel #6
0
    def _onExportButtonPressed(self):
        options = QFileDialog.Options()
        if ilastik_config.getboolean("ilastik", "debug"):
            options |= QFileDialog.DontUseNativeDialog

        directory = QFileDialog.getExistingDirectory(self, 'Select Directory',os.getenv('HOME'), options=options)      
        
        if directory is None:
            print "cancelled."
            return
        
        # determine from_time (it could has been changed in the GUI meanwhile)
        for t_from, label2color_at in enumerate(self.mainOperator.label2color):
            if len(label2color_at) == 0:                
                continue
            else:
                break
            
        print "Saving first label image..."
        key = []
        for idx, flag in enumerate(axisTagsToString(self.mainOperator.LabelImage.meta.axistags)):
            if flag is 't':
                key.append(slice(t_from,t_from+1))
            elif flag is 'c':
                key.append(slice(0,1))                
            else:
                key.append(slice(0,self.mainOperator.LabelImage.meta.shape[idx]))                        
        
        roi = SubRegion(self.mainOperator.LabelImage, key)
        labelImage = self.mainOperator.LabelImage.get(roi).wait()
        labelImage = labelImage[0,...,0]
        
        write_events([], str(directory), t_from, labelImage)
        
        events = self.mainOperator.events
        print "Saving events..."
        print "Length of events " + str(len(events))
        
        for i, events_at in enumerate(events):
            t = t_from + i            
            key[0] = slice(t+1,t+2)
            roi = SubRegion(self.mainOperator.LabelImage, key)
            labelImage = self.mainOperator.LabelImage.get(roi).wait()
            labelImage = labelImage[0,...,0]
            if self.withMergers:                
                write_events(events_at, str(directory), t+1, labelImage, self.mainOperator.mergers)
            else:
                write_events(events_at, str(directory), t+1, labelImage)
Beispiel #7
0
        def _export():
            self.applet.busy = True
            self.applet.appletStateUpdateRequested.emit()

            t_from = None
            # determine from_time (it could has been changed in the GUI meanwhile)
            for t_from, label2color_at in enumerate(
                    self.mainOperator.label2color):
                if len(label2color_at) == 0:
                    continue
                else:
                    break

            if t_from is None:
                self._criticalMessage("There is nothing to export.")
                return

            t_from = int(t_from)

            logger.info("Saving first label image...")
            key = []
            for idx, flag in enumerate(
                    axisTagsToString(
                        self.mainOperator.LabelImage.meta.axistags)):
                if flag is 't':
                    key.append(slice(t_from, t_from + 1))
                elif flag is 'c':
                    key.append(slice(0, 1))
                else:
                    key.append(
                        slice(0, self.mainOperator.LabelImage.meta.shape[idx]))

            roi = SubRegion(self.mainOperator.LabelImage, key)
            labelImage = self.mainOperator.LabelImage.get(roi).wait()
            labelImage = labelImage[0, ..., 0]

            try:
                # write_events([], str(directory), t_from, labelImage)

                events = self.mainOperator.EventsVector.value
                logger.info("Saving events...")
                logger.info("Length of events " + str(len(events)))

                num_files = float(len(events))

                for i in sorted(events.keys()):
                    events_at = events[i]
                    i = int(i)
                    t = t_from + i
                    key[0] = slice(t, t + 1)
                    roi = SubRegion(self.mainOperator.LabelImage, key)
                    labelImage = self.mainOperator.LabelImage.get(roi).wait()
                    labelImage = labelImage[0, ..., 0]
                    if self.withMergers:
                        write_events(events_at, str(directory), t, labelImage,
                                     self.mainOperator.mergers)
                    else:
                        write_events(events_at, str(directory), t, labelImage)
                    _handle_progress(i / num_files * 100)
            except IOError as e:
                self._criticalMessage("Cannot export the tracking results. Maybe these files already exist. "\
                                      "Please delete them or choose a different directory.")
                return