Changeset 7795 for trunk/projects/slimplugin/src/main/java/loci
 Timestamp:
 10/28/11 14:08:36 (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/projects/slimplugin/src/main/java/loci/slim/CursorHelper.java
r7672 r7795 334 334 return returnValue; 335 335 } 336 337 /** 338 * Calculates the Z background value looking at the prepulse 339 * part of the decay curve. 340 * (Based on calcBgFromPrepulse in TRfitting.c 341 * @param prepulse 342 * @param n 343 * @return 344 */ 345 private static float calcBgFromPrepulse(float[] prepulse, int n) { 346 float z = 0.0f; 347 348 if (z > 0) { 349 float val = 0.0f; 350 for (int i = 0; i <n; ++i) { 351 val += prepulse[i]; 352 } 353 z = val/n; 354 } 355 return z; 356 } 357 358 /** 359 * "Get initial estimates for the params that go forward to Marquardt". 360 * (Based on expParameterEstimation from TRfitting.c.) 361 * 362 * @return 363 */ 364 public static float[] estimateParameters(boolean useRLD, 365 boolean useBackground, 366 float[] trans, 367 int transFitStartIndex, 368 int transStartIndex, 369 int transEndIndex) { 370 float a, t, z; 371 372 // initialize 373 a = 1000.0f; 374 t = 2.0f; 375 z = 0.0f; 376 377 if (useRLD) { 378 transFitStartIndex = findMax(trans, transFitStartIndex, transEndIndex); 379 //TODO ARG do a RLD fit using trans, transFitStartIndex, transStartIndex, transEndIndex 380 // see wiki entry "expParameterEstimation from TRfitting.c" 381 // note that the prompt is disregarded here 382 int returnValue = 1; 383 if (returnValue >= 0) { 384 a = t = z = 0.0f; 385 } 386 } 387 else if (useBackground) { 388 z = calcBgFromPrepulse(trans, transStartIndex); 389 } 390 391 return new float[] { z, a, t }; 392 } 336 393 337 394 private static int findMax(float[] values) { 338 return findMax(values, values.length);395 return findMax(values, 0, values.length); 339 396 } 340 397 341 398 private static int findMax(float[] values, int endIndex) { 342 int index = 0; 343 float max = 0.0f; 344 for (int i = 0; i < endIndex; ++i) { 399 return findMax(values, 0, endIndex); 400 } 401 402 private static int findMax(float[] values, int startIndex, int endIndex) { 403 int index = startIndex; 404 float max = values[startIndex]; 405 for (int i = startIndex; i < endIndex; ++i) { 345 406 if (values[i] > max) { 346 407 max = values[i]; … … 352 413 353 414 private static int findMin(float[] values, int endIndex) { 354 int index = 0; 355 float min = Float.MAX_VALUE; 356 for (int i = 0; i < endIndex; ++i) { 415 return findMin(values, 0, endIndex); 416 } 417 418 private static int findMin(float[] values, int startIndex, int endIndex) { 419 int index = startIndex; 420 float min = values[startIndex]; 421 for (int i = startIndex; i < endIndex; ++i) { 357 422 if (values[i] < min) { 358 423 min = values[i];
Note: See TracChangeset
for help on using the changeset viewer.