<commit_before>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package eu.visualize.ini.retinamodel;

import net.sf.jaer.chip.AEChip;
import net.sf.jaer.event.BasicEvent;
import net.sf.jaer.event.EventPacket;
import net.sf.jaer.event.PolarityEvent;

//import net.sf.jaer.event.orientation.ApsDvsMotionOrientationEvent;
//import net.sf.jaer.eventprocessing.label.ApsDvsDirectionSelectiveFilter;
//****************************************************************************//

//-- Description -------------------------------------------------------------//
// 
// @author Scott and Diederik
//****************************************************************************//
//-- Main class OMCOD --------------------------------------------------------//
public class DirectionSelectiveCell_new{

    private float[][] storedPreviousTimestamp;
    private float[][] storedPreviousValue;
    private float delayUs;
    private float decayTime;
    private float MembranePotential;
    private float IFthreshold;
    private int nxmax;
    private int nymax;
    private int timeConstant;

    public DirectionSelectiveCell_new(AEChip chip) {

        this.storedPreviousTimestamp = new float[nxmax][nymax]; // deleted -1 in all
        this.nxmax = chip.getSizeX() >> 3;
        this.nymax = chip.getSizeY() >> 3;

//------------------------------------------------------------------------------
        //   setPropertyTooltip(disp, "showSubunits", "Enables showing subunit activity annotation over retina output");

    }

    //----------------------------------------------------------------------------//
//-- Filter packet method ----------------------------------------------------//
//----------------------------------------------------------------------------//
//    @Override
    public EventPacket<?> filterPacket(EventPacket<?> in) {
        //checkOutputPacketEventType(in); // make sure memory is allocated to avoid leak.
        for (Object o : in) {
            PolarityEvent e = (PolarityEvent) o;
            if (e.isSpecial() || e.isFilteredOut()) {
                continue;
            }
            decayBy(e);
            computeDirection(e);
        }
        return in;
    }

    public void decayBy(PolarityEvent e) {
        if (e.timestamp - storedPreviousTimestamp[e.x][e.y] >= delayUs) {

            decayTime = (float) -(e.timestamp - storedPreviousTimestamp[e.x][e.y] - delayUs)/timeConstant;
            storedPreviousValue[e.x][e.y] = (float) (storedPreviousValue[e.x][e.y] * (Math.pow(2.7, decayTime)));
        }
    }

    public void computeDirection(BasicEvent e) {
        if (e.x != 0) {
            if (storedPreviousTimestamp[e.x - 1][e.y] - storedPreviousTimestamp[e.x][e.y] >= delayUs) {
                MembranePotential = storedPreviousValue[e.x - 1][e.y] + storedPreviousValue[e.x][e.y];
                if (MembranePotential >= IFthreshold) {
                    spike();
                }
            }
        }
    }

    public void spike() {
        System.out.println("spiked");
    }
    
    public float getDdelayUs() {
        return delayUs;
    }
    
    public void setDelayUs(float delayUs) {
        this.delayUs = delayUs;
        putFloat("delayUs", delayUs);
    }
//------------------------------------------------------------------------------
}<commit_msg>fixed the build error, sorry everyone<commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package eu.visualize.ini.retinamodel;

import net.sf.jaer.chip.AEChip;
import net.sf.jaer.event.BasicEvent;
import net.sf.jaer.event.EventPacket;
import net.sf.jaer.event.PolarityEvent;

//import net.sf.jaer.event.orientation.ApsDvsMotionOrientationEvent;
//import net.sf.jaer.eventprocessing.label.ApsDvsDirectionSelectiveFilter;
//****************************************************************************//

//-- Description -------------------------------------------------------------//
// 
// @author Scott and Diederik
//****************************************************************************//
//-- Main class OMCOD --------------------------------------------------------//
public class DirectionSelectiveCell_new{

    private float[][] storedPreviousTimestamp;
    private float[][] storedPreviousValue;
    private float delayUs;
    private float decayTime;
    private float MembranePotential;
    private float IFthreshold;
    private int nxmax;
    private int nymax;
    private int timeConstant;

    public DirectionSelectiveCell_new(AEChip chip) {

        this.storedPreviousTimestamp = new float[nxmax][nymax]; // deleted -1 in all
        this.nxmax = chip.getSizeX() >> 3;
        this.nymax = chip.getSizeY() >> 3;

//------------------------------------------------------------------------------
        //   setPropertyTooltip(disp, "showSubunits", "Enables showing subunit activity annotation over retina output");

    }

    //----------------------------------------------------------------------------//
//-- Filter packet method ----------------------------------------------------//
//----------------------------------------------------------------------------//
//    @Override
    public EventPacket<?> filterPacket(EventPacket<?> in) {
        //checkOutputPacketEventType(in); // make sure memory is allocated to avoid leak.
        for (Object o : in) {
            PolarityEvent e = (PolarityEvent) o;
            if (e.isSpecial() || e.isFilteredOut()) {
                continue;
            }
            decayBy(e);
            computeDirection(e);
        }
        return in;
    }

    public void decayBy(PolarityEvent e) {
        if (e.timestamp - storedPreviousTimestamp[e.x][e.y] >= delayUs) {

            decayTime = (float) -(e.timestamp - storedPreviousTimestamp[e.x][e.y] - delayUs)/timeConstant;
            storedPreviousValue[e.x][e.y] = (float) (storedPreviousValue[e.x][e.y] * (Math.pow(2.7, decayTime)));
        }
    }

    public void computeDirection(BasicEvent e) {
        if (e.x != 0) {
            if (storedPreviousTimestamp[e.x - 1][e.y] - storedPreviousTimestamp[e.x][e.y] >= delayUs) {
                MembranePotential = storedPreviousValue[e.x - 1][e.y] + storedPreviousValue[e.x][e.y];
                if (MembranePotential >= IFthreshold) {
                    spike();
                }
            }
        }
    }

    public void spike() {
        System.out.println("spiked");
    }
    
    public float getDdelayUs() {
        return delayUs;
    }
    
    public void setDelayUs(float delayUs) {
        this.delayUs = delayUs;
        //putFloat("delayUs", delayUs);
    }
//------------------------------------------------------------------------------
}
{'fraction_non_alphanumeric': 0.2830649798734905, 'fraction_numerical': 0.0023001725129384704, 'mean_word_length': 1.6233031674208145, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7249354', 'n_tokens_mistral': 1816, 'n_tokens_neox': 1744, 'n_words': 391}