fable.python
Class FabioFile

java.lang.Object
  extended by fable.python.FabioFile
All Implemented Interfaces:
java.lang.Comparable<java.lang.Object>, java.util.EventListener, org.eclipse.jface.util.IPropertyChangeListener

public class FabioFile
extends java.lang.Object
implements java.lang.Comparable<java.lang.Object>, org.eclipse.jface.util.IPropertyChangeListener

The FabioFile class is used to read files using the Python fabio package. It uses the Jep interpreter to call Python. It can be used in multi-threaded Java environments. Different thread should supply their own Jep interpreter. The image data is stored in a cache so that the last N images will be read from the cache and not from disk. This will be reflected in the time to read i.e. it will be zero. The cache size can be increased in function of the memory available. It is currently set to 20 i.e. 20*16 MB.

Author:
Andy Gotz + Gaelle Suchet

Field Summary
 boolean headerRead
           
 boolean imageRead
           
 
Constructor Summary
FabioFile(java.lang.String _fullFileName)
          Create a FabioFile object which be able to read Fabio files via the fabio Python module.
 
Method Summary
 void acquire()
           
 void addHeaderInfo(java.lang.String key, java.lang.String value)
          Add new key in header info
 void addIndex(int index)
          Gaelle : add a sample Vector index for this fabioFile
 int compareTo(java.lang.Object other)
           
 int compareTo(java.lang.String key, java.lang.Object other)
           
 int getBytesPerPixel()
           
 java.lang.String getFileName()
          return short file name i.e.
 java.lang.String getFileNumber()
           
 boolean getFlag()
           
 java.lang.String getFullFilename()
           
 java.lang.String getFullFileName()
           
 int getHeight()
          get image height
 float[] getImageAsFloat()
          Return image as floating pint array
 float[] getImageAsFloat(FableJep jep)
          Return image as floating pint array
 int[] getImageAsInt()
          return image as int by converting the float image to int, do not keep the image in memory
 java.lang.String[] getKeys()
           
 java.util.Vector<java.lang.String> getKeysAsListedInHeader()
           
 float getMaximum()
          return maximum value in image
 float getMean()
          return mean value in image
 float getMinimum()
          return minimum value in image
 java.lang.String getStems()
          8 janv.
 long getTimeToReadImage()
          get time to read image in ms
 java.lang.String getValue(java.lang.String key)
           
 int getWidth()
          get image width
 void loadHeader()
          Load only the header and not the image.
 void loadHeader(FableJep fableJep)
          Load only the header and not the image.
 void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event)
           
 void readImage()
          read image into memory
 void readImageAsFloat()
          read image as float into memory
 void readImageAsFloat(FableJep fableJep)
          read image as float into memory
 void release()
           
 void setFlag(boolean b)
           
 void setFullFileName(java.lang.String fullfilename)
          Set the fullfilename of fabio file if different from header
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

headerRead

public boolean headerRead

imageRead

public boolean imageRead
Constructor Detail

FabioFile

public FabioFile(java.lang.String _fullFileName)
          throws FabioFileException
Create a FabioFile object which be able to read Fabio files via the fabio Python module.

Parameters:
fileName -
Throws:
FabioFileException
Method Detail

acquire

public void acquire()

release

public void release()

setFullFileName

public void setFullFileName(java.lang.String fullfilename)
Set the fullfilename of fabio file if different from header

Parameters:
fullfilename -

getFullFileName

public java.lang.String getFullFileName()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

loadHeader

public void loadHeader()
                throws FabioFileException
Load only the header and not the image. loadHeader() uses the python fabio module to read the header.

Throws:
FabioFileException
java.lang.Throwable

loadHeader

public void loadHeader(FableJep fableJep)
                throws FabioFileException
Load only the header and not the image. loadHeader() uses the python fabio module to read the header. Use the jep interpreter provided by the callee. This is needed for reading headers in multithreaded environments.

Throws:
FabioFileException

addHeaderInfo

public void addHeaderInfo(java.lang.String key,
                          java.lang.String value)
Add new key in header info


getKeys

public java.lang.String[] getKeys()
                           throws FabioFileException,
                                  java.lang.Throwable
Returns:
Fabio header keys
Throws:
FabioFileException
java.lang.Throwable

getKeysAsListedInHeader

public java.util.Vector<java.lang.String> getKeysAsListedInHeader()
                                                           throws FabioFileException,
                                                                  java.lang.Throwable
Returns:
a vector of EDF Header Keys
Throws:
FabioFileException
java.lang.Throwable

getValue

public java.lang.String getValue(java.lang.String key)
                          throws FabioFileException
Parameters:
key - the header key
Returns:
the value of the key header
Throws:
FabioFileException
java.lang.Throwable

addIndex

public void addIndex(int index)
Gaelle : add a sample Vector index for this fabioFile

Parameters:
index - index in sample vector file

getFullFilename

public java.lang.String getFullFilename()

getFileName

public java.lang.String getFileName()
return short file name i.e. without the path

Returns:
short file name

getTimeToReadImage

public long getTimeToReadImage()
get time to read image in ms

Returns:
time to took to read image and make a copy

getStems

public java.lang.String getStems()
8 janv. 08

Returns:
fabio file stem name

getFileNumber

public java.lang.String getFileNumber()
Returns:
file number, even for bruker format //TODO test with bruker files

getWidth

public int getWidth()
             throws java.lang.Throwable
get image width

Returns:
image width
Throws:
java.lang.Throwable

getHeight

public int getHeight()
              throws java.lang.Throwable
get image height

Returns:
image height
Throws:
java.lang.Throwable

getBytesPerPixel

public int getBytesPerPixel()

readImage

public void readImage()
               throws java.lang.Throwable
read image into memory

Throws:
java.lang.Throwable

readImageAsFloat

public void readImageAsFloat()
                      throws java.lang.Throwable
read image as float into memory

Throws:
java.lang.Throwable

readImageAsFloat

public void readImageAsFloat(FableJep fableJep)
                      throws java.lang.Throwable
read image as float into memory

Throws:
java.lang.Throwable

getImageAsFloat

public float[] getImageAsFloat()
                        throws java.lang.Throwable
Return image as floating pint array

Returns:
image as floating point array
Throws:
java.lang.Throwable

getImageAsFloat

public float[] getImageAsFloat(FableJep jep)
Return image as floating pint array

Returns:
image as floating point array

getImageAsInt

public int[] getImageAsInt()
                    throws java.lang.Throwable
return image as int by converting the float image to int, do not keep the image in memory

Returns:
image as integer array
Throws:
java.lang.Throwable

getMinimum

public float getMinimum()
                 throws java.lang.Throwable
return minimum value in image

Returns:
image minimum
Throws:
java.lang.Throwable

getMaximum

public float getMaximum()
                 throws java.lang.Throwable
return maximum value in image

Returns:
image maximum
Throws:
java.lang.Throwable

getMean

public float getMean()
              throws java.lang.Throwable
return mean value in image

Returns:
image mean
Throws:
java.lang.Throwable

setFlag

public void setFlag(boolean b)

getFlag

public boolean getFlag()

compareTo

public int compareTo(java.lang.Object other)
Specified by:
compareTo in interface java.lang.Comparable<java.lang.Object>

compareTo

public int compareTo(java.lang.String key,
                     java.lang.Object other)
Parameters:
key - the key used to sort
other - the fableFile
Returns:
0 if equal, 1 if keyValue for other is greater than this,-1 if otherValue

propertyChange

public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event)
Specified by:
propertyChange in interface org.eclipse.jface.util.IPropertyChangeListener