NOTICE! This is a static HTML version of a legacy Fiji BugZilla bug.

The Fiji project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Bug 1003 - Array.rankPositions does not order positions correctly
Array.rankPositions does not order positions correctly
Status: RESOLVED WONTFIX
Product: Fiji
Classification: Unclassified
Component: Plugins
unspecified
PC Windows
: P4 normal
Assigned To: ImageJ Bugs Mailing List
Depends on:
Blocks:
 
Reported: 2015-02-11 17:29 CST by tokamoto
Modified: 2015-02-12 15:45 CST
2 users (show)

See Also:

Description tokamoto 2015-02-11 17:29:14 CST
Running ImageJ version 1.49o.  I'm trying to sort multiple arrays only in relation to one of the arrays.  Need to have the rank of that one array, so I can sort all of them.  Tested the Array.rankPositions function, but it doesn't output the right rankings.  Below is the small test macro I used, and below that is the output.

test = newArray(15, 10, 50, 20, 40, 1, 2, 3);
new = Array.rankPositions(test);
Array.show(test, new);

output is:
test  new
15  5
10  6
50  7
20  1
40  0
1  3
2  4
3  2

Information about your version of Java:

  os.arch => amd64
  os.name => Windows 7
  os.version => 6.1
  java.version => 1.6.0_24
  java.vendor => New Oracle
  java.runtime.name => Java(TM) SE Runtime Environment
  java.runtime.version => 1.6.0_24-b07
  java.vm.name => Java HotSpot(TM) 64-Bit Server VM
  java.vm.version => 19.1-b02
  java.vm.vendor => Sun Microsystems Inc.
  java.vm.info => mixed mode
  java.awt.graphicsenv => sun.awt.Win32GraphicsEnvironment
  java.specification.name => Java Platform API Specification
  java.specification.version => 1.6
  sun.cpu.endian => little
  sun.desktop => windows
  file.separator => \

The up-to-date check says: CHECK_TURNED_OFF

Information relevant to JAVA_HOME related problems:

  JAVA_HOME is set to: C:\Fiji.app/java/win64/jdk1.6.0_24//jre
  imagej.dir => C:\Fiji.app

Information about the version of each plugin:

Activated update sites:
ImageJ: http://update.imagej.net/ (last check:20150122024514)
Fiji: http://fiji.sc/update/ (last check:20150203080057)

Files not up-to-date:
  772f7227 (MODIFIED) 20150203100028 jars/ij-1.49m.jar
  1ad3be0d (LOCAL_ONLY) 20150107090442 jars/jpedalSTD.jar
  6ddc36e4 (LOCAL_ONLY) 20150127113614 macros/Individual/SNR.ijm
  7e29c562 (LOCAL_ONLY) 20150109131628 macros/Individual/Startup/StartupMacros.fiji.ijm
  43ce2fa9 (LOCAL_ONLY) 20150127113919 macros/Individual/automerge.ijm
  ed5b891e (LOCAL_ONLY) 20150109133039 macros/Individual/autominmaxtif.ijm
  23985b42 (LOCAL_ONLY) 20150127114211 macros/Individual/cellSNR.ijm
  bf227d21 (LOCAL_ONLY) 20150127114005 macros/Individual/openzproject.ijm
  3e3bcc64 (LOCAL_ONLY) 20150127114054 macros/Individual/regexmerge.ijm
  c86dc415 (MODIFIED) 20150209134941 macros/StartupMacros.fiji.ijm
  9305cb25 (LOCAL_ONLY) 20150123160923 plugins/NicoIJPlugins_.jar
  a5f48127 (LOCAL_ONLY) 20150123160730 plugins/TSFProto.jar
  e5789fc6 (LOCAL_ONLY) 20150123160727 plugins/commons-math-2.0.jar
  7c3684b3 (LOCAL_ONLY) 20150123160732 plugins/gproto.jar
  5e62e842 (LOCAL_ONLY) 20150123160725 plugins/jcommon-1.0.16.jar
  f38a3c3b (LOCAL_ONLY) 20150123160712 plugins/jfreechart-1.0.13.jar
  569c5489 (LOCAL_ONLY) 20141120221500 plugins/mcib3d-core3.0.jar
  1979e4e6 (LOCAL_ONLY) 20141120234754 plugins/mcib3d_plugins3.0.jar
  8cb8d89b (LOCAL_ONLY) 20120924071500 plugins/quickhull3d.jar
Comment 1 Wayne Rasband 2015-02-11 19:06:13 CST
This is the expected behavior. The rankPositions() function returns the rank positions as indexes, starting with index of smallest value. Get the rank positions of the indexes to get the ranks. Here is an example:

  test = newArray(15, 10, 50, 20, 40, 1, 2, 3);
  rank_pos = Array.rankPositions(test);
  rank = Array.rankPositions(rank_pos);
  Array.show(test, rank_pos, rank);

And here is the output:


 test  rank_pos  rank
 155     5        4
 10      6        3
 50      7        7
 20      1        5
 40      0        6
 1       3        0
 2       4        1
 3       2        2
Comment 2 tokamoto 2015-02-12 15:45:00 CST
Thanks for the clarification.  I got mixed up when reading the description, but it makes sense now.