Login  Register

Re: Adding keyboard shortcut to toggle visibility of patches in TrakEM2

Posted by Albert Cardona-2 on Apr 12, 2016; 1:28am
URL: http://imagej.273.s1.nabble.com/Adding-keyboard-shortcut-to-toggle-visibility-of-patches-in-TrakEM2-tp5016099p5016102.html

Hi Federico,

Basically, you can create your own KeyListener and attach it to the TrakEM2
window canvas, and react upon its keyPressed KeyEvent.

The canvas element you can get from Display.getFront().getCanvas().

Would be something like this:

from java.awt import KeyAdapter

class MyKeyListener(KeyAdapter):
  def keyPressed(self, event):
    # Run your code here
    ...

Display.getFront().getCanvas().addKeyListener(MyKeyListener())

Best,

Albert

2016-04-11 17:05 GMT-04:00 Federico Luzzati <[hidden email]>:

> Dear List,
> I'm using TrakEM2 to analyze huge multi-channel confocal reconstructions.
> I'm
> importing the channels as separate 8-bit patches with the antigen specified
> within the patch name, apply a LUT with "adjust image filters" and set the
> composite mode to Add.
> To switch on and off a channel I'm using the "select all that match
> function". Nonetheless, this method is very slow, and it would be much
> better if one could define keyboard shortcuts for that.
> I wrote this simple script to toggle visibility of patches based on their
> names, but I can't figure out how I could call it from a keyboard shortcut
> inside TraKEM2.
>
> Any hint will be greatly appreciated
> Thank you very much!
>
> Federico
>
> Here is an example of the script:
>
> from ini.trakem2.display import *
>
> for layer in Display.getFront().getLayerSet().getLayers():
> patches = layer.getDisplayables(Patch)
> for patch in patches:
> if "DCX" in patch.title:
> if patch.visible == True:
> patch.visible = False
> else:
> patch.visible = True
>
>
>
> --
> Federico Luzzati, PhD
> Assistant Professor
> University of Turin,
> Dept. LIfe Sciences and Systems Biology (DBIOS)
> Via Accademia Albertina, 13 - 10123 Torino - IT
>
> Researcher at
> Neuroscience Institute Cavalieri Ottolenghi (NICO)
> Regione Gonzole, 10 - 10043 Orbassano (To) - IT
>
> tel. +39-0116704683/ -6631
> http://www.nico.ottolenghi.unito.it/index.php/it/adult-neurogenesis
>
> Sostieni con il tuo 5xmille il NICO e la ricerca sulle malattie
> neurodegenerative
> Firma nel riquadro "Finanziamento della ricerca scientifica e
> dell'Università"
> CF 97564560015
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>



--
http://albert.rierol.net
http://www.janelia.org/lab/cardona-lab
http://www.ini.uzh.ch/~acardona/

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