Skip to content

Commit

Permalink
renamed calcCoeffVar to calcSCV
Browse files Browse the repository at this point in the history
it's actually the squared coefficient of variation, renamed to fix, no changes to algorithm
  • Loading branch information
acaccavano committed Dec 6, 2019
1 parent 7d8e23b commit 2fe04f8
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions 4-calcCoeffVarBatch.ijm → 4-calcSCVBatch.ijm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Macro to calculate Coefficient of Variation (CV), defined as Var(Img)/(Ave(Img)^2) = 1/nFrames * Sum[[(Img-Ave(Img)/Ave(Img)]^2]
// Macro to calculate the Squared Coefficient of Variation (SCV), defined as Var(Img)/(Ave(Img)^2) = 1/nFrames * Sum[[(Img-Ave(Img)/Ave(Img)]^2]
// Output is a single TIF file for each file, highlighting the most active regions across the time series

parentDir = getDirectory("Select folder containing bleach-corrected tif stacks");
saveDir = getDirectory("Now select folder to save (dF/F)^2 coefficient of variation (CV) tif images");
saveDir = getDirectory("Now select folder to save Squared Coefficient of Variation (SCV) tif images");
stackList = getFileList(parentDir);

setBatchMode(true);
Expand All @@ -13,8 +13,8 @@ for (i=0; i<stackList.length; i++) {
// Import Stack
open(parentDir + stackList[i]);
stackName = getTitle();
print("Computing (dF/F)^2 Coeff. of Var. for file: " + stackName);
cvImage = substring(stackName, 0, lengthOf(stackName) - 4) + "_CV";
print("Computing Squared Coefficient of Variation (SCV) [Var(F)/Ave(F)^2] for file: " + stackName);
scvImage = substring(stackName, 0, lengthOf(stackName) - 4) + "_SCV";

// Apply Gaussian filter to time series
run("Duplicate...", "duplicate");
Expand Down Expand Up @@ -43,16 +43,16 @@ for (i=0; i<stackList.length; i++) {
rename(multImage);

if (j==1) {
rename(cvImage);
rename(scvImage);
} else {
imageCalculator("Add create 32-bit", cvImage, multImage);
newCVImage = getTitle();
imageCalculator("Add create 32-bit", scvImage, multImage);
newSCVImage = getTitle();
selectWindow(multImage);
close();
selectWindow(cvImage);
selectWindow(scvImage);
close();
selectWindow(newCVImage);
rename(cvImage);
selectWindow(newSCVImage);
rename(scvImage);
}
selectWindow(divImage);
close();
Expand All @@ -65,17 +65,17 @@ for (i=0; i<stackList.length; i++) {
close();
selectWindow(aveImage);
close();
selectWindow(cvImage);
selectWindow(scvImage);
run("Divide...", "value=" + nFrames);
run("Enhance Contrast", "saturated=0.35");

// Save File
saveName = saveDir + cvImage;
saveName = saveDir + scvImage;
print("Saving file: " + saveName);
saveAs("Tiff", saveName);
close();

}

setBatchMode(false);
waitForUser("(dF/F)^2 CoeffVar macro finished for folder " + parentDir);
waitForUser("(Squared Coefficient of Variation (SCV) macro finished for folder " + parentDir);

0 comments on commit 2fe04f8

Please sign in to comment.