id1=getImageID;
name=getTitle();

Dialog.create("Image Difference");
Dialog.addNumber("Start:", 1);
Dialog.addNumber("End:", 51);
Dialog.addNumber("Peak Start:", 53);
Dialog.addNumber("Peak End:", 62);

Dialog.show();

starter=Dialog.getNumber(); 
end = Dialog.getNumber();
peakst = Dialog.getNumber();
peaken=Dialog.getNumber();;

run("Fire");
run("Z Project..." , "start="+starter+" stop="+end+ ("projection= [Average Intensity]"));
rename("prestimulus_"+name);
id2=getImageID;

selectImage(id1);

run("Z Project..." , "start="+peakst+" stop="+peaken+ ("projection= [Average Intensity]"));
rename("peakstimulus_"+name);
id3=getImageID;

imageCalculator("Subtract create", id3, id2); 
rename("delta_"+name);
id4=getImageID;
run("Smooth");


/*  this plugin/macro obtains a difference image between frames within an image stack. You can

1. obtains an average pre stimulus image from specified start images, called "prestimulus_"+filename.
if you want to use only one image for prestimulus, specify "Start" and "End" as same image in the Dialog box.

2. obtains an average peak stimulus image from specified peak images, called "peakstimulus_"+filename
if you want to use only one image for prestimulus, specify "Peak Start" and "Peak End" as same image in the Dialog box.

3. creates a difference image of the two average images, called "delta_"+filename

-Created by Meera Mani on Dec 3, 2007

-Modified by Pablo on Dec 4, 2007

1. Set to my typical defaults 
2. Set to fire
3. Added smoothing for the delta image

Copy this .txt file into the plugins folder. It should appear as a plugin when ImageJ is reopened. 

/*
