Accessing the area_list labels (TrakEM2)

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

Accessing the area_list labels (TrakEM2)

Pol
This question relates to trakEM2
http://www.ini.uzh.ch/~acardona/trakem2.html

I have a stack of images with annotations on another tif image stack. I
import the original image stack and afterwards I import the annotations as
arealists using 'Import labels as arealists'.

Now, I'd like to do some scripting to delete the arealists of every 9/10
slices (and probably some other things in the future).

The problem is I can't seem to find in which object the arealists are
stored. On trakEM GUI they show on the Z space tab.

I've looked at the class
diagram<http://www.ini.uzh.ch/~acardona/img/trakem2_datastructure_diagram.svg>(useful!)
and it says AreaLists are Displayable and that LayerSet contains
a list of ZDisplayable, but If I do print
Project.getProjects()[0].getRootLayerSet().getDisplayables() I only get the
385 image slices, the annotations are not stored there.

I'm guessing I'm looking for the DLabel objects, but I can't seem to find
where they are stored so I can delete the ones placed at certain z.

I'm not sure this is the appropriate forum, let me know if it isn't.

Cheers,

Pol

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Accessing the area_list labels (TrakEM2)

Albert Cardona-2
2013/4/23 Pol <[hidden email]>

> This question relates to trakEM2
> http://www.ini.uzh.ch/~acardona/trakem2.html
>
> I have a stack of images with annotations on another tif image stack. I
> import the original image stack and afterwards I import the annotations as
> arealists using 'Import labels as arealists'.
>
> Now, I'd like to do some scripting to delete the arealists of every 9/10
> slices (and probably some other things in the future).
>
> The problem is I can't seem to find in which object the arealists are
> stored. On trakEM GUI they show on the Z space tab.
>
> I've looked at the class
> diagram<
> http://www.ini.uzh.ch/~acardona/img/trakem2_datastructure_diagram.svg
> >(useful!)
> and it says AreaLists are Displayable and that LayerSet contains
> a list of ZDisplayable, but If I do print
> Project.getProjects()[0].getRootLayerSet().getDisplayables() I only get the
> 385 image slices, the annotations are not stored there.
>



Use:

Project.getProjects()[0].getRootLayerSet().getZDisplayables()

note the 'Z' in getZDisplayables()


Have a look at the TrakEM2 scripting tutorial:
http://fiji.sc/TrakEM2_Scripting



>
> I'm guessing I'm looking for the DLabel objects, but I can't seem to find
> where they are stored so I can delete the ones placed at certain z.
>


DLabel are text. What you are looking for are AreaList objects.

Here is a convenient way to get them. in jython:

project = Project.getProjects()[0]
layerset = project.getRootLayerSet()
arealists = layerset.getZDisplayables(AreaList)


Then, what you intended to do was to remove areas from within AreaList
objects. For that, iterate the layers:

# Remove an area from every 10th layer
touched_layers = []
for i, layer in enumerate(layerset.getLayers()):
  if 0 == (i+1) % 10:
    for arealist in arealists:
      arealist.setArea(layer.getId(), None)
    touched_layers.append(layer)

# Recreate internal quad-trees for object lookup
layerset.recreateBuckets(touched_layers, False)


Best,

Albert




>
> I'm not sure this is the appropriate forum, let me know if it isn't.
>
> Cheers,
>
> Pol
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>



--
http://albert.rierol.net
http://www.ini.uzh.ch/~acardona/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Pol
Reply | Threaded
Open this post in threaded view
|

Re: Accessing the area_list labels (TrakEM2)

Pol
Hi Albert,

Thanks for your reply, that was helpful and very complete.

The script, though, didn't change the arealists. I removed the conditional,
expecting it would remove all the arealists (and therefore leving my with
the raw tif stack), but nothing happened.

project = Project.getProjects()[0]
layerset = project.getRootLayerSet()
arealists = layerset.getZDisplayables(AreaList)

# Remove an area from every 10th layer
touched_layers = []
for i,layer in enumerate(layerset.getLayers()):
  for arealist in arealists:
       arealist.setArea(layer.getId(), None)
  touched_layers.append(layer)

print len(touched_layers)

# Recreate internal quad-trees for object lookup
layerset.recreateBuckets(touched_layers, False)

touched_layers does indeed have the size of the stack, and all arealist in
arealists are set to None, but still, the project doesn't seem to realize
any of this, graphically at least. Looking at the source code, my guess is
the problem is

      arealist.setArea(layer.getId(), None)

since

    public void setArea(final long layer_id, final Area area) {
*        if (null == area) return;*
        ht_areas.put(layer_id, area);
        updateInDatabase("points=" + layer_id);
    }

I'm not familiar with Jython, so I might be missing something. Let me know
if I could provide more information.

Your comments were helpful retrieving the arealists and many other things I
learnt (thanks!). So I'm guessing the question would be, how can we erase
an area if we can't set it to None?

GrĂ cies,

Pol


2013/4/23 Albert Cardona <[hidden email]>

> 2013/4/23 Pol <[hidden email]>
>
> > This question relates to trakEM2
> > http://www.ini.uzh.ch/~acardona/trakem2.html
> >
> > I have a stack of images with annotations on another tif image stack. I
> > import the original image stack and afterwards I import the annotations
> as
> > arealists using 'Import labels as arealists'.
> >
> > Now, I'd like to do some scripting to delete the arealists of every 9/10
> > slices (and probably some other things in the future).
> >
> > The problem is I can't seem to find in which object the arealists are
> > stored. On trakEM GUI they show on the Z space tab.
> >
> > I've looked at the class
> > diagram<
> > http://www.ini.uzh.ch/~acardona/img/trakem2_datastructure_diagram.svg
> > >(useful!)
> > and it says AreaLists are Displayable and that LayerSet contains
> > a list of ZDisplayable, but If I do print
> > Project.getProjects()[0].getRootLayerSet().getDisplayables() I only get
> the
> > 385 image slices, the annotations are not stored there.
> >
>
>
>
> Use:
>
> Project.getProjects()[0].getRootLayerSet().getZDisplayables()
>
> note the 'Z' in getZDisplayables()
>
>
> Have a look at the TrakEM2 scripting tutorial:
> http://fiji.sc/TrakEM2_Scripting
>
>
>
> >
> > I'm guessing I'm looking for the DLabel objects, but I can't seem to find
> > where they are stored so I can delete the ones placed at certain z.
> >
>
>
> DLabel are text. What you are looking for are AreaList objects.
>
> Here is a convenient way to get them. in jython:
>
> project = Project.getProjects()[0]
> layerset = project.getRootLayerSet()
> arealists = layerset.getZDisplayables(AreaList)
>
>
> Then, what you intended to do was to remove areas from within AreaList
> objects. For that, iterate the layers:
>
> # Remove an area from every 10th layer
> touched_layers = []
> for i, layer in enumerate(layerset.getLayers()):
>   if 0 == (i+1) % 10:
>     for arealist in arealists:
>       arealist.setArea(layer.getId(), None)
>     touched_layers.append(layer)
>
> # Recreate internal quad-trees for object lookup
> layerset.recreateBuckets(touched_layers, False)
>
>
> Best,
>
> Albert
>
>
>
>
> >
> > I'm not sure this is the appropriate forum, let me know if it isn't.
> >
> > Cheers,
> >
> > Pol
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
>
>
> --
> http://albert.rierol.net
> http://www.ini.uzh.ch/~acardona/
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Pol
Reply | Threaded
Open this post in threaded view
|

Re: Accessing the area_list labels (TrakEM2)

Pol
Hi,

area.reset() seems to do it


Pol


2013/4/24 Pol <[hidden email]>

> Hi Albert,
>
> Thanks for your reply, that was helpful and very complete.
>
> The script, though, didn't change the arealists. I removed the
> conditional, expecting it would remove all the arealists (and therefore
> leving my with the raw tif stack), but nothing happened.
>
> project = Project.getProjects()[0]
> layerset = project.getRootLayerSet()
> arealists = layerset.getZDisplayables(AreaList)
>
> # Remove an area from every 10th layer
> touched_layers = []
> for i,layer in enumerate(layerset.getLayers()):
>   for arealist in arealists:
>        arealist.setArea(layer.getId(), None)
>   touched_layers.append(layer)
>
> print len(touched_layers)
>
> # Recreate internal quad-trees for object lookup
> layerset.recreateBuckets(touched_layers, False)
>
> touched_layers does indeed have the size of the stack, and all arealist in
> arealists are set to None, but still, the project doesn't seem to realize
> any of this, graphically at least. Looking at the source code, my guess is
> the problem is
>
>       arealist.setArea(layer.getId(), None)
>
> since
>
>     public void setArea(final long layer_id, final Area area) {
> *        if (null == area) return;*
>         ht_areas.put(layer_id, area);
>         updateInDatabase("points=" + layer_id);
>     }
>
> I'm not familiar with Jython, so I might be missing something. Let me know
> if I could provide more information.
>
> Your comments were helpful retrieving the arealists and many other things
> I learnt (thanks!). So I'm guessing the question would be, how can we erase
> an area if we can't set it to None?
>
> GrĂ cies,
>
> Pol
>
>
> 2013/4/23 Albert Cardona <[hidden email]>
>
>> 2013/4/23 Pol <[hidden email]>
>>
>> > This question relates to trakEM2
>> > http://www.ini.uzh.ch/~acardona/trakem2.html
>> >
>> > I have a stack of images with annotations on another tif image stack. I
>> > import the original image stack and afterwards I import the annotations
>> as
>> > arealists using 'Import labels as arealists'.
>> >
>> > Now, I'd like to do some scripting to delete the arealists of every 9/10
>> > slices (and probably some other things in the future).
>> >
>> > The problem is I can't seem to find in which object the arealists are
>> > stored. On trakEM GUI they show on the Z space tab.
>> >
>> > I've looked at the class
>> > diagram<
>> > http://www.ini.uzh.ch/~acardona/img/trakem2_datastructure_diagram.svg
>> > >(useful!)
>> > and it says AreaLists are Displayable and that LayerSet contains
>> > a list of ZDisplayable, but If I do print
>> > Project.getProjects()[0].getRootLayerSet().getDisplayables() I only get
>> the
>> > 385 image slices, the annotations are not stored there.
>> >
>>
>>
>>
>> Use:
>>
>> Project.getProjects()[0].getRootLayerSet().getZDisplayables()
>>
>> note the 'Z' in getZDisplayables()
>>
>>
>> Have a look at the TrakEM2 scripting tutorial:
>> http://fiji.sc/TrakEM2_Scripting
>>
>>
>>
>> >
>> > I'm guessing I'm looking for the DLabel objects, but I can't seem to
>> find
>> > where they are stored so I can delete the ones placed at certain z.
>> >
>>
>>
>> DLabel are text. What you are looking for are AreaList objects.
>>
>> Here is a convenient way to get them. in jython:
>>
>> project = Project.getProjects()[0]
>> layerset = project.getRootLayerSet()
>> arealists = layerset.getZDisplayables(AreaList)
>>
>>
>> Then, what you intended to do was to remove areas from within AreaList
>> objects. For that, iterate the layers:
>>
>> # Remove an area from every 10th layer
>> touched_layers = []
>> for i, layer in enumerate(layerset.getLayers()):
>>   if 0 == (i+1) % 10:
>>     for arealist in arealists:
>>       arealist.setArea(layer.getId(), None)
>>     touched_layers.append(layer)
>>
>> # Recreate internal quad-trees for object lookup
>> layerset.recreateBuckets(touched_layers, False)
>>
>>
>> Best,
>>
>> Albert
>>
>>
>>
>>
>> >
>> > I'm not sure this is the appropriate forum, let me know if it isn't.
>> >
>> > Cheers,
>> >
>> > Pol
>> >
>> > --
>> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>> >
>>
>>
>>
>> --
>> http://albert.rierol.net
>> http://www.ini.uzh.ch/~acardona/
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
>

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