Skip to content

Commit

Permalink
changing defaults settings
Browse files Browse the repository at this point in the history
  • Loading branch information
cleterrier committed May 31, 2017
1 parent 4f11b94 commit b66efa6
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 100 deletions.
168 changes: 83 additions & 85 deletions Process locs files (batch)/Batch_Process_Locs.ijm
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ macro "Batch Process Localizations" {
CHOOSE_DEF = false;
CHOOSE_STRING_DEF = "";

EXC_DEF = false;
EXC_DEF = true;
EXC_STRING_DEF = "_ZR_";


// Drift correction
CORR_DRIFT_DEF = false;
CORR_DRIFT_DEF = true;
BIN_DEF = 12; // number of frames per sub-reconstruction used for autocorrelation
MAG_DEF = 5; // pixel size of sub-reconstructions used for autocorrelation
SM_DEF = 0.6; // smoothing factor for autocorrelation
Expand All @@ -55,9 +54,10 @@ macro "Batch Process Localizations" {
PHOT_MAX_DEF = 10000;

// Expression-based filter
EXP_FILT_DEF = false;
EXP_FILT_DEF = true;
// EXP_STRING_DEF = "intensity>700 & intensity<15000 & sigma>80 & uncertainty_xy<80"; for TS-processed or DOM-processed files
EXP_STRING_DEF = "intensity>700 & intensity<30000 & detections<5"; // for STORM
// EXP_STRING_DEF = "intensity>700 & intensity<20000 & detections<5"; // for STORM
EXP_STRING_DEF = "intensity>700 & intensity<100000 & detections<50"; // for STORM+PAINT
// EXP_STRING_DEF = "intensity>1500 & intensity<500000 & detections<500"; // for PAINT

// Density filter
Expand Down Expand Up @@ -205,7 +205,7 @@ macro "Batch Process Localizations" {
FileTotal = 0;
for (n = 0; n < ALL_NAMES.length; n++) {
if (endsWith(ALL_NAMES[n], LOC_SUFFIX) == true) {
if (CHOOSE == false || indexOf(ALL_NAMES[n], CHOOSE_STRING) > -1) {
if ((CHOOSE == false || indexOf(ALL_NAMES[n], CHOOSE_STRING) > -1) && (EXC == false || indexOf(ALL_NAMES[n], EXC_STRING) == -1)) {
FileTotal++;
}
}
Expand All @@ -215,91 +215,89 @@ macro "Batch Process Localizations" {
FileCount = 0;
for (n = 0; n < ALL_NAMES.length; n++) {
if (endsWith(ALL_NAMES[n], LOC_SUFFIX) == true) {
if (CHOOSE == false || indexOf(ALL_NAMES[n], CHOOSE_STRING) > -1) {
if (EXC == false || indexOf(ALL_NAMES[n], EXC_STRING) == -1) {

// Image counter
FileCount++;

// Get the file path
FILE_PATH = INPUT_DIR + ALL_NAMES[n];

// Store components of the file name
FILE_NAME = File.getName(FILE_PATH);
if ((CHOOSE == false || indexOf(ALL_NAMES[n], CHOOSE_STRING) > -1) && (EXC == false || indexOf(ALL_NAMES[n], EXC_STRING) == -1)) {
// Image counter
FileCount++;

// Get the file path
FILE_PATH = INPUT_DIR + ALL_NAMES[n];

// Store components of the file name
FILE_NAME = File.getName(FILE_PATH);

print(" Input file #" + FileCount + "/" + FileTotal + ": " + FILE_NAME);

OUT_TITLE = FILE_NAME;

// Open the loc file
run("Import results", "append=false startingframe=1 rawimagestack= filepath=[" + FILE_PATH + "] livepreview=false fileformat=[CSV (comma separated)]");


if (CORR_DRIFT == true) {
// Obtain the number of locs (# of lines in the loc file) and the number of steps for autocorrelation
// ROWS = eval("script", "importClass(Packages.cz.cuni.lf1.lge.ThunderSTORM.results.IJResultsTable); var rt = IJResultsTable.getResultsTable(); rows = rt.getRowCount();");
// FRAMES = eval("script", "importClass(Packages.cz.cuni.lf1.lge.ThunderSTORM.results.IJResultsTable); var rt = IJResultsTable.getResultsTable(); var rows = rt.getRowCount(); var colf = rt.findColumn(\"frame\"); var minf = parseInt(rt.getValue(0, colf)); var maxf = minf; for (var row = 1; row < rows; row++) {var val = parseInt(rt.getValue(row, colf)); if (val > maxf) maxf = val} frames = maxf;");
// FRAMES = parseInt(FRAMES);

print(" Input file #" + FileCount + "/" + FileTotal + ": " + FILE_NAME);
// STEPS = floor(FRAMES / PACKET_SIZE);
// if (STEPS < 2) STEPS = 2;
// MAGNIF = CAM_SIZE / XCORR_SIZE;

OUT_TITLE = FILE_NAME;

// Open the loc file
run("Import results", "append=false startingframe=1 rawimagestack= filepath=[" + FILE_PATH + "] livepreview=false fileformat=[CSV (comma separated)]");
// print(" Drift correction: found " + FRAMES + " frames, " + STEPS + " sub-images");


if (CORR_DRIFT == true) {
// Obtain the number of locs (# of lines in the loc file) and the number of steps for autocorrelation
// ROWS = eval("script", "importClass(Packages.cz.cuni.lf1.lge.ThunderSTORM.results.IJResultsTable); var rt = IJResultsTable.getResultsTable(); rows = rt.getRowCount();");
// FRAMES = eval("script", "importClass(Packages.cz.cuni.lf1.lge.ThunderSTORM.results.IJResultsTable); var rt = IJResultsTable.getResultsTable(); var rows = rt.getRowCount(); var colf = rt.findColumn(\"frame\"); var minf = parseInt(rt.getValue(0, colf)); var maxf = minf; for (var row = 1; row < rows; row++) {var val = parseInt(rt.getValue(row, colf)); if (val > maxf) maxf = val} frames = maxf;");
// FRAMES = parseInt(FRAMES);

// STEPS = floor(FRAMES / PACKET_SIZE);
// if (STEPS < 2) STEPS = 2;
// MAGNIF = CAM_SIZE / XCORR_SIZE;

// print(" Drift correction: found " + FRAMES + " frames, " + STEPS + " sub-images");

// run("Show results table", "action=drift magnification=" + MAGNIF + " save=false showcorrelations=false method=[Cross correlation] steps=" + STEPS);
run("Show results table", "action=drift magnification=" + MAG + " ccsmoothingbandwidth=" + SM + " save=false showcorrelations=false method=[Cross correlation] steps=" + BIN);
}

if (MERGE == true) {
run("Show results table", "action=merge zcoordweight=0.1 offframes=" + OFF + " dist=" + DIST + " framespermolecule=" + MAXF);
}

if (PHOT_FILT == true){
run("Show results table", "action=filter formula=[intensity>" + PHOT_MIN + " & intensity<" + PHOT_MAX + "]");
}
// run("Show results table", "action=drift magnification=" + MAGNIF + " save=false showcorrelations=false method=[Cross correlation] steps=" + STEPS);
run("Show results table", "action=drift magnification=" + MAG + " ccsmoothingbandwidth=" + SM + " save=false showcorrelations=false method=[Cross correlation] steps=" + BIN);
}

if (MERGE == true) {
run("Show results table", "action=merge zcoordweight=0.1 offframes=" + OFF + " dist=" + DIST + " framespermolecule=" + MAXF);
}

if (PHOT_FILT == true){
run("Show results table", "action=filter formula=[intensity>" + PHOT_MIN + " & intensity<" + PHOT_MAX + "]");
}

if (EXP_FILT == true){
run("Show results table", "action=filter formula=[" + EXP_STRING + "]");
}

if (EXP_FILT == true){
run("Show results table", "action=filter formula=[" + EXP_STRING + "]");
}

if (DENS_FILT == true){
colZ = eval("script", "importClass(Packages.cz.cuni.lf1.lge.ThunderSTORM.results.IJResultsTable); var rt = IJResultsTable.getResultsTable(); var colZ = rt.findColumn(\"z [nm]\");");
if (colZ < 0) DENS_DIM = "2D";
run("Show results table", "action=density neighbors=" + DENS_NUMB + " dimensions=" + DENS_DIM + " radius=" + DENS_RAD);
}

// Export the corrected locs into an output file
if (DENS_FILT == true){
colZ = eval("script", "importClass(Packages.cz.cuni.lf1.lge.ThunderSTORM.results.IJResultsTable); var rt = IJResultsTable.getResultsTable(); var colZ = rt.findColumn(\"z [nm]\");");
if (colZ < 0) DENS_DIM = "2D";
run("Show results table", "action=density neighbors=" + DENS_NUMB + " dimensions=" + DENS_DIM + " radius=" + DENS_RAD);
}

// Export the corrected locs into an output file

// Count the new Loc number
nLocs = eval("script", "importClass(Packages.cz.cuni.lf1.lge.ThunderSTORM.results.IJResultsTable); var rt = IJResultsTable.getResultsTable(); rows = rt.getRowCount();");
nLocK = round(nLocs / 1000);
// OUT_TITLE = replace(OUT_TITLE, "([0-9])+K_", nLocK + "K_");
OUT_TITLE = replace(OUT_TITLE, "_TS", "_" + nLocK + "K_TS");
if (CORR_DRIFT == true) {
OUT_TITLE = replace(OUT_TITLE, "_TS", "_DC_TS");
}

if (TSF == false) {
OUT_PATH = OUTPUT_DIR + OUT_TITLE;
run("Export results", "filepath=[" + OUT_PATH + "] fileformat=[CSV (comma separated)] chi2=false saveprotocol=false");
// remove chi2 that causes an error on 27-07-2017 version (see bug on GitHub)
}
else {
OUT_TITLE = replace(OUT_TITLE, ".csv", ".tsf");
OUT_PATH = OUTPUT_DIR + OUT_TITLE;
run("Export results", "filepath=[" + OUT_PATH + "] fileformat=[Tagged spot file] saveprotocol=false");
}

print(" Output file:" + OUT_TITLE);

// Count the new Loc number
nLocs = eval("script", "importClass(Packages.cz.cuni.lf1.lge.ThunderSTORM.results.IJResultsTable); var rt = IJResultsTable.getResultsTable(); rows = rt.getRowCount();");
nLocK = round(nLocs / 1000);
// OUT_TITLE = replace(OUT_TITLE, "([0-9])+K_", nLocK + "K_");
OUT_TITLE = replace(OUT_TITLE, "_TS", "_" + nLocK + "K_TS");
if (CORR_DRIFT == true) {
OUT_TITLE = replace(OUT_TITLE, "_TS", "_DC_TS");
}

if (TSF == false) {
OUT_PATH = OUTPUT_DIR + OUT_TITLE;
run("Export results", "filepath=[" + OUT_PATH + "] fileformat=[CSV (comma separated)] chi2=false saveprotocol=false");
// remove chi2 that causes an error on 27-07-2017 version (see bug on GitHub)
}
else {
OUT_TITLE = replace(OUT_TITLE, ".csv", ".tsf");
OUT_PATH = OUTPUT_DIR + OUT_TITLE;
run("Export results", "filepath=[" + OUT_PATH + "] fileformat=[Tagged spot file] saveprotocol=false");
}

print(" Output file:" + OUT_TITLE);

// Rename the drift image
if (CORR_DRIFT == true) {
selectWindow("Drift");
rename(OUT_TITLE);
}
// Rename the drift image
if (CORR_DRIFT == true) {
selectWindow("Drift");
rename(OUT_TITLE);
}
}

} // end of IF loop on include/exclude names
} // end of IF loop on extensions
} // end of FOR loop on n extensions

Expand Down
30 changes: 15 additions & 15 deletions Workflow_.ijm
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
MODE_DEF = "Custom";
USE_DRIFT_DEF = true;
BATCH_PROC_DEF = true;
EXC_STRING_DEF = "_ZR_";
EXCL_STRING_DEF = "_ZR_";
CORR_DRIFT_DEF = true;
EXP_STRING_DEF = "intensity>700 & intensity<30000 & detections<5";
EXP_STRING_DEF = "intensity>700 & intensity<100000 & detections<50";
REC_2D_DEF = true;
REC_3D_DEF = true;
SR_SIZE_DEF = 16;
Expand All @@ -28,7 +28,7 @@
Dialog.addCheckbox("Use drift-corrected coordinates", USE_DRIFT_DEF);
Dialog.addMessage("Process localizations options");
Dialog.addCheckbox("Batch process localizations", BATCH_PROC_DEF);
Dialog.addString("Exclude name containing", EXC_STRING_DEF);
Dialog.addString("Exclude name containing", EXCL_STRING_DEF);
Dialog.addCheckbox("Additional drift correction", CORR_DRIFT_DEF);
Dialog.addString("Use filter string", EXP_STRING_DEF, 30);
Dialog.addMessage("Reconstructions options");
Expand All @@ -45,9 +45,9 @@
MODE = Dialog.getChoice();
USE_DRIFT = Dialog.getCheckbox();
BATCH_PROC = Dialog.getCheckbox();
EXC_STRING = Dialog.getString();
if (lengthOf(EXC_STRING)>0) EXC = true;
else EXC = false;
EXCL_STRING = Dialog.getString();
if (lengthOf(EXCL_STRING)>0) EXCL = true;
else EXCL = false;
CORR_DRIFT = Dialog.getCheckbox();
EXP_STRING = Dialog.getString();
if (lengthOf(EXP_STRING)>0) EXP_FILT = true;
Expand All @@ -61,8 +61,8 @@
if (MODE == "STORM") {
USE_DRIFT = true;
BATCH_PROC = true;
EXC = true;
EXC_STRING = "_ZR_";
EXCL = true;
EXCL_STRING = "_ZR_";
CORR_DRIFT = true;
EXP_FILT = true;
EXP_STRING = "intensity>700 & intensity<30000 & detections<5";
Expand All @@ -77,8 +77,8 @@
if (MODE == "PAINT") {
USE_DRIFT = true;
BATCH_PROC = true;
EXC = true;
EXC_STRING = "_ZR_";
EXCL = true;
EXCL_STRING = "_ZR_";
CORR_DRIFT = true;
EXP_FILT = true;
EXP_STRING = "intensity>1500 & intensity<1000000 & detections<100";
Expand All @@ -92,8 +92,8 @@
if (MODE == "to RCC") {
USE_DRIFT = false;
BATCH_PROC = true;
EXC = true;
EXC_STRING = "_ZR_";
EXCL = true;
EXCL_STRING = "_ZR_";
CORR_DRIFT = true;
EXP_FILT = true;
EXP_STRING = "intensity>700 & intensity<30000 & detections<5";
Expand All @@ -118,8 +118,8 @@
// File chooser
CHOOSE = false;
CHOOSE_STRING = "";
// EXC = true;
// EXC_STRING = "_ZR_";
// EXCL = true;
// EXCL_STRING = "_ZR_";
// Drift correction
// CORR_DRIFT = true;
BIN = 12; // number of frames per sub-reconstruction used for autocorrelation
Expand Down Expand Up @@ -177,7 +177,7 @@
// Optional Batch Proc
if (BATCH_PROC == true) {
BatchProc_path = plugin_path + File.separator + "NeuroCyto Lab" + File.separator + "ChriSTORM" + File.separator + "Process locs files (batch)" + File.separator+ "Batch_Process_Locs.ijm";
BatchProc_args = out_path + "," + CHOOSE + "," + CHOOSE_STRING + "," + EXC + "," + EXC_STRING + "," + CORR_DRIFT + "," + BIN + "," + MAG + "," + SM + "," + MERGE + "," + DIST + "," + MAXF + "," + OFF + "," + PHOT_FILT + "," + PHOT_MIN + "," + PHOT_MAX + "," + EXP_FILT + "," + EXP_STRING + "," + DENS_FILT + "," + DENS_RAD + "," + DENS_NUMB + "," + DENS_DIM + "," + TSF;
BatchProc_args = out_path + "," + CHOOSE + "," + CHOOSE_STRING + "," + EXCL + "," + EXCL_STRING + "," + CORR_DRIFT + "," + BIN + "," + MAG + "," + SM + "," + MERGE + "," + DIST + "," + MAXF + "," + OFF + "," + PHOT_FILT + "," + PHOT_MIN + "," + PHOT_MAX + "," + EXP_FILT + "," + EXP_STRING + "," + DENS_FILT + "," + DENS_RAD + "," + DENS_NUMB + "," + DENS_DIM + "," + TSF;
out_path = runMacro(BatchProc_path, BatchProc_args);
}

Expand Down

0 comments on commit b66efa6

Please sign in to comment.