jiaxuanleong / SPIRO.Assays

ImageJ macros written to analyse data acquired by SPIRO imaging
BSD 2-Clause "Simplified" License
3 stars 0 forks source link

Random order of preprocessed photos in the image stack file #22

Open Stramon1um opened 2 years ago

Stramon1um commented 2 years ago

Hi,

thanks for this marvelous system!

I have been trying to preprocess the photos of the plates using the SPIRO_preprocessing macro, but I always get a stack file in which the photos are not chronologically ordered as I guess they should, like for instance from the oldest to the newest. I don't have any errors during the process and the photos are all right.

The tricky part comes afterwards (for seed germination or root growth), where you might need to select a specific range of photos and without any reasonable order, it always becomes very difficult to find the proper photos in al this mix.

May this be an issue only for me or is it normal? I even tried to preprocess very small amount of photos, but nothing changed.

I'm using Fiji on a Debian-based distribution (PopOS).

Thanks in advance for any support ;)

jiaxuanleong commented 2 years ago

Hi! It sounds like you have your files sorted in your system in another way from "Name" in ascending order. I did not account for this, but have now updated the preprocessing macro automatically sort the files during indexing. Please try the newest update (02.03.22) of SPIRO_Assays.ijm now and let me know if this fixes your problem.

Stramon1um commented 2 years ago

Thanks! Tomorrow I will give it a try ;)

Stramon1um commented 2 years ago

Hi, I tried a couple of times with the new macro but it didn't fix the problem, they are still "randomly" ordered.

Any suggestions?

Thanks

jiaxuanleong commented 2 years ago

Hi! I have only a temporary fix now. After letting Preprocessing run, could you please open one of your XXX_preprocessed file? With the stack displayed in ImageJ, you can go to Image > Stacks > Tools > Stack Sorter and use the "Sort by Label" function, then overwrite the file with this sorted stack. With this you should be able to progress to the next steps of analysis.

It's a bit annoying for now to manually do this for each preprocessed stack. I tried to implement it in the macro for you but ran into some problems where the Stack Sorter did not recognize there is a stack, when called from within a macro. I'll find a workaround for this soon.

Stramon1um commented 2 years ago

Yes, in this way it works!

For the few number of tests I'm going to run in the next days this workaround is more than fine, thanks ;)

Do yo think this issue might be related to my Linux system in a way?

jiaxuanleong commented 2 years ago

From my few Google searches, it seems like Linux system also returns files (for example with the ls command) in alphanumeric order, so I doubt Linux itself is to blame here. A few questions to satisfy my curiousity and also maybe point us towards what might be causing this:

jonasoh commented 2 years ago

Different filesystems will return files in different orders to the programs requesting them (e.g., ls or ImageJ). In simple terms, the program requests a list of files from the operating system/filesystem, and, depending on the system, the ordering of that list will differ. It may be that the system in question returns the files in the order they were written to disk, alphanumerically sorted, or sorted by some internal representation. The program can then decide what to do about the ordering (such as sort them alphanumerically, as is the case for ls in its default mode).

It may be the case that ImageJ simply respects the filesystem ordering in this case, and that differences in how Linux vs MacOS/Windows filesystems work explains why the ordering is different.

Stramon1um commented 2 years ago

From my few Google searches, it seems like Linux system also returns files (for example with the ls command) in alphanumeric order, so I doubt Linux itself is to blame here. A few questions to satisfy my curiousity and also maybe point us towards what might be causing this:

  • Does the "random" file order in your stack reflect what you see when you open the folder, in file explorer?
  • When you import an image sequence manually in ImageJ, for example with File > Import > Image Sequence and check "sort names numerically" , does it produce a stack sorted as expected?
  • Is this order of the stack different from unchecking the "sort names numerically"?

Hi, I checked each point you listed, so:

Different filesystems will return files in different orders to the programs requesting them (e.g., ls or ImageJ). In simple terms, the program requests a list of files from the operating system/filesystem, and, depending on the system, the ordering of that list will differ. It may be that the system in question returns the files in the order they were written to disk, alphanumerically sorted, or sorted by some internal representation. The program can then decide what to do about the ordering (such as sort them alphanumerically, as is the case for ls in its default mode).

It may be the case that ImageJ simply respects the filesystem ordering in this case, and that differences in how Linux vs MacOS/Windows filesystems work explains why the ordering is different.

I also tried ls in the same folder and it prompts the list of files properly ordered as I see with any file manager.

Thanks again for the quick and fast support ;)