Fiji: keyboard shortcuts for moving through time and channels

A friend asked me today if there are alternatives to the arrow keys or ‘.’ and ‘,’ to switch channels and time points in a 4D image in Fiji.
He knows that with the alt-key pressed you move through time while without alt you move through channels, but he would love to have keyboard shortcuts that do not require the modifier keys pressed (e.g. alt).

Any way to make this happen for him?

If you need more motivation, here is his original email… :wink:

When we’re playing 4D movies (multiple Z-plane, multiple timepoints), we use the arrow keys to make playback seamless as we’re following cell lineages, etc. The forward and back arrows control the Z plane, and the same keys plus the ALT button control the timepoints…

If only the timepoints were controlled instead by keys on the left side of the keyboard, then we could play back movies using two hands, gliding up and down in planes and forward and back in time without even thinking about what keys we’re pressing. Our lives would be so much happier. We’d be kinder to our mates and children, and we’d probably plant more flowers, if forward and back in time were controlled by, say, the “z” and “c” keys, which I think are currently unassigned to anything during playback.

Is that an easy thing to do? I’m dreaming of you telling this to someone and them saying, “oh yeah, that’s trivial, I can make that fix right now”.

Thanks for any hint, trick, hack, or tipp,
Florian

One way you can achieve this is by assigning the keys “z” and “c” to macros, which utilize the built-in macro functions to move through the time frames.

Check out the following macro:
move_through_timeframes.txt (225 Bytes)

You will need to install it by following the below guidelines:

Note that keyboard shortcuts will not work unless the macros are installed and the “ImageJ” window, or an image window, is the active (front) window and has keyboard focus. You install macros using the macro editor’s Macros>Install Macros command or the Plugins>Macros>Install command. Install the two macros in the above example and you will see that the commands

Macro 1 [a] Macro 2 [1]

get added to Plugins>Macros submenu. Save these macros in a file named “StartupMacros.txt” in the macros folder and ImageJ will automatically install them when it starts up.

Ved

3 Likes

Alternatively to getStackPosition and setStackPosition, you can programmatically set the modifier key alt using setKeyDown("alt"):

macro "Previous Frame [z]" {
	setKeyDown("alt");
	run("Previous Slice [<]");
}

macro "Next Frame [c]" {
	setKeyDown("alt");
	run("Next Slice [>]");
}

Put this into your StartupMacros.ijm to have it installed at startup.

4 Likes

That works when I press “c” or “z” (thanks!) but when I hold down “c” or “z” to scroll through video rapidly, that doesn’t work… and “c” or “z” don’t work at all any more, nor do the arrow keys. I’d be grateful for any help!

You can try with larger increments, you could even have the same macro respond to shift+alt modifiers to change the increment to your needs. Here is a starting point:

macro "Macro 1 [z]" {
	Stack.getPosition(channel, slice, frame);
	getDimensions(w, h, c, z, nframes);
	newT = frame + 10;
	if (newT > nframes) newT = 1;
	Stack.setPosition(channel, slice, newT);
}

BTW, Did you try toggling the Reverse CZT order of “>” and “<” in Edit>Options>Misc…? That would allow you to navigate in T using the default shortcuts <>; in Z with Ctrl+<>, and in C using Alt+<>

1 Like

I didn’t try – the goal is to be able to move forward and back in time, and up and down in focal planes, at video rate using two fingers on each hand (hence no alt key, etc). If we can do that, then we can analyze data way easier than we currently do fumbling for keys in a way that makes video rate playback (and the required brain focus) impossible, at least for my brain. We’ll be grateful for any solutions to this - thanks!

Could you please upload a hyperstack (minimal working example), where you see this problem?

Ved

Have you tried enabling “Reverse CZT order of ‘>’ and ‘<’” in Edit>Options>Misc?

Thanks Wayne. That gives us control of time, but I think we lose quick control of Z plane then… or at least I can’t find shortcut keys for Z plane then. Our goal is to be able to move forward and back in time, and up and down in focal planes, at video rate using two fingers on each hand (hence no alt key, etc). If we can do that, then we can analyze data way easier than we currently do fumbling for keys in a way that makes video rate playback (and the required brain focus) impossible, at least for my brain. We’ll be grateful for any solutions to this.

Thanks tferr. We’re trying to get rapid access to shifting Z plane and T forward or back – so we can scroll through multiplane videos at video rate, for analyzing data without removing our eyes from the video. So ideally we’d have no extra keys to press, like Ctrl.

Thanks to all of you for your suggestions… I’ve learned a lot! :slight_smile:

I think one could also use BigDataViewer (BDV) for this where ‘[’ and ‘]’ keys move time and the mouse could control which z-plane to show… does this make sense?

@bobg, do you have an example movie to share? If not… I assume that any 3D+t movie would do, right?

Ok, I’ve tested on some random data and I think it is not so bad. (Not sure if going through time is maybe too fast… but this can be tweaked, I’m sure.)

Test like this:

  • Open Fiji
  • File -> Open Samples -> Mitosis (5D stack)
  • Plugins -> BigDataViewer -> Open Current Image
  • Now use scroll wheel (two fingers on your touchpad) to go into Z-direction and ‘[’, ‘]’ keys for time.

Let me know what you dislike.

Best,
Florian

PS: extra feature that is possible here is that you can hit Shift+X, Shift+Y, or Shift+Z or just click and arbitrarily rotate your volume and then still use scrolling and ‘[’, ‘]’ to move through time.

I tried BigDataViewer on our film (here’s a small one: https://www.dropbox.com/s/1sci010p5ihrr0b/example-1.tif?dl=0) but it’s doing weird things to it (maybe time and Z are swapped the way it’s reading it?) So back to the way Fiji opens the file normally… I hadn’t appreciated that the Alt/Option key (on a Mac) will swap whether the left/right arrow keys are controlling T or Z. That works pretty well, and even better for my brain when I use EDIT > OPTIONS > MISC > REVERSE CZT ORDER OF > AND < so that the more-used T scrolling doesn’t require the extra key pushed. Not bad. I think I’d prefer having separate keys for controlling each (arrows for time, Z and C for plane, for example) but this gets me 90% of the way to what I was hoping for. I’ll declare my problem solved. Thanks!!

1 Like