Esempio n. 1
0
    def load(self):
        '''
        Loads the binary data from the raw image.  Tries to load .nrrd 
        '''
        if self.loaded:
            raise Exception("This fish has already been loaded.  Check to make sure you are not calling Fish.load() more than once.")
        t=type(self.filename)
        if t==type(str()):
            bindata=main.loadFile(self.filename)
            self.fileextension=main.parseExtension(self.filename)
        else:
            #TODO Make it so that it can handle more than one file
            raise Exception("I can't handle more than one file yet")
        
        #Get header data
        if ".nrrd" in self.fileextension or ".nhdr" in self.fileextension:
            self.hdrinfo,raw=splitNrrdData(self.bindata)
            self.axes=[i for i in reversed(self.hdrinfo["dsize"])]
        

        elif ".raw" in self.fileextension:
            raw=bindata
            if len(self.axes)==0:
                self.axes=main.getDimFromFile(self.filename)
                assert len(self.axes!=0), "Could not parse the The number of axes must be greater than zero."
        lineardata=main.unpacker2(raw, offset=0)
        self.shapegrid=np.reshape(lineardata, self.axes, order)
        self.loaded=True
Esempio n. 2
0
 def setDimensions(self, axes=[0]):
     '''
     Sets the fish dimensions from any of a number of data sources
     '''
     
     if len(axes)>0 and axes[0]>0:
         self.data.reshape(axes.reverse())
     else:
         self.fileextension=main.parseExtension(self.filename)
         if self.fileextension==".nrrd" or self.fileextension ==".nhdr":
             #Overwrite axes input
             #TODO See if this is necessary as time goes on.
             self.axes=self.hdrinfo["dsize"]
         elif "raw" in self.fileextension:
             dims= main.getDimFromFile(self.filename)    
             if dims is not None:
                 self.axes=dims
                 self.data.reshape(dims)