示例#1
0
 def load_new_image(self, action):
     image_filter = gtk.FileFilter()
     image_filter.add_pattern("*.hdr")
     image_filter.add_pattern("*.nii")
     image_filter.set_name("Recon Images")
     fname = ask_fname(self, "Choose file to open...", action="open",
                       filter=image_filter)
     if not fname:
         return
     try:
         img = readImage(fname, "nifti")
     except:
         img = readImage(fname, "analyze")
     self.killoverlay(None)
     self.__init__(img)
示例#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 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()
示例#4
0
 def reload_image(self, button):
     "called when reload (refresh) button is hit"
     if not self.image:
         return
     path = self.image.path
     self.image = readImage(path, vrange=(0, 1))
     self._initialize_undo_buffer()
     self.update_plotter()
示例#5
0
 def reload_image(self, button):
     "called when reload (refresh) button is hit"
     if not self.image:
         return
     path = self.image.path
     self.image = readImage(path, vrange=(0, 1))
     self._initialize_undo_buffer()
     self.update_plotter()
示例#6
0
def load_data_prepd(fname, sl=0, N1=64):
    img = imageio.readImage(fname, N1=N1)
    cdata = np.empty((img.n_chan, img.n_pe, img.N1), 'F')
    cdata[:] = img.cdata[:,0,sl,:,:]
    del img.n_chan
    del img.cdata
    img.setData(cdata)
    return img
示例#7
0
def load_data_prepd(fname, sl=0, N1=64):
    img = imageio.readImage(fname, N1=N1)
    cdata = np.empty((img.n_chan, img.n_pe, img.N1), 'F')
    cdata[:] = img.cdata[:, 0, sl, :, :]
    del img.n_chan
    del img.cdata
    img.setData(cdata)
    return img
示例#8
0
 def load_new_image(self, action):
     image_filter = gtk.FileFilter()
     image_filter.add_pattern("*.hdr")
     image_filter.add_pattern("*.nii")
     image_filter.set_name("Recon Images")
     fname = ask_fname(self,
                       "Choose file to open...",
                       action="open",
                       filter=image_filter)
     if not fname:
         return
     try:
         img = readImage(fname, "nifti")
     except:
         img = readImage(fname, "analyze")
     self.killoverlay(None)
     self.__init__(img)
 def setUp(self):
     pwd = os.path.split(__file__)[0]
     kernfile = os.path.join(pwd, 'fmap_based_kernel_long')
     self.ref_kernel = np.fromstring(
         open(kernfile, 'rb').read(), np.complex128)
     self.ref_kernel.shape = (20, 64, 64, 64)
     fmapfile = os.path.join(pwd, "test_fmap.nii")
     fmapIm = readImage(fmapfile)
     self.fmap, self.chi = (fmapIm[0].astype(np.float64),
                            fmapIm[1].astype(np.float64))
 def setUp(self):
     pwd = os.path.split(__file__)[0]
     kernfile = os.path.join(pwd, 'fmap_based_kernel_long')
     self.ref_kernel = np.fromstring(open(kernfile, 'rb').read(),
                                    np.complex128)
     self.ref_kernel.shape = (20,64,64,64)
     fmapfile = os.path.join(pwd, "test_fmap.nii")
     fmapIm = readImage(fmapfile)
     self.fmap,self.chi = (fmapIm[0].astype(np.float64),
                           fmapIm[1].astype(np.float64))
示例#11
0
 def run(self, plotter="slice"):
     opts, args = self.parse_args()
     if not args:
         self.print_help()
         sys.exit(0)
     image = readImage(args[0])
     if plotter is "slice":
         ViewImage(title=args[0]).run(image)
     else:
         ViewOrtho(title=args[0]).run(image)
示例#12
0
 def run(self):
     opts, args = self.parse_args()
     if args:
         vrange = parseVolRangeOption(opts.vol_range, self)
         try:
             image = readImage(args[0], vrange=vrange)
         except:
             image = None
             print 'Could not find image %s, try loading manually'%args[0]
             
     else:
         image = None
     recon_gui(image=image, logfile=opts.log_file)
示例#13
0
    def run(self):
        opts, args = self.parse_args()
        if args:
            vrange = parseVolRangeOption(opts.vol_range, self)
            try:
                image = readImage(args[0], vrange=vrange)
            except:
                image = None
                print 'Could not find image %s, try loading manually' % args[0]

        else:
            image = None
        recon_gui(image=image, logfile=opts.log_file)
示例#14
0
    def initoverlay(self, action):
        image_filter = gtk.FileFilter()
        image_filter.add_pattern("*.hdr")
        image_filter.add_pattern("*.nii")
        image_filter.set_name("Recon Images")
        fname = ask_fname(self,
                          "Choose file to overlay...",
                          action="open",
                          filter=image_filter)
        if not fname:
            return
        img = readImage(fname, vrange=(0, 0))
        self.overlay_img = SlicerImage(img)

        img_dims = N.take(
            N.array(self.image.shape) * self.image.dr, self.image.slicing())
        ovl_dims = N.take(
            N.array(self.overlay_img.shape) * self.overlay_img.dr,
            self.overlay_img.slicing())
        if not (img_dims == ovl_dims).all():
            print img_dims, ovl_dims
            print "Overlay failed because physical dimensions do not align..."
            print "base image dimensions (zyx): [%3.1f %3.1f %3.1f] (mm)" % tuple(
                img_dims)
            print "overlay image dimenensions (zyx: [%3.1f %3.1f %3.1f] (mm)" % tuple(
                ovl_dims)
            return
        self.setNorm()
        (ax, cor, sag) = self.overlay_img.slicing()
        self.ax_overlay = OverLay(self.ax_plot,
                                  ax,
                                  norm=self.overlay_norm,
                                  interpolation=self.ax_plot.interpolation)
        self.cor_overlay = OverLay(self.cor_plot,
                                   cor,
                                   norm=self.overlay_norm,
                                   interpolation=self.cor_plot.interpolation)
        self.sag_overlay = OverLay(self.sag_plot,
                                   sag,
                                   norm=self.overlay_norm,
                                   interpolation=self.sag_plot.interpolation)
        self.overlays = [self.ax_overlay, self.cor_overlay, self.sag_overlay]
        self.updateSlices(self.image.zyx_coords(),
                          sliceplots=self.overlays,
                          image=self.overlay_img,
                          norm=self.overlay_norm)
示例#15
0
 def initoverlay(self, action):
     image_filter = gtk.FileFilter()
     image_filter.add_pattern("*.hdr")
     image_filter.add_pattern("*.nii")
     image_filter.set_name("Recon Images")
     fname = ask_fname(self, "Choose file to overlay...", action="open",
                       filter=image_filter)
     if not fname:
         return
     img = readImage(fname, vrange=(0,0))
     self.overlay_img = SlicerImage(img)
         
     img_dims = N.take(N.array(self.image.shape) * self.image.dr,
                       self.image.slicing())
     ovl_dims = N.take(N.array(self.overlay_img.shape) * self.overlay_img.dr,
                       self.overlay_img.slicing())
     if not (img_dims == ovl_dims).all():
         print img_dims, ovl_dims
         print "Overlay failed because physical dimensions do not align..."
         print "base image dimensions (zyx): [%3.1f %3.1f %3.1f] (mm)"%tuple(img_dims)
         print "overlay image dimenensions (zyx: [%3.1f %3.1f %3.1f] (mm)"%tuple(ovl_dims)
         return
     self.setNorm()
     (ax, cor, sag) = self.overlay_img.slicing()
     self.ax_overlay = OverLay(self.ax_plot, ax,
                               norm=self.overlay_norm,
                               interpolation=self.ax_plot.interpolation)
     self.cor_overlay = OverLay(self.cor_plot, cor,
                                norm=self.overlay_norm,
                                interpolation=self.cor_plot.interpolation)
     self.sag_overlay = OverLay(self.sag_plot, sag,
                                norm=self.overlay_norm,
                                interpolation=self.sag_plot.interpolation)
     self.overlays = [self.ax_overlay, self.cor_overlay, self.sag_overlay]
     self.updateSlices(self.image.zyx_coords(),
                       sliceplots=self.overlays,
                       image=self.overlay_img,
                       norm=self.overlay_norm)
示例#16
0
 def run(self):
     return readImage(self.filename,
                      self.format,
                      datatype=self.datatype,
                      vrange=self.vrange)  #, N1=128)
示例#17
0
    #-------------------------------------------------------------------------
    def _takedown(self, foo):
        self.padre.overlay_tools = None
        foo.destroy()

    #-------------------------------------------------------------------------
    def alpha_handler(self, adj):
        for overlay in self.overlay_ref:
            overlay.setAlpha(self.alphaslider.get_value())

    #-------------------------------------------------------------------------
    def cmap_handler(self, cbox):
        cmap = cmap_lookup[cbox.get_active()]
        for overlay in self.overlay_ref:
            overlay.setCmap(cmap)

    #-------------------------------------------------------------------------
    def interpo_handler(self, cbox):
        interpo = interp_lookup[cbox.get_active()]
        for overlay in self.overlay_ref:
            overlay.setInterpo(interpo)


##############################################################################
if __name__ == "__main__":
    fname = sys.argv[1]
    ftype = len(sys.argv) > 2 and sys.argv[2] or "analyze"
    img = readImage(fname, ftype)
    spmclone(img)
    
示例#18
0
 def run(self):        
     return readImage(self.filename, self.format,
                      datatype=self.datatype, vrange=self.vrange) #, N1=128)
示例#19
0
    #-------------------------------------------------------------------------
    def _takedown(self, foo):
        self.padre.overlay_tools = None
        foo.destroy()

    #-------------------------------------------------------------------------
    def alpha_handler(self, adj):
        for overlay in self.overlay_ref:
            overlay.setAlpha(self.alphaslider.get_value())

    #-------------------------------------------------------------------------
    def cmap_handler(self, cbox):
        cmap = cmap_lookup[cbox.get_active()]
        for overlay in self.overlay_ref:
            overlay.setCmap(cmap)

    #-------------------------------------------------------------------------
    def interpo_handler(self, cbox):
        interpo = interp_lookup[cbox.get_active()]
        for overlay in self.overlay_ref:
            overlay.setInterpo(interpo)


##############################################################################
if __name__ == "__main__":
    fname = sys.argv[1]
    ftype = len(sys.argv) > 2 and sys.argv[2] or "analyze"
    img = readImage(fname, ftype)
    spmclone(img)