Reloading/Reverting a stack

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

Reloading/Reverting a stack

Juanjo Vega
Hi everyone,

I'm trying to implement a timer which will reload an image from disk
every period (5 seconds). It will be used to check images while they are
being modified by other programs.

As a quick trick, I'm using the "Revert" command inside the timer's
"run()" method, and it seems to work for 2D images, but it doesn't work
for stacks.

I also tried this:

FileInfo fi = imp.getOriginalFileInfo();
FileOpener fo = new FileOpener(fi);
fo.revertToSaved(imp);

But the stack is not reverted. And if I use the "getFileInfo()" method
instead of "getOriginalFileInfo()", it crashes because of some kind of
internal casting between byte and float:

"Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: [F
cannot be cast to [B"

Right now I'm sort of ideas, so I'm having a look into manuals and the
internet, but maybe somebody could help me.

Sincerelly,

Juanjo Vega.
Reply | Threaded
Open this post in threaded view
|

Re: Reloading/Reverting a stack

dscho
Hi,

On Mon, 27 Sep 2010, Juanjo Vega wrote:

> "Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: [F
> cannot be cast to [B"

Typically, this means that you have a (byte[])ip.getPixels() somewhere,
but that the ip is actually a FloatProcessor, not a ByteProcessor.

Ciao,
Johannes
Reply | Threaded
Open this post in threaded view
|

Re: Reloading/Reverting a stack

Juanjo Vega
Hi,

On Mon, 2010-09-27 at 18:23 +0200, Johannes Schindelin wrote:
> Hi,
>
> On Mon, 27 Sep 2010, Juanjo Vega wrote:
>
> > "Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: [F
> > cannot be cast to [B"
>
> Typically, this means that you have a (byte[])ip.getPixels() somewhere,
> but that the ip is actually a FloatProcessor, not a ByteProcessor.

Sure, but even fixing it I can't revert or reload stacks. IJ.run(imp,
"Revert") doesn't work for stacks, but for single images it works
perfectly.

I'm still looking at the code to try to understand why it doesn't work.

Any tip or help will be welcome.

Thanks,

Juanjo
Reply | Threaded
Open this post in threaded view
|

Re: Reloading/Reverting a stack

Rasband, Wayne (NIH/NIMH) [E]
On Sep 28, 2010, at 7:46 AM, Juanjo Vega wrote:
> Sure, but even fixing it I can't revert or reload stacks. IJ.run(imp,
> "Revert") doesn't work for stacks, but for single images it works
> perfectly.
>
> I'm still looking at the code to try to understand why it doesn't work.
>
> Any tip or help will be welcome.

The File>Revert command works with stacks in the 1.44i daily build.

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

Re: Reloading/Reverting a stack

Juanjo Vega
Thank you very much, Michael and Wayne.

I did "imp.updateAndDraw()" after updating the image, but it didn't
work.

I agree that a user won't see the entire stack every 5 seconds, so the
idea is not to refresh the entire stack, but to show the last version of
data loaded from disk when the user browses the stack.

I'll try Michael ideas, so it will work in previous imageJ versions. If
I can't manage to fix the problem, then I'll update to 1.44i (<- this is
the most probably option =P).

Sincerelly,

Juanjo.


On Tue, 2010-09-28 at 15:11 -0400, Rasband, Wayne (NIH/NIMH) [E] wrote:

> On Sep 28, 2010, at 7:46 AM, Juanjo Vega wrote:
> > Sure, but even fixing it I can't revert or reload stacks. IJ.run(imp,
> > "Revert") doesn't work for stacks, but for single images it works
> > perfectly.
> >
> > I'm still looking at the code to try to understand why it doesn't work.
> >
> > Any tip or help will be welcome.
>
> The File>Revert command works with stacks in the 1.44i daily build.
>
> -wayne