Login  Register

Re: sorting bug in ij.plugin.FolderOpener?

Posted by Wayne Rasband on Mar 23, 2007; 10:05pm
URL: http://imagej.273.s1.nabble.com/sorting-bug-in-ij-plugin-FolderOpener-tp3699965p3699967.html

> I've noticed the same problem, and I know it has to do with how the
> ij.plugin.FolderOpener sorts the file list whenever any of the file
> names are not of equal length.
>
> What the ij.plugin.FolderOpener does is to prepend zeros to the file
> name whenever it is shorter than the longest file name, which then
> when applying the ij.util.StringSorter, will result in very unexpected
> sortings.

File>Import>Image Sequence correctly sorts names of unequal length as
long is each name contains only one number. For example, the names

a14.jpg
aa202.jpg
aaa201.jpg
aaaaaa2.jpg

will be correctly sorted in numeric order. This works because ImageJ
prepends zeros only after removing all non-numeric characters. What it
can't handle is file names that are not of equal length and that also
contain more than one number. This is because the digits from all the
numbers in the name are combined to form a single number that is
sorted.

> I always work it around by either making special plugins that read the
> listing numbers specifically in the file name, putting them in a
> Hashtable and then sorting the table by its keys; or by copying
> FolderOpener code, modifying the class name and modifying the
> sortFileList method.
>
> All this hassle could be easily solved by making the sortFileList
> method public in ij.plugin.FolderOpener, which would allow to create
> very simplified extended versions of this class.

The sortFileList() method in the FolderOpener class is public in ImageJ
1.38.

-wayne