jAER project on SourceForge

net.sf.jaer.chip
Class TypedEventExtractor<T extends BasicEvent>

java.lang.Object
  extended by net.sf.jaer.chip.TypedEventExtractor<T>
All Implemented Interfaces:
java.io.Serializable, EventExtractor2D
Direct Known Subclasses:
CochleaAERb.Extractor, CochleaAMSNoBiasgen.Extractor, ColorContrastRetinaTestChip.Extractor, Conv32.Extractor, Conv64.Extractor, Conv64InOut.Extractor, Dollbrain1.Extractor, Learning.Extractor, RetinaExtractor, Tmpdiff128AndCochleaAERb.Extractor, Tmpdiff64AndCochleaAERb.Extractor, Tnc3.Extractor, UioFoveatedImager.Extractor, UioStaticBioVis.Extractor

public abstract class TypedEventExtractor<T extends BasicEvent>
extends java.lang.Object
implements EventExtractor2D, java.io.Serializable

An abstract 2D event extractor for 16 bit raw addresses. It is called with addresses and timestamps and extracts these to {X, Y, type} arrays based on methods that you define by subclassing and overriding the abstract methods. xMask, yMask, typeMask mask for x, y address and cell type, and xShift, yShift, typeShift say how many bits to shift after masking, xFlip,yFlip,typeFlip use the chip size to flip the x,y, and type to invert the addresses.

Author:
tobi
See Also:
Serialized Form

Field Summary
protected  AEChip chip
           
protected  boolean fliptype
           
protected  boolean flipx
           
protected  boolean flipy
           
protected  boolean hexArrangement
           
protected  EventPacket out
           
protected  boolean rotate
           
protected  int typemask
           
protected  byte typeshift
           
protected  int xmask
           
protected  byte xshift
           
protected  int ymask
           
protected  byte yshift
           
 
Constructor Summary
TypedEventExtractor(AEChip aechip)
          Creates a new instance of RetinaEventExtractor
 
Method Summary
 EventPacket extractPacket(AEPacketRaw in)
          extracts the meaning of the raw events.
 void extractPacket(AEPacketRaw in, EventPacket out)
          Extracts the meaning of the raw events.
 int getAddressFromCell(int x, int y, int type)
          computes the raw address from an x,y, and type.
 int getSubsampleThresholdEventCount()
           
 byte getTypeFromAddress(int addr)
          gets type from raw address.
 int getTypemask()
           
 byte getTypeshift()
           
 int getUsedBits()
           
 short getXFromAddress(int addr)
          Gets X from raw address.
 int getXmask()
           
 byte getXshift()
           
 short getYFromAddress(int addr)
          gets Y from raw address.
 int getYmask()
           
 byte getYshift()
           
 boolean isFliptype()
           
 boolean isFlipx()
           
 boolean isFlipy()
           
 boolean isSubsamplingEnabled()
           
 boolean matchesAddress(int addr1, int addr2)
           
 AEPacketRaw reconstructRawPacket(EventPacket packet)
          Reconstructs a raw packet suitable for logging to a data file, from an EventPacket that could be the result of filtering operations
 void setFliptype(boolean fliptype)
           
 void setFlipx(boolean flipx)
           
 void setFlipy(boolean flipy)
           
 void setSubsampleThresholdEventCount(int subsampleThresholdEventCount)
           
 void setSubsamplingEnabled(boolean subsamplingEnabled)
           
 void setTypemask(int typemask)
           
 void setTypeshift(byte typeshift)
           
 void setXmask(int xmask)
          bit mask for x address, before shift
 void setXshift(byte xshift)
           
 void setYmask(int ymask)
           
 void setYshift(byte yshift)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xmask

protected int xmask

ymask

protected int ymask

xshift

protected byte xshift

yshift

protected byte yshift

typemask

protected int typemask

typeshift

protected byte typeshift

chip

protected AEChip chip

flipx

protected boolean flipx

flipy

protected boolean flipy

rotate

protected boolean rotate

fliptype

protected boolean fliptype

hexArrangement

protected boolean hexArrangement

out

protected EventPacket out
Constructor Detail

TypedEventExtractor

public TypedEventExtractor(AEChip aechip)
Creates a new instance of RetinaEventExtractor

Parameters:
aechip - the chip this extractor extracts
Method Detail

getXFromAddress

public short getXFromAddress(int addr)
Gets X from raw address. declared final for speed, cannot be overridden in subclass. It expects addr to be from a certain format like ???? XXX? X?X? ????. The mask 0000 1110 1010 0000 will get those Xs. So, what's left is 0000 XXX0 X0X0 0000. Then it is shifted (the triple means zero-padding regardless of sign, necessary because addr is not defined as unsigned!) with the xshift parameter. So, in this case e.g. 5, what will make the result 0000 0000 0XXX 0X0X (0-64). If the incoming addr is big-endian versus small-endian the entire bit sequence has to be reversed of course. This is not what is done by flipx! That is just a boolean that results in the chip size minus the result otherwise. So, in the above example the place for X is still expected in the same spots (the mask is not inverted). Last remark: the masks are normally continuous, no weird blanks within them. :-) Ultimate remark: a mask of size 1 will invert the value if the flip parameter is set. Super-last remark: the parameter sizex should be 7 (not 8) for a mask of size 3 (000 - 111), like mentioned before. So, the sizex and sizey parameters in this TypedEventExtractor class are decremented with one compared to the same parameters in the class AEChip.

Specified by:
getXFromAddress in interface EventExtractor2D
Parameters:
addr - the raw address.
Returns:
physical address

getYFromAddress

public short getYFromAddress(int addr)
gets Y from raw address. declared final for speed, cannot be overridden in subclass.

Specified by:
getYFromAddress in interface EventExtractor2D
Parameters:
addr - the raw address.
Returns:
physical address

getTypeFromAddress

public byte getTypeFromAddress(int addr)
gets type from raw address. declared final for speed, cannot be overridden in subclass.

Specified by:
getTypeFromAddress in interface EventExtractor2D
Parameters:
addr - the raw address.
Returns:
physical address

extractPacket

public EventPacket extractPacket(AEPacketRaw in)
extracts the meaning of the raw events.

Specified by:
extractPacket in interface EventExtractor2D
Parameters:
in - the raw events, can be null
Returns:
out the processed events. these are partially processed in-place. empty packet is returned if null is supplied as in.

extractPacket

public void extractPacket(AEPacketRaw in,
                          EventPacket out)
Extracts the meaning of the raw events. This form is used to supply an output packet. This method is used for real time event filtering using a buffer of output events local to data acquisition. An AEPacketRaw may contain multiple events, not all of them have to sent out as EventPackets. An AEPacketRaw is a set(!) of addresses and corresponding timing moments. A first filter (independent from the other ones) is implemented by subSamplingEnabled and getSubsampleThresholdEventCount. The latter may limit the amount of samples in one package to say 50,000. If there are 160,000 events and there is a sub sample threshold of 50,000, a "skip parameter" set to 3. Every so now and then the routine skips with 4, so we end up with 50,000. It's an approximation, the amount of events may be less than 50,000. The events are extracted uniform from the input.

Specified by:
extractPacket in interface EventExtractor2D
Parameters:
in - the raw events, can be null
out - the processed events. these are partially processed in-place. empty packet is returned if null is supplied as input.

getTypemask

public int getTypemask()
Specified by:
getTypemask in interface EventExtractor2D

setTypemask

public void setTypemask(int typemask)
Specified by:
setTypemask in interface EventExtractor2D

getTypeshift

public byte getTypeshift()
Specified by:
getTypeshift in interface EventExtractor2D

setTypeshift

public void setTypeshift(byte typeshift)
Specified by:
setTypeshift in interface EventExtractor2D

getXmask

public int getXmask()
Specified by:
getXmask in interface EventExtractor2D

setXmask

public void setXmask(int xmask)
bit mask for x address, before shift

Specified by:
setXmask in interface EventExtractor2D

getXshift

public byte getXshift()
Specified by:
getXshift in interface EventExtractor2D

setXshift

public void setXshift(byte xshift)
Specified by:
setXshift in interface EventExtractor2D
Parameters:
xshift - the number of bits to right shift raw address after masking with setXmask(int)

getYmask

public int getYmask()
Specified by:
getYmask in interface EventExtractor2D

setYmask

public void setYmask(int ymask)
Specified by:
setYmask in interface EventExtractor2D
Parameters:
ymask - the bit mask for y address, before shift

getYshift

public byte getYshift()
Specified by:
getYshift in interface EventExtractor2D

setYshift

public void setYshift(byte yshift)
Specified by:
setYshift in interface EventExtractor2D
Parameters:
yshift - the number of bits to right shift raw address after masking with setYmask(int)

isFlipx

public boolean isFlipx()
Specified by:
isFlipx in interface EventExtractor2D

setFlipx

public void setFlipx(boolean flipx)
Specified by:
setFlipx in interface EventExtractor2D

isFlipy

public boolean isFlipy()
Specified by:
isFlipy in interface EventExtractor2D

setFlipy

public void setFlipy(boolean flipy)
Specified by:
setFlipy in interface EventExtractor2D

isFliptype

public boolean isFliptype()
Specified by:
isFliptype in interface EventExtractor2D

setFliptype

public void setFliptype(boolean fliptype)
Specified by:
setFliptype in interface EventExtractor2D

getUsedBits

public int getUsedBits()
Specified by:
getUsedBits in interface EventExtractor2D

matchesAddress

public boolean matchesAddress(int addr1,
                              int addr2)
Specified by:
matchesAddress in interface EventExtractor2D

getAddressFromCell

public int getAddressFromCell(int x,
                              int y,
                              int type)
computes the raw address from an x,y, and type. Useful for searching for events in e.g. matlab, given the raw addresses. This function does include flipped addresses - it uses flip booleans to pre-adjust x,y,type for chip.

Specified by:
getAddressFromCell in interface EventExtractor2D
Parameters:
x - the x address
y - the y address
type - the cell type
Returns:
the raw address

isSubsamplingEnabled

public boolean isSubsamplingEnabled()
Specified by:
isSubsamplingEnabled in interface EventExtractor2D

setSubsamplingEnabled

public void setSubsamplingEnabled(boolean subsamplingEnabled)
Specified by:
setSubsamplingEnabled in interface EventExtractor2D

getSubsampleThresholdEventCount

public int getSubsampleThresholdEventCount()
Specified by:
getSubsampleThresholdEventCount in interface EventExtractor2D

setSubsampleThresholdEventCount

public void setSubsampleThresholdEventCount(int subsampleThresholdEventCount)
Specified by:
setSubsampleThresholdEventCount in interface EventExtractor2D

reconstructRawPacket

public AEPacketRaw reconstructRawPacket(EventPacket packet)
Reconstructs a raw packet suitable for logging to a data file, from an EventPacket that could be the result of filtering operations

Specified by:
reconstructRawPacket in interface EventExtractor2D
Parameters:
packet - the EventPacket
Returns:
a raw packet holding the device events

jAER project on SourceForge