Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/nno/burstiDAtor
Browse files Browse the repository at this point in the history
  • Loading branch information
nno committed Jun 28, 2019
2 parents 143a128 + 143578a commit f343c4b
Show file tree
Hide file tree
Showing 16 changed files with 846 additions and 216 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
*.m~
.git.bfg-report
build
bin
*.jar
.*.sw?
.classpath
.project
15 changes: 3 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,11 @@ ENTRY_POINT = burstiDAtor/BurstiDAtor

BUILD_DIR = build/java

SOURCE_FILES = \
java/burstiDAtor/Burst.java \
java/burstiDAtor/BurstWizard.java \
java/burstiDAtor/BurstiDAtor.java \
java/burstiDAtor/Bursts.java \
java/burstiDAtor/Props.java \
java/burstiDAtor/Settings.java \
java/burstiDAtor/Spikes.java \
java/burstiDAtor/Utils.java
SOURCE_FILES = $(wildcard java/burstiDAtor/*.java)

JAVAC = javac
JFLAGS = -encoding UTF-8


vpath %.class build/java
vpath %.java java

Expand All @@ -37,7 +28,7 @@ Default:
@echo "make run: run your app."
@echo "make jar: package your project into a executable jar."

build: $(SOURCE_FILES:.java=.class)
build: ${BUILD_DIR} $(SOURCE_FILES:.java=.class)

# pattern rule
%.class: %.java
Expand All @@ -58,7 +49,7 @@ clean:
run: build
java -cp build/java $(ENTRY_POINT)

jar: build
jar: clean build
jar cvfe $(JAR_PKG) $(ENTRY_POINT) -C build/java .


82 changes: 82 additions & 0 deletions java/burstiDAtor/AutoCorr.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package burstiDAtor;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

public class AutoCorr extends Histogram {
public AutoCorr(Spikes spikes) {
super();
int n_spikes = spikes.length();

Settings settings = Settings.getInstance();
SpikeDelta min_isi = SpikeDelta.fromString(settings.getS("autocorr_min"));
SpikeDelta max_isi = SpikeDelta.fromString(settings.getS("autocorr_max"));
SpikeDelta binwidth = SpikeDelta.fromString(settings.getS("autocorr_binwidth"));

int n_bins = max_isi.subtract(min_isi).divideCeil(binwidth);

for (int i = 0; i <= n_bins; i++) {
bins.add((double) i);
if (i<n_bins) {
counts.add(0);
}
}

if (n_spikes<2) {
return;
}

for (int i = 0; i < n_spikes; i++) {
for (int j = i + 1; j < spikes.length(); j++) {
SpikeDelta delta = new SpikeDelta(spikes.get(i), spikes.get(j));
int bin = getBin(min_isi, binwidth, delta);
boolean too_small = bin < 0;
boolean too_large = bin >= n_bins;
boolean keep = !(too_small || too_large);
if (keep) {
counts.set(bin, 1 + counts.get(bin));
}
if (too_large) {
break;
}
}
}
}

public static int getBin(SpikeDelta t_onset, SpikeDelta binwidth, SpikeDelta t) {
int bin = t.subtract(t_onset).divideFloor(binwidth);
return bin;
}

public BufferedImage getPlot() {
return super.getPlot("time (ms)");
}


public static void main(String... _) throws Exception {
String d = "/Users/nick/tmp/";

String[] fns = { "neuron 1 651542.txt", "neuron 2 653286.txt", "Neuron 3 653284.txt" };

for (int i = 0; i < fns.length; i++) {

String fn = "/Users/nick/tmp/" + fns[i];
File f = new File(fn);
Spikes spikes = new Spikes(f);
AutoCorr ac = new AutoCorr(spikes);

BufferedImage img = ac.getPlot();

try {
// Save as PNG
File file = new File("/Users/nick/tmp/neuron" + (i + 1) + ".png");
ImageIO.write(img, "png", file);

} catch (IOException e) {
}

}
}
}
8 changes: 4 additions & 4 deletions java/burstiDAtor/Burst.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

/**
* Contains onset information of spikes in a burst
*
*
* @author nick
*
*
*/
public class Burst {
Vector<Double> onsets;
Expand All @@ -20,7 +20,7 @@ public Burst() {

/**
* add a spike to the burst
*
*
* @param onset
* time of the spike
*/
Expand All @@ -30,7 +30,7 @@ public void add(double onset) {

/**
* Compute statistics for this burst
*
*
* @param fs
* Optional list of property keys to return. If null or empty
* then all keys are returned.
Expand Down
Loading

0 comments on commit f343c4b

Please sign in to comment.