TrakEM question

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

TrakEM question

Kenneth Sloan-3
We are using TrakEM to look at a stack of EM images.  It works great!

But, we would like to generate orthogonal views of the stack of images.

I am, alas, completely ignorant of how TrakEM manages the images (multiple tiles, multiple slices).

It seems clear that the image displayed by ImageJ is not a "stack" as far as ImageJ is concerned.
Any attempt to select that window and apply any Stack command fails miserably ("must be a stack").
I didn't really think that would work, but I tried it.

So...is there a way to produce a (perhaps low resolution, perhaps a limited "brick") stack that can be treated as a normal ImageJ stack of images, so that we could use (for example) "Orthogonal Views").

I expect this will be expensive.  The data set is 10-20TB.  So, the key is probably "lower resolution or restricted region in x,y,z"

--
Kenneth Sloan
[hidden email]
Vision is the art of seeing what is invisible to others.

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

Re: TrakEM question

Albert Cardona-2
Hi Kenneth,

Glad you find TrakEM2 useful.

Internally, TrakEM2 organizes data as a list of 2D planes. Each plane,
or section, is modeled by a "Layer" object. The list of Layer
instances is the LayerSet.

As you point out, your volume is too large for visualization as an
orthoslices at 100 % resolution, and you have two parameters to play
with: the ROI to restrict to a subvolume, and the magnification.

Here is a script that uses both, in jython, and opens an image stack.
It requires:
1. That a TrakEM2 project is open.
2. That an ROI is draw using the rectangle tool (optional).
3. Write in the first and last sections (indices, not Z) that you want
to include).

Will produce 8-bit images. If you want RGB, use ImagePlus.COLOR_RGB in
the getFlatImage function. (GRAY16 and GRAY32 won't work.)
For 16-bit, use the ExportUnsignedShort.makeFlatImage method instead.

If you are intending to visualize the entire volume rather than a
small bit, there are alternatives.

For one, consider exporting the data as N5
(https://github.com/saalfeldlab/n5) and then using the BigDataViewer
or the BigCAT to visualize the volume in arbitrary zooms and
rotations, as well as orthoslices. With compression, the data would
take about 50% of the current storage space.

Another option is to view the whole TrakEM2 projevt volume as an
ImgLib2 RandomAccessibleInterval (ask Stephan Saalfeld about the
script), and then using whatever ImgLib2-based tools you like to crop,
process, or visualize, including the BigDataViewer.

Yet another option is to export the data for CATMAID (see:
https://github.com/axtimwalde/fiji-scripts/blob/master/TrakEM2/catmaid-export2.bsh
).

Best,

Albert


####################
# Export an ImageStack from a range of TrakEM2 layers

from ini.trakem2.display import Display, Displayable
from ij import ImagePlus, ImageStack

# zero-based index:
index_first_section = 10
index_last_section = 20

magnification = 0.25

front = Display.getFront()
layerset = front.getLayerSet()
layers = layerset.getLayers().subList(index_first_section,
index_last_section + 1)
loader = layerset.getProject().getLoader()

# Can be null
roi = front.getRoi()

# The whole 2D area, or just that of the ROI
bounds = roi.getBounds() if roi else layerset.get2DBounds()

stack = ImageStack(int(bounds.width * magnification + 0.5),
                   int(bounds.height * magnification + 0.5))
print stack

for layer in layers:
  imp = loader.getFlatImage(layer, bounds, magnification, -1,
ImagePlus.GRAY8, Displayable, False)
  stack.addSlice(imp.getProcessor())

ImagePlus("stack", stack).show()
###################

2018-03-10 9:20 GMT-05:00 Kenneth Sloan <[hidden email]>:

> We are using TrakEM to look at a stack of EM images.  It works great!
>
> But, we would like to generate orthogonal views of the stack of images.
>
> I am, alas, completely ignorant of how TrakEM manages the images (multiple tiles, multiple slices).
>
> It seems clear that the image displayed by ImageJ is not a "stack" as far as ImageJ is concerned.
> Any attempt to select that window and apply any Stack command fails miserably ("must be a stack").
> I didn't really think that would work, but I tried it.
>
> So...is there a way to produce a (perhaps low resolution, perhaps a limited "brick") stack that can be treated as a normal ImageJ stack of images, so that we could use (for example) "Orthogonal Views").
>
> I expect this will be expensive.  The data set is 10-20TB.  So, the key is probably "lower resolution or restricted region in x,y,z"
>
> --
> Kenneth Sloan
> [hidden email]
> Vision is the art of seeing what is invisible to others.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html



--
http://albert.rierol.net
http://www.janelia.org/lab/cardona-lab
https://www.pdn.cam.ac.uk/directory/albert-cardona

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

Re: TrakEM question

Christian Goosmann-2
In reply to this post by Kenneth Sloan-3
Hi Kenneth

did you think of exporting your region of interest from trackEM. Draw a
rectangle anywhere in the display, right click choosing 'export' and
'make flat image'. A dialog opens where you can specify which range of
slices or "z-positions" you want. It either generates a stack as an open
document or writes one to the disk, you choose.

hth

Christian

---
Christian Goosmann
Mikroskopie
Max-Planck-Institut für Infektionsbiologie
Campus Charité Mitte
Charitéplatz 1
10117 Berlin
Tel.: +49 30 28460 388

On 10.03.2018 15:20, Kenneth Sloan wrote:

> We are using TrakEM to look at a stack of EM images.  It works great!
>
> But, we would like to generate orthogonal views of the stack of images.
>
> I am, alas, completely ignorant of how TrakEM manages the images (multiple tiles, multiple slices).
>
> It seems clear that the image displayed by ImageJ is not a "stack" as far as ImageJ is concerned.
> Any attempt to select that window and apply any Stack command fails miserably ("must be a stack").
> I didn't really think that would work, but I tried it.
>
> So...is there a way to produce a (perhaps low resolution, perhaps a limited "brick") stack that can be treated as a normal ImageJ stack of images, so that we could use (for example) "Orthogonal Views").
>
> I expect this will be expensive.  The data set is 10-20TB.  So, the key is probably "lower resolution or restricted region in x,y,z"
>
> --
> Kenneth Sloan
> [hidden email]
> Vision is the art of seeing what is invisible to others.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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

Re: TrakEM question

Kenneth Sloan-3
Thank you for your reply.  I'm a very new user of TrakEM (and...not actually using it myself - just helping some other folk).

I will pass it along, and give it a try.

--
Kenneth Sloan
[hidden email]
Vision is the art of seeing what is invisible to others.





> On 12 Mar 2018, at 11:55 , Christian Goosmann <[hidden email]> wrote:
>
> Hi Kenneth
>
> did you think of exporting your region of interest from trackEM. Draw a rectangle anywhere in the display, right click choosing 'export' and 'make flat image'. A dialog opens where you can specify which range of slices or "z-positions" you want. It either generates a stack as an open document or writes one to the disk, you choose.
>
> hth
>
> Christian
>
> ---
> Christian Goosmann
> Mikroskopie
> Max-Planck-Institut für Infektionsbiologie
> Campus Charité Mitte
> Charitéplatz 1
> 10117 Berlin
> Tel.: +49 30 28460 388
>
> On 10.03.2018 15:20, Kenneth Sloan wrote:
>> We are using TrakEM to look at a stack of EM images.  It works great!
>>
>> But, we would like to generate orthogonal views of the stack of images.
>>
>> I am, alas, completely ignorant of how TrakEM manages the images (multiple tiles, multiple slices).
>>
>> It seems clear that the image displayed by ImageJ is not a "stack" as far as ImageJ is concerned.
>> Any attempt to select that window and apply any Stack command fails miserably ("must be a stack").
>> I didn't really think that would work, but I tried it.
>>
>> So...is there a way to produce a (perhaps low resolution, perhaps a limited "brick") stack that can be treated as a normal ImageJ stack of images, so that we could use (for example) "Orthogonal Views").
>>
>> I expect this will be expensive.  The data set is 10-20TB.  So, the key is probably "lower resolution or restricted region in x,y,z"
>>
>> --
>> Kenneth Sloan
>> [hidden email]
>> Vision is the art of seeing what is invisible to others.
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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

Re: TrakEM question

Kenneth Sloan-3
In reply to this post by Albert Cardona-2
Excellent!  Again - thank you.

--
Kenneth Sloan
[hidden email]
Vision is the art of seeing what is invisible to others.





> On 12 Mar 2018, at 10:33 , Albert Cardona <[hidden email]> wrote:
>
> Hi Kenneth,
>
> Glad you find TrakEM2 useful.
>
> Internally, TrakEM2 organizes data as a list of 2D planes. Each plane,
> or section, is modeled by a "Layer" object. The list of Layer
> instances is the LayerSet.
>
> As you point out, your volume is too large for visualization as an
> orthoslices at 100 % resolution, and you have two parameters to play
> with: the ROI to restrict to a subvolume, and the magnification.
>
> Here is a script that uses both, in jython, and opens an image stack.
> It requires:
> 1. That a TrakEM2 project is open.
> 2. That an ROI is draw using the rectangle tool (optional).
> 3. Write in the first and last sections (indices, not Z) that you want
> to include).
>
> Will produce 8-bit images. If you want RGB, use ImagePlus.COLOR_RGB in
> the getFlatImage function. (GRAY16 and GRAY32 won't work.)
> For 16-bit, use the ExportUnsignedShort.makeFlatImage method instead.
>
> If you are intending to visualize the entire volume rather than a
> small bit, there are alternatives.
>
> For one, consider exporting the data as N5
> (https://github.com/saalfeldlab/n5) and then using the BigDataViewer
> or the BigCAT to visualize the volume in arbitrary zooms and
> rotations, as well as orthoslices. With compression, the data would
> take about 50% of the current storage space.
>
> Another option is to view the whole TrakEM2 projevt volume as an
> ImgLib2 RandomAccessibleInterval (ask Stephan Saalfeld about the
> script), and then using whatever ImgLib2-based tools you like to crop,
> process, or visualize, including the BigDataViewer.
>
> Yet another option is to export the data for CATMAID (see:
> https://github.com/axtimwalde/fiji-scripts/blob/master/TrakEM2/catmaid-export2.bsh
> ).
>
> Best,
>
> Albert
>
>
> ####################
> # Export an ImageStack from a range of TrakEM2 layers
>
> from ini.trakem2.display import Display, Displayable
> from ij import ImagePlus, ImageStack
>
> # zero-based index:
> index_first_section = 10
> index_last_section = 20
>
> magnification = 0.25
>
> front = Display.getFront()
> layerset = front.getLayerSet()
> layers = layerset.getLayers().subList(index_first_section,
> index_last_section + 1)
> loader = layerset.getProject().getLoader()
>
> # Can be null
> roi = front.getRoi()
>
> # The whole 2D area, or just that of the ROI
> bounds = roi.getBounds() if roi else layerset.get2DBounds()
>
> stack = ImageStack(int(bounds.width * magnification + 0.5),
>                   int(bounds.height * magnification + 0.5))
> print stack
>
> for layer in layers:
>  imp = loader.getFlatImage(layer, bounds, magnification, -1,
> ImagePlus.GRAY8, Displayable, False)
>  stack.addSlice(imp.getProcessor())
>
> ImagePlus("stack", stack).show()
> ###################
>
> 2018-03-10 9:20 GMT-05:00 Kenneth Sloan <[hidden email]>:
>> We are using TrakEM to look at a stack of EM images.  It works great!
>>
>> But, we would like to generate orthogonal views of the stack of images.
>>
>> I am, alas, completely ignorant of how TrakEM manages the images (multiple tiles, multiple slices).
>>
>> It seems clear that the image displayed by ImageJ is not a "stack" as far as ImageJ is concerned.
>> Any attempt to select that window and apply any Stack command fails miserably ("must be a stack").
>> I didn't really think that would work, but I tried it.
>>
>> So...is there a way to produce a (perhaps low resolution, perhaps a limited "brick") stack that can be treated as a normal ImageJ stack of images, so that we could use (for example) "Orthogonal Views").
>>
>> I expect this will be expensive.  The data set is 10-20TB.  So, the key is probably "lower resolution or restricted region in x,y,z"
>>
>> --
>> Kenneth Sloan
>> [hidden email]
>> Vision is the art of seeing what is invisible to others.
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
>
>
> --
> http://albert.rierol.net
> http://www.janelia.org/lab/cardona-lab
> https://www.pdn.cam.ac.uk/directory/albert-cardona
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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

Re: TrakEM question

Saalfeld, Stephan
Or you build this project into your active Fiji instance:

https://github.com/saalfeldlab/bigdataviewer-trakem2

It will add a plugin

https://github.com/saalfeldlab/bigdataviewer-trakem2/blob/master/src/ma
in/resources/plugins.config

to view the currently open TrakEM2 project with arbitrary reslicing
BigDataViewer.  Without export.

It's a little old and may conflict with other stuff in Fiji, so test in
a fresh copy.

mvn -Dimagej.app.directory=$HOME/packages/Fiji.app clean install

Best,
Stephan

On Mon, 2018-03-12 at 13:53 -0500, Kenneth Sloan wrote:

> Excellent!  Again - thank you.
>
> --
> Kenneth Sloan
> [hidden email]
> Vision is the art of seeing what is invisible to others.
>
>
>
>
>
> >
> > On 12 Mar 2018, at 10:33 , Albert Cardona <[hidden email]>
> > wrote:
> >
> > Hi Kenneth,
> >
> > Glad you find TrakEM2 useful.
> >
> > Internally, TrakEM2 organizes data as a list of 2D planes. Each
> > plane,
> > or section, is modeled by a "Layer" object. The list of Layer
> > instances is the LayerSet.
> >
> > As you point out, your volume is too large for visualization as an
> > orthoslices at 100 % resolution, and you have two parameters to
> > play
> > with: the ROI to restrict to a subvolume, and the magnification.
> >
> > Here is a script that uses both, in jython, and opens an image
> > stack.
> > It requires:
> > 1. That a TrakEM2 project is open.
> > 2. That an ROI is draw using the rectangle tool (optional).
> > 3. Write in the first and last sections (indices, not Z) that you
> > want
> > to include).
> >
> > Will produce 8-bit images. If you want RGB, use ImagePlus.COLOR_RGB
> > in
> > the getFlatImage function. (GRAY16 and GRAY32 won't work.)
> > For 16-bit, use the ExportUnsignedShort.makeFlatImage method
> > instead.
> >
> > If you are intending to visualize the entire volume rather than a
> > small bit, there are alternatives.
> >
> > For one, consider exporting the data as N5
> > (https://github.com/saalfeldlab/n5) and then using the
> > BigDataViewer
> > or the BigCAT to visualize the volume in arbitrary zooms and
> > rotations, as well as orthoslices. With compression, the data would
> > take about 50% of the current storage space.
> >
> > Another option is to view the whole TrakEM2 projevt volume as an
> > ImgLib2 RandomAccessibleInterval (ask Stephan Saalfeld about the
> > script), and then using whatever ImgLib2-based tools you like to
> > crop,
> > process, or visualize, including the BigDataViewer.
> >
> > Yet another option is to export the data for CATMAID (see:
> > https://github.com/axtimwalde/fiji-scripts/blob/master/TrakEM2/catm
> > aid-export2.bsh
> > ).
> >
> > Best,
> >
> > Albert
> >
> >
> > ####################
> > # Export an ImageStack from a range of TrakEM2 layers
> >
> > from ini.trakem2.display import Display, Displayable
> > from ij import ImagePlus, ImageStack
> >
> > # zero-based index:
> > index_first_section = 10
> > index_last_section = 20
> >
> > magnification = 0.25
> >
> > front = Display.getFront()
> > layerset = front.getLayerSet()
> > layers = layerset.getLayers().subList(index_first_section,
> > index_last_section + 1)
> > loader = layerset.getProject().getLoader()
> >
> > # Can be null
> > roi = front.getRoi()
> >
> > # The whole 2D area, or just that of the ROI
> > bounds = roi.getBounds() if roi else layerset.get2DBounds()
> >
> > stack = ImageStack(int(bounds.width * magnification + 0.5),
> >                   int(bounds.height * magnification + 0.5))
> > print stack
> >
> > for layer in layers:
> >  imp = loader.getFlatImage(layer, bounds, magnification, -1,
> > ImagePlus.GRAY8, Displayable, False)
> >  stack.addSlice(imp.getProcessor())
> >
> > ImagePlus("stack", stack).show()
> > ###################
> >
> > 2018-03-10 9:20 GMT-05:00 Kenneth Sloan <[hidden email]>:
> > >
> > > We are using TrakEM to look at a stack of EM images.  It works
> > > great!
> > >
> > > But, we would like to generate orthogonal views of the stack of
> > > images.
> > >
> > > I am, alas, completely ignorant of how TrakEM manages the images
> > > (multiple tiles, multiple slices).
> > >
> > > It seems clear that the image displayed by ImageJ is not a
> > > "stack" as far as ImageJ is concerned.
> > > Any attempt to select that window and apply any Stack command
> > > fails miserably ("must be a stack").
> > > I didn't really think that would work, but I tried it.
> > >
> > > So...is there a way to produce a (perhaps low resolution, perhaps
> > > a limited "brick") stack that can be treated as a normal ImageJ
> > > stack of images, so that we could use (for example) "Orthogonal
> > > Views").
> > >
> > > I expect this will be expensive.  The data set is 10-20TB.  So,
> > > the key is probably "lower resolution or restricted region in
> > > x,y,z"
> > >
> > > --
> > > Kenneth Sloan
> > > [hidden email]
> > > Vision is the art of seeing what is invisible to others.
> > >
> > > --
> > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
> >
--

Stephan Saalfeld, Ph.D.
Group Leader
Janelia Research Campus
19700 Helix Drive | Ashburn, VA 20147
Phone: 571-209-4184 | Fax: 571-209-4946
[hidden email]



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

signature.asc (484 bytes) Download Attachment