Commit 2a2a7ccf authored by Andrey Filippov's avatar Andrey Filippov

debugging recurrent layer

parent 2eb14ba0
...@@ -171,7 +171,7 @@ public class CuasDetectRT { ...@@ -171,7 +171,7 @@ public class CuasDetectRT {
int curt_vel_suppr_rad =clt_parameters.imp.curt_vel_suppr_rad; int curt_vel_suppr_rad =clt_parameters.imp.curt_vel_suppr_rad;
double curt_vel_athresh = clt_parameters.imp.curt_vel_athresh; double curt_vel_athresh = clt_parameters.imp.curt_vel_athresh;
double curt_vel_rthresh = clt_parameters.imp.curt_vel_rthresh; double curt_vel_rthresh = clt_parameters.imp.curt_vel_rthresh;
double curt_vel_dbg_min = clt_parameters.imp.curt_vel_dbgmin; // temporary, testing with strong targets, make clean background
boolean curt_recur_en = clt_parameters.imp.curt_recur_en; // By Claude on 06/09/2026 boolean curt_recur_en = clt_parameters.imp.curt_recur_en; // By Claude on 06/09/2026
int curt_recur_period = clt_parameters.imp.curt_recur_period; // By Claude on 06/09/2026 int curt_recur_period = clt_parameters.imp.curt_recur_period; // By Claude on 06/09/2026
double curt_recur_w = clt_parameters.imp.curt_recur_w; // By Claude on 06/09/2026 double curt_recur_w = clt_parameters.imp.curt_recur_w; // By Claude on 06/09/2026
...@@ -316,7 +316,8 @@ public class CuasDetectRT { ...@@ -316,7 +316,8 @@ public class CuasDetectRT {
"-A1_"+d2s(alpha1)+ "-A1_"+d2s(alpha1)+
"-NH"+num_hist_5d+ "-NH"+num_hist_5d+
"-VR"+curt_vel_radius+"-VD"+curt_vel_decimate+"-MF"+min_frac_last+ "-VR"+curt_vel_radius+"-VD"+curt_vel_decimate+"-MF"+min_frac_last+
"-TE"+(curt_vel_thresh_en?"1":"0") + "-TA"+curt_vel_athresh + "-TR"+curt_vel_rthresh+"-SR"+curt_vel_suppr_rad; "-TE"+(curt_vel_thresh_en?"1":"0") + "-TA"+curt_vel_athresh + "-TR"+curt_vel_rthresh+
"-SR"+curt_vel_suppr_rad+"-D"+curt_vel_dbg_min;
// Level-0 5D convolution (fine velocity from coarse-velocity history) // Level-0 5D convolution (fine velocity from coarse-velocity history)
int num_5d_lev0 = Math.max(0, dpixels_3d3.length - num_hist_5d + 1); int num_5d_lev0 = Math.max(0, dpixels_3d3.length - num_hist_5d + 1);
dpixels_5d_pyramid[0] = new double[num_5d_lev0][][][]; dpixels_5d_pyramid[0] = new double[num_5d_lev0][][][];
...@@ -345,7 +346,11 @@ public class CuasDetectRT { ...@@ -345,7 +346,11 @@ public class CuasDetectRT {
} // By Claude on 06/09/2026 } // By Claude on 06/09/2026
System.out.println("detectTargets(): will run convolve3d()"); System.out.println("detectTargets(): will run convolve3d()");
for (int n5d = 0; n5d < num_5d_lev0; n5d++) { for (int n5d = 0; n5d < num_5d_lev0; n5d++) {
System.out.print ("n5d="+n5d+" "); double tmp_min=curt_vel_dbg_min;
if ((n5d == 0) || (n5d == 8) || (n5d == 12) || (n5d == 16)) { // disabling outputs for certain timestamps for debugging
tmp_min = 1000;
}
System.out.print ("n5d="+n5d+":"+tmp_min+" ");
double[][][] window = new double[num_hist_5d][][]; double[][][] window = new double[num_hist_5d][][];
for (int h = 0; h < num_hist_5d; h++) { for (int h = 0; h < num_hist_5d; h++) {
window[h] = dpixels_3d3[n5d + num_hist_5d - 1 - h]; window[h] = dpixels_3d3[n5d + num_hist_5d - 1 - h];
...@@ -368,7 +373,8 @@ public class CuasDetectRT { ...@@ -368,7 +373,8 @@ public class CuasDetectRT {
dpixels_5d_roi_pyramid[0][n5d], dpixels_5d_roi_pyramid[0][n5d],
curt_save_select, curt_save_select,
curt_vel_athresh, curt_vel_athresh,
curt_vel_rthresh); curt_vel_rthresh,
tmp_min); // curt_vel_dbg_min); // final double dbg_min) { // zero if below, for testing with strong signals
} }
if (run_recur && ((n5d % curt_recur_period) == 0)) { // By Claude on 06/09/2026 if (run_recur && ((n5d % curt_recur_period) == 0)) { // By Claude on 06/09/2026
recurrentBuffer.update( // By Claude on 06/09/2026 recurrentBuffer.update( // By Claude on 06/09/2026
...@@ -411,7 +417,7 @@ public class CuasDetectRT { ...@@ -411,7 +417,7 @@ public class CuasDetectRT {
String title_recur = title_conv5d+ // By Claude on 06/09/2026 String title_recur = title_conv5d+ // By Claude on 06/09/2026
"-RP"+curt_recur_period+"-RW"+d2s(curt_recur_w)+"-RL"+d2s(curt_recur_leak)+ // By Claude on 06/09/2026 "-RP"+curt_recur_period+"-RW"+d2s(curt_recur_w)+"-RL"+d2s(curt_recur_leak)+ // By Claude on 06/09/2026
"-RWT"+d2s(curt_recur_wthresh)+"-RS"+d2s(curt_recur_spread)+ // By Claude on 06/09/2026 "-RWT"+d2s(curt_recur_wthresh)+"-RS"+d2s(curt_recur_spread)+ // By Claude on 06/09/2026
"-RC"+curt_recur_max_clust+SUFFIX_RECUR; // By Claude on 06/09/2026 "-RC"+curt_recur_max_clust+SUFFIX_RECUR+"-D"+curt_vel_dbg_min; // By Claude on 06/09/2026
ImagePlus imp_recur_rect = cuasRTUtils.showConvKernel5d( // By Claude on 06/09/2026 ImagePlus imp_recur_rect = cuasRTUtils.showConvKernel5d( // By Claude on 06/09/2026
recur_show, // By Claude on 06/09/2026 recur_show, // By Claude on 06/09/2026
curt_save_select, // By Claude on 06/09/2026 curt_save_select, // By Claude on 06/09/2026
...@@ -501,7 +507,8 @@ public class CuasDetectRT { ...@@ -501,7 +507,8 @@ public class CuasDetectRT {
dpixels_5d_roi_pyramid[nlev+1][n5d], dpixels_5d_roi_pyramid[nlev+1][n5d],
curt_save_select, curt_save_select,
curt_vel_athresh, curt_vel_athresh,
curt_vel_rthresh); curt_vel_rthresh,
curt_vel_dbg_min); // final double dbg_min) { // zero if below, for testing with strong signals
} }
} }
ts_5d_lev[n5d] = ts_pyramid[nlev+1][n5d + num_hist_5d - 1]; ts_5d_lev[n5d] = ts_pyramid[nlev+1][n5d + num_hist_5d - 1];
......
...@@ -1518,13 +1518,15 @@ public class CuasRTUtils { ...@@ -1518,13 +1518,15 @@ public class CuasRTUtils {
* @param roi pixel rectangle (full-image coordinates) * @param roi pixel rectangle (full-image coordinates)
* @param athresh absolute threshold: M must reach this for suppression to activate * @param athresh absolute threshold: M must reach this for suppression to activate
* @param rthresh relative threshold: val/M below this → zeroed (e.g. 0.5) * @param rthresh relative threshold: val/M below this → zeroed (e.g. 0.5)
* @param dbg_min debug feature - zero if weaker to test recurrent with strong targets
* @return new filtered array, same shape as data * @return new filtered array, same shape as data
*/ */
public double [][][] filterConv5dROI( public double [][][] filterConv5dROI(
final double [][][] data, final double [][][] data,
final Rectangle roi, final Rectangle roi,
final double athresh, final double athresh,
final double rthresh) { final double rthresh,
final double dbg_min) { // zero if below, for testing with strong signals
final int num_vout = kernel5d[0].length; final int num_vout = kernel5d[0].length;
final int vout_dim = (int) Math.sqrt(num_vout); final int vout_dim = (int) Math.sqrt(num_vout);
final int num_sub = kernel5d[0][0].length; final int num_sub = kernel5d[0][0].length;
...@@ -1566,7 +1568,7 @@ public class CuasRTUtils { ...@@ -1566,7 +1568,7 @@ public class CuasRTUtils {
} }
} }
double thresh = Math.max(athresh, M * rthresh); double thresh = Math.max(athresh, M * rthresh);
result[roi_pix][sub_idx][v_out_idx] = ((M - val) >= thresh) ? 0 : val; result[roi_pix][sub_idx][v_out_idx] =((val < dbg_min) || ((M - val) >= thresh)) ? 0 : val;
} }
} }
} }
...@@ -1609,7 +1611,7 @@ public class CuasRTUtils { ...@@ -1609,7 +1611,7 @@ public class CuasRTUtils {
} }
} }
double thresh = Math.max(athresh, M * rthresh); double thresh = Math.max(athresh, M * rthresh);
result[roi_pix][sub_idx][v_out_idx] = ((M - val) >= thresh) ? 0 : val; result[roi_pix][sub_idx][v_out_idx] =((val < dbg_min) || ((M - val) >= thresh)) ? 0 : val;
} }
} }
} }
......
...@@ -1148,6 +1148,7 @@ min_str_neib_fpn 0.35 ...@@ -1148,6 +1148,7 @@ min_str_neib_fpn 0.35
public int curt_vel_suppr_rad = 3; // suppress weaker in this radius public int curt_vel_suppr_rad = 3; // suppress weaker in this radius
public double curt_vel_athresh = 1.0; // absolute threshold: discard this pixel-velocity if it has immediate neighbor (of 80=81-1) stronger by this value public double curt_vel_athresh = 1.0; // absolute threshold: discard this pixel-velocity if it has immediate neighbor (of 80=81-1) stronger by this value
public double curt_vel_rthresh = 0.1; // relative threshold: discard this pixel-velocity if it has immediate neighbor stronger by this value times stronger value public double curt_vel_rthresh = 0.1; // relative threshold: discard this pixel-velocity if it has immediate neighbor stronger by this value times stronger value
public double curt_vel_dbgmin = 0.0; // For testing recurrent with strong targets, zero out lower values
public double[] curt_temp_weights = {1,1,1,1,1}; // historic weights for 5D convolution ([0] is the latest sample) public double[] curt_temp_weights = {1,1,1,1,1}; // historic weights for 5D convolution ([0] is the latest sample)
// === Layer 2 recurrent accumulation buffer === // By Claude on 06/09/2026 // === Layer 2 recurrent accumulation buffer === // By Claude on 06/09/2026
public boolean curt_recur_en = true; // enable recurrent accumulation buffer (Layer 2) // By Claude on 06/09/2026 public boolean curt_recur_en = true; // enable recurrent accumulation buffer (Layer 2) // By Claude on 06/09/2026
...@@ -3430,6 +3431,10 @@ min_str_neib_fpn 0.35 ...@@ -3430,6 +3431,10 @@ min_str_neib_fpn 0.35
"Discard this pixel-velocity if it has immediate neighbor (of 80=81-1) stronger by this valuediscard this pixel-velocity if it has immediate neighbor (of 80=81-1) stronger by this value."); "Discard this pixel-velocity if it has immediate neighbor (of 80=81-1) stronger by this valuediscard this pixel-velocity if it has immediate neighbor (of 80=81-1) stronger by this value.");
gd.addNumericField("Relative thershold", this.curt_vel_rthresh, 6,8,"", gd.addNumericField("Relative thershold", this.curt_vel_rthresh, 6,8,"",
"Discard this pixel-velocity if it has immediate neighbor stronger by this value times stronger value."); "Discard this pixel-velocity if it has immediate neighbor stronger by this value times stronger value.");
gd.addNumericField("Remove weaker velocities", this.curt_vel_dbgmin, 6,8,"",
"Debug feature for testing recurrent with strong targets - zero out weaker (set 10.0).");
gd.addStringField ("Historic weight for 5D convolution", IntersceneMatchParameters.doublesToString(curt_temp_weights), 80, gd.addStringField ("Historic weight for 5D convolution", IntersceneMatchParameters.doublesToString(curt_temp_weights), 80,
"Historic weights for 5D convolution ([0] is the latest sample). Will be normalized"); "Historic weights for 5D convolution ([0] is the latest sample). Will be normalized");
...@@ -4951,7 +4956,7 @@ min_str_neib_fpn 0.35 ...@@ -4951,7 +4956,7 @@ min_str_neib_fpn 0.35
this.curt_vel_suppr_rad = (int) gd.getNextNumber(); this.curt_vel_suppr_rad = (int) gd.getNextNumber();
this.curt_vel_athresh = gd.getNextNumber(); this.curt_vel_athresh = gd.getNextNumber();
this.curt_vel_rthresh = gd.getNextNumber(); this.curt_vel_rthresh = gd.getNextNumber();
this.curt_vel_dbgmin = gd.getNextNumber();
this.curt_temp_weights = IntersceneMatchParameters. StringToDoubles(gd.getNextString(), 0); this.curt_temp_weights = IntersceneMatchParameters. StringToDoubles(gd.getNextString(), 0);
this.curt_recur_en = gd.getNextBoolean(); // By Claude on 06/09/2026 this.curt_recur_en = gd.getNextBoolean(); // By Claude on 06/09/2026
...@@ -6290,6 +6295,7 @@ min_str_neib_fpn 0.35 ...@@ -6290,6 +6295,7 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"curt_vel_suppr_rad", this.curt_vel_suppr_rad+""); // int properties.setProperty(prefix+"curt_vel_suppr_rad", this.curt_vel_suppr_rad+""); // int
properties.setProperty(prefix+"curt_vel_athresh", this.curt_vel_athresh+""); // double properties.setProperty(prefix+"curt_vel_athresh", this.curt_vel_athresh+""); // double
properties.setProperty(prefix+"curt_vel_rthresh", this.curt_vel_rthresh+""); // double properties.setProperty(prefix+"curt_vel_rthresh", this.curt_vel_rthresh+""); // double
properties.setProperty(prefix+"curt_vel_dbgmin", this.curt_vel_dbgmin+""); // double
properties.setProperty(prefix+"curt_temp_weights", IntersceneMatchParameters.doublesToString(this.curt_temp_weights)); properties.setProperty(prefix+"curt_temp_weights", IntersceneMatchParameters.doublesToString(this.curt_temp_weights));
properties.setProperty(prefix+"curt_recur_en", this.curt_recur_en+""); // boolean // By Claude on 06/09/2026 properties.setProperty(prefix+"curt_recur_en", this.curt_recur_en+""); // boolean // By Claude on 06/09/2026
...@@ -7614,6 +7620,7 @@ min_str_neib_fpn 0.35 ...@@ -7614,6 +7620,7 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"curt_vel_suppr_rad")!=null) this.curt_vel_suppr_rad=Integer.parseInt(properties.getProperty(prefix+"curt_vel_suppr_rad")); if (properties.getProperty(prefix+"curt_vel_suppr_rad")!=null) this.curt_vel_suppr_rad=Integer.parseInt(properties.getProperty(prefix+"curt_vel_suppr_rad"));
if (properties.getProperty(prefix+"curt_vel_athresh")!=null) this.curt_vel_athresh=Double.parseDouble(properties.getProperty(prefix+"curt_vel_athresh")); if (properties.getProperty(prefix+"curt_vel_athresh")!=null) this.curt_vel_athresh=Double.parseDouble(properties.getProperty(prefix+"curt_vel_athresh"));
if (properties.getProperty(prefix+"curt_vel_rthresh")!=null) this.curt_vel_rthresh=Double.parseDouble(properties.getProperty(prefix+"curt_vel_rthresh")); if (properties.getProperty(prefix+"curt_vel_rthresh")!=null) this.curt_vel_rthresh=Double.parseDouble(properties.getProperty(prefix+"curt_vel_rthresh"));
if (properties.getProperty(prefix+"curt_vel_dbgmin")!=null) this.curt_vel_dbgmin=Double.parseDouble(properties.getProperty(prefix+"curt_vel_dbgmin"));
if (properties.getProperty(prefix+"curt_temp_weights")!=null) this.curt_temp_weights= IntersceneMatchParameters.StringToDoubles(properties.getProperty(prefix+"curt_temp_weights"),0); // use 0 if (properties.getProperty(prefix+"curt_temp_weights")!=null) this.curt_temp_weights= IntersceneMatchParameters.StringToDoubles(properties.getProperty(prefix+"curt_temp_weights"),0); // use 0
...@@ -8916,6 +8923,7 @@ min_str_neib_fpn 0.35 ...@@ -8916,6 +8923,7 @@ min_str_neib_fpn 0.35
imp.curt_vel_suppr_rad = this.curt_vel_suppr_rad; imp.curt_vel_suppr_rad = this.curt_vel_suppr_rad;
imp.curt_vel_athresh = this.curt_vel_athresh; imp.curt_vel_athresh = this.curt_vel_athresh;
imp.curt_vel_rthresh = this.curt_vel_rthresh; imp.curt_vel_rthresh = this.curt_vel_rthresh;
imp.curt_vel_dbgmin = this.curt_vel_dbgmin;
imp.curt_temp_weights = this.curt_temp_weights.clone(); imp.curt_temp_weights = this.curt_temp_weights.clone();
imp.curt_recur_en = this.curt_recur_en; // By Claude on 06/09/2026 imp.curt_recur_en = this.curt_recur_en; // By Claude on 06/09/2026
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment