示例#1
0
    def load_any_image(self, action):
        "called when open button/menu item is hit"
        fid_filter = gtk.FileFilter()
        fid_filter.add_pattern("fid")
        fid_filter.set_name("FID Images")

        dat_filter = gtk.FileFilter()
        dat_filter.add_pattern("*.dat")
        dat_filter.set_name("DAT Images")

        ana_nii_filter = gtk.FileFilter()
        ana_nii_filter.add_pattern("*.hdr")
        ana_nii_filter.add_pattern("*.nii")
        ana_nii_filter.set_name("ANALYZE/NIFTI Images")

        fname = ask_fname(
            self, "Choose file to load...", action="open", filter=[fid_filter, dat_filter, ana_nii_filter]
        )

        if not fname:
            return
        # cook any fid filename found
        if fname[-8:] == ".fid/fid":
            fname = os.path.split(fname)[0]
        self.image = readImage(fname, vrange=(0, 1))
        self._initialize_undo_buffer()
        self.pathentry.set_text(fname.split("/")[-1])
        self.update_plotter()
示例#2
0
    def load_any_image(self, action):
        "called when open button/menu item is hit"
        fid_filter = gtk.FileFilter()
        fid_filter.add_pattern('fid')
        fid_filter.set_name('FID Images')

        dat_filter = gtk.FileFilter()
        dat_filter.add_pattern('*.dat')
        dat_filter.set_name('DAT Images')

        ana_nii_filter = gtk.FileFilter()
        ana_nii_filter.add_pattern('*.hdr')
        ana_nii_filter.add_pattern('*.nii')
        ana_nii_filter.set_name('ANALYZE/NIFTI Images')

        fname = ask_fname(self,
                          'Choose file to load...',
                          action='open',
                          filter=[fid_filter, dat_filter, ana_nii_filter])

        if not fname:
            return
        # cook any fid filename found
        if fname[-8:] == '.fid/fid':
            fname = os.path.split(fname)[0]
        self.image = readImage(fname, vrange=(0, 1))
        self._initialize_undo_buffer()
        self.pathentry.set_text(fname.split('/')[-1])
        self.update_plotter()
示例#3
0
 def save_image(self, button):
     "called when save image button is hit"
     if not self.image:
         return
     image_filter = gtk.FileFilter()
     image_filter.add_pattern("*.hdr")
     image_filter.set_name("ANALYZE files")
     fname = ask_fname(self, "Write image to this file...", action="save", filter=image_filter)
     if not fname:
         return
     if not self.image.combined:
         self.image.combine_channels()
     self.image.writeImage(fname, targetdim=self.image.ndim)
示例#4
0
 def save_oplist(self, button):
     "called when save oplist button is hit"
     fname = ask_fname(self, "Write oplist to this file...", action="save")
     if not fname:
         return
     oplist = self.construct_oplist()
     f = open(fname, "w")
     for opdef in oplist:
         f.write("[" + opdef[0] + "]\n")
         for key, val in opdef[1].items():
             f.write("%s = %s\n" % (key, val))
         f.write("\n")
     f.close()
示例#5
0
 def save_oplist(self, button):
     "called when save oplist button is hit"
     fname = ask_fname(self, 'Write oplist to this file...', action='save')
     if not fname:
         return
     oplist = self.construct_oplist()
     f = open(fname, 'w')
     for opdef in oplist:
         f.write('[' + opdef[0] + ']\n')
         for key, val in opdef[1].items():
             f.write('%s = %s\n' % (key, val))
         f.write('\n')
     f.close()
示例#6
0
 def save_image(self, button):
     "called when save image button is hit"
     if not self.image:
         return
     image_filter = gtk.FileFilter()
     image_filter.add_pattern('*.hdr')
     image_filter.set_name('ANALYZE files')
     fname = ask_fname(self,
                       'Write image to this file...',
                       action='save',
                       filter=image_filter)
     if not fname:
         return
     if not self.image.combined:
         self.image.combine_channels()
     self.image.writeImage(fname, targetdim=self.image.ndim)