Sort order in Virtual Stack Opener

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Sort order in Virtual Stack Opener

Divakar Ramachandran
Is there a way to change the sort order in the Virtual stack opene
Hi,

Is there a way to change the sort order in the Virtual stack opener plugin? I have image files with names like A.1, A.2 etc., running typically to hundreds of images. When I open the images  as a stack using the virtual stack opener, the stack order is alphabetical, like A.1, A.10, A.100, A.101 etc. instead of the numerical order.

Thanks,
Divakar


Divakar Ramachandran
Minneapolis, MN 55414, USA





               
__________________________________________________________
Yahoo! India Answers: Share what you know. Learn something new
http://in.answers.yahoo.com/
Reply | Threaded
Open this post in threaded view
|

Re: Sort order in Virtual Stack Opener

Justin McGrath
Hi Divakar,
I don't know about getting the plugin to open them in a different
order, but you could try renaming your files.  If you can, have what
ever creates them zero pad the number and it should work. i.e A.1
would be A.0001.

Here's a sed script that will zero pad to four zeros for the files you
already have and in case you can't automatically zero pad the names.

#!/bin/bash
for i in A*;
 do new_name=`echo "$i" | sed -e 's/A\.\([0-9]\{1,3\}$\)/A\.0\1/g' \
                                -e 's/A\.\([0-9]\{1,3\}$\)/A\.0\1/g' \
                                -e 's/A\.\([0-9]\{1,3\}$\)/A\.0\1/g'`;
 if  [ "$i" != "$new_name" ] ;  then
   mv "$i" "$new_name"
 fi
done

I tried it on a few fake files and it works, but you certainly want to
backup your files first in case something goes wrong.

I bet there's a better way to do this, rather than listing the same
command three times.  Anyone know a way to make sed do something
multiple times?

Justin
Reply | Threaded
Open this post in threaded view
|

Re: Sort order in Virtual Stack Opener

Wayne Rasband
In reply to this post by Divakar Ramachandran
> Is there a way to change the sort order in the Virtual stack opene
> Hi,
>
> Is there a way to change the sort order in the Virtual stack opener
> plugin? I have image files with names like A.1, A.2 etc., running
> typically to hundreds of images. When I open the images  as a stack
> using the virtual stack opener, the stack order is alphabetical, like
> A.1, A.10, A.100, A.101 etc. instead of the numerical order.

There is an updated Virtual Stack Opener at

     http://rsb.info.nih.gov/ij/plugins/virtual-opener.html

that sorts in numeric order.

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Sort order in Virtual Stack Opener

Daniel Glen
In reply to this post by Justin McGrath
To make this a little simpler, with a little modification of your 'i'  
variable as a counter instead and using tcsh syntax, you could add  
lines something like this instead

set orig_name = slice.$i
set new_name = `printf "slice.%4.4d" $i`
mv $orig_name $new_name > & /dev/null

On Oct 12, 2006, at 10:30 PM, Justin McGrath wrote:

> Hi Divakar,
> I don't know about getting the plugin to open them in a different
> order, but you could try renaming your files.  If you can, have what
> ever creates them zero pad the number and it should work. i.e A.1
> would be A.0001.
>
> Here's a sed script that will zero pad to four zeros for the files you
> already have and in case you can't automatically zero pad the names.
>
> #!/bin/bash
> for i in A*;
> do new_name=`echo "$i" | sed -e 's/A\.\([0-9]\{1,3\}$\)/A\.0\1/g' \
>                                -e 's/A\.\([0-9]\{1,3\}$\)/A\.0\1/g' \
>                                -e 's/A\.\([0-9]\{1,3\}$\)/A\.0\1/g'`;
> if  [ "$i" != "$new_name" ] ;  then
>   mv "$i" "$new_name"
> fi
> done
>
> I tried it on a few fake files and it works, but you certainly want to
> backup your files first in case something goes wrong.
>
> I bet there's a better way to do this, rather than listing the same
> command three times.  Anyone know a way to make sed do something
> multiple times?
>
> Justin