Login  Register

Re: sorting bug in ij.plugin.FolderOpener?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: sorting bug in ij.plugin.FolderOpener?

Walter O'Dell PhD
12 posts
well I just spent a couple hours in the code to uncover the problem mentioned in this thread from 2007. Basically, I had a list of files, say
firstfile.jpg   and
secondfile2.jpg.

FolderOpener displays the 2 file in this order, so I select to read in just 1 file, starting at 1 and skipping none, and the program then opens the second file.  In the sorter program within FolderOpener the first file name gets changed to 000000000aaaaaafirstfile.jpg, while the second file gets changed to 000000000000002secondfile2.jpg.  And the latter file name then is higher alphanumerically than the first.

My personal solution is to set sortFileNames = false, within FolderOpener.java.  Since I have changed several of the base ImageJ files and compile everything from scratch anyway, this works for me.

The casual user won't know to write their own version of the sorter function, and won't understand that what is shown in the selection display is not what folderOpener is working with.  

My recommendation is to either have the sort routine applied before the list of files is displayed in the selection GUI so that the display matches what will be selected, or use the same sorter inside FolderOpener that the machine uses for the display, or make the default sortFileNames = false and let the powerusers turn it On if they feel the need for it.

have a nice day.

-Walter

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: sorting bug in ij.plugin.FolderOpener?

Michael Schmid
2136 posts
Hi Walter,

sorry, I don't fully understand your problem.

When sorting by name or sorting numerically, the sequence will always be
  firstfile.jpg
  secondfile2.jpg
Even the files
  firstfile2.jpg
  secondfile1.jpg
get always sorted alphanumerically (sequence as above, irrespective of the descending number).

There is a difference between the sorting sequences with
  2isTheSecond.jpg
  12isTheTwelth.jpg
where sorting by name results in the reverse sequence (in the dialog, Mac OSX sorts it numerically anyhow, not strictly by name, Windows seems to sort it strictly by name).

Concerning the sequence shown by the file opener dialog box: This highly depends on the operating system. On most operating systems you can select whether the list of files should be sorted by name or modification date/time, ascending or descending. As far as I know, you can't tell Java which sequence to present in the dialog, and you can't read the sequence chosen by the user from Java.

Are you using the FolderOpener in a Plugin?
There is a public method
  public void FolderOpener.sortFileNames(boolean b)
I think that this one is supposed to change the behavior if you call FolderOpener from a plugin; but I have the impression that it would not work (I have not tried): Unless when running a macro, it seems that always the staticSortFileNames variable is used, but the sortFileNames method sets the non-static one. If my suspicion is correct, this could be (and should be) fixed.

If it's the user interface of 'File>Import>Image Sequence' that you talk about: The only way that I see to help the user would be displaying the first and maybe last filename, above or below the line giving the size and number of images. If there are more users who have a problem here, it might be worthwhile. When doing it, one must not forget to circumvent the infamous Mac OS X bug, which will delay the update of the text in the dialog (adding a 100ms-delay before doing the last setText operation).

So far my 3 cents,

Michael
________________________________________________________________
On Feb 4, 2013, at 22:18, Walter O'Dell PhD wrote:

> well I just spent a couple hours in the code to uncover the problem mentioned in this thread from 2007. Basically, I had a list of files, say
> firstfile.jpg   and
> secondfile2.jpg.
>
> FolderOpener displays the 2 file in this order, so I select to read in just 1 file, starting at 1 and skipping none, and the program then opens the second file.  In the sorter program within FolderOpener the first file name gets changed to 000000000aaaaaafirstfile.jpg, while the second file gets changed to 000000000000002secondfile2.jpg.  And the latter file name then is higher alphanumerically than the first.
>
> My personal solution is to set sortFileNames = false, within FolderOpener.java.  Since I have changed several of the base ImageJ files and compile everything from scratch anyway, this works for me.
>
> The casual user won't know to write their own version of the sorter function, and won't understand that what is shown in the selection display is not what folderOpener is working with.  
>
> My recommendation is to either have the sort routine applied before the list of files is displayed in the selection GUI so that the display matches what will be selected, or use the same sorter inside FolderOpener that the machine uses for the display, or make the default sortFileNames = false and let the powerusers turn it On if they feel the need for it.
>
> have a nice day.
>
> -Walter
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html