Python script: z projection

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

Python script: z projection

Hadrien Mary
Hi,

I am trying to write a small script to perform z projection on an
image. It seems that I use the wrong signature for ops.project()
function. I tried many combinations without success...

-------------------------------
# @DatasetService data
# @DisplayService display
# @OpService ops

from net.imagej.ops.statistics import Max
from net.imglib2.type.numeric import RealType

fname = "/home/hadim/test_small.ome.tif"
img = data.open(fname)
display.createDisplay(img.getName(), img)

#op = ops.sum(RealType, img)
img2 = ops.project(img, Max, 1)
display.createDisplay(img2.getName(), img2)

data.save(img2, "/home/hadim/projected.ome.tif")
-----------------------------------

I looked the doc, imagej-ops tests but I can't find the correct
signature for python. Maybe you can help.

Thank you

--
Hadrien Mary

Ph.D student in Biology
Tournier-Gachet Team
CNRS - LBCMCP - UMR 5088

Université de Toulouse - Bât. 4R3B1
118, route de Narbonne - 31062 Toulouse

_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: Python script: z projection

Hadrien Mary
Last thing : I would like to run this script in headless mode on
pretty big images (17GB), so I would like to be sure wether `img =
data.open(fname)` use SCIFIO to open them.

If it does I guess virtual stack is used in case the opened image is
big. Am I correct ?

--
Hadrien Mary

Ph.D student in Biology
Tournier-Gachet Team
CNRS - LBCMCP - UMR 5088

Université de Toulouse - Bât. 4R3B1
118, route de Narbonne - 31062 Toulouse


On Sat, Jan 24, 2015 at 9:25 PM, Hadrien Mary <[hidden email]> wrote:

> Hi,
>
> I am trying to write a small script to perform z projection on an
> image. It seems that I use the wrong signature for ops.project()
> function. I tried many combinations without success...
>
> -------------------------------
> # @DatasetService data
> # @DisplayService display
> # @OpService ops
>
> from net.imagej.ops.statistics import Max
> from net.imglib2.type.numeric import RealType
>
> fname = "/home/hadim/test_small.ome.tif"
> img = data.open(fname)
> display.createDisplay(img.getName(), img)
>
> #op = ops.sum(RealType, img)
> img2 = ops.project(img, Max, 1)
> display.createDisplay(img2.getName(), img2)
>
> data.save(img2, "/home/hadim/projected.ome.tif")
> -----------------------------------
>
> I looked the doc, imagej-ops tests but I can't find the correct
> signature for python. Maybe you can help.
>
> Thank you
>
> --
> Hadrien Mary
>
> Ph.D student in Biology
> Tournier-Gachet Team
> CNRS - LBCMCP - UMR 5088
>
> Université de Toulouse - Bât. 4R3B1
> 118, route de Narbonne - 31062 Toulouse

_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: Python script: z projection

Hadrien Mary
I tried another approach without success neither :

-----------------------------------
# @DatasetService data
# @DisplayService display
# @ImageJ ij

from net.imagej.ops.statistics import Max
from net.imagej.ops.statistics import Sum
from net.imglib2.type.numeric import RealType

from jarray import array

fname = "/home/hadim/test_small.ome.tif"
ds = data.open(fname)

# TODO : find dimensions in ds object
dims = array([136, 65], 'l')
out = ij.op().createimg(dims)

# Find ndim for project on Z axis
ndim = 2

op = ij.op().sum(RealType, out)
ds2 = ij.op().project(out, ds, op, ndim)

ij.ui().show(ds2.getName(), ds2)

# TODO: should I delete out ?
-------------------------------------

--
Hadrien Mary

Ph.D student in Biology
Tournier-Gachet Team
CNRS - LBCMCP - UMR 5088

Université de Toulouse - Bât. 4R3B1
118, route de Narbonne - 31062 Toulouse


On Sat, Jan 24, 2015 at 9:35 PM, Hadrien Mary <[hidden email]> wrote:

> Last thing : I would like to run this script in headless mode on
> pretty big images (17GB), so I would like to be sure wether `img =
> data.open(fname)` use SCIFIO to open them.
>
> If it does I guess virtual stack is used in case the opened image is
> big. Am I correct ?
>
> --
> Hadrien Mary
>
> Ph.D student in Biology
> Tournier-Gachet Team
> CNRS - LBCMCP - UMR 5088
>
> Université de Toulouse - Bât. 4R3B1
> 118, route de Narbonne - 31062 Toulouse
>
>
> On Sat, Jan 24, 2015 at 9:25 PM, Hadrien Mary <[hidden email]> wrote:
>> Hi,
>>
>> I am trying to write a small script to perform z projection on an
>> image. It seems that I use the wrong signature for ops.project()
>> function. I tried many combinations without success...
>>
>> -------------------------------
>> # @DatasetService data
>> # @DisplayService display
>> # @OpService ops
>>
>> from net.imagej.ops.statistics import Max
>> from net.imglib2.type.numeric import RealType
>>
>> fname = "/home/hadim/test_small.ome.tif"
>> img = data.open(fname)
>> display.createDisplay(img.getName(), img)
>>
>> #op = ops.sum(RealType, img)
>> img2 = ops.project(img, Max, 1)
>> display.createDisplay(img2.getName(), img2)
>>
>> data.save(img2, "/home/hadim/projected.ome.tif")
>> -----------------------------------
>>
>> I looked the doc, imagej-ops tests but I can't find the correct
>> signature for python. Maybe you can help.
>>
>> Thank you
>>
>> --
>> Hadrien Mary
>>
>> Ph.D student in Biology
>> Tournier-Gachet Team
>> CNRS - LBCMCP - UMR 5088
>>
>> Université de Toulouse - Bât. 4R3B1
>> 118, route de Narbonne - 31062 Toulouse

_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: Python script: z projection

Curtis Rueden
Hi Hadrien,

> I am trying to write a small script to perform z projection on an
> image.

Thanks for playing with Ops, and sorry that no one replied to this thread until now!

I just wanted to let you know that based on your attempts, we are preparing a Z projection example with Ops for the upcoming 2015 ImageJ conference.

Preliminary work can be seen at:

It will merge to master within the next few days, and become available in ImageJ's Script Editor in the Templates > Tutorials menu by the conference.

Regards,
Curtis

On Sat, Jan 24, 2015 at 4:29 PM, Hadrien Mary <[hidden email]> wrote:
I tried another approach without success neither :

-----------------------------------
# @DatasetService data
# @DisplayService display
# @ImageJ ij

from net.imagej.ops.statistics import Max
from net.imagej.ops.statistics import Sum
from net.imglib2.type.numeric import RealType

from jarray import array

fname = "/home/hadim/test_small.ome.tif"
ds = data.open(fname)

# TODO : find dimensions in ds object
dims = array([136, 65], 'l')
out = ij.op().createimg(dims)

# Find ndim for project on Z axis
ndim = 2

op = ij.op().sum(RealType, out)
ds2 = ij.op().project(out, ds, op, ndim)

ij.ui().show(ds2.getName(), ds2)

# TODO: should I delete out ?
-------------------------------------

--
Hadrien Mary

Ph.D student in Biology
Tournier-Gachet Team
CNRS - LBCMCP - UMR 5088

Université de Toulouse - Bât. 4R3B1
118, route de Narbonne - 31062 Toulouse


On Sat, Jan 24, 2015 at 9:35 PM, Hadrien Mary <[hidden email]> wrote:
> Last thing : I would like to run this script in headless mode on
> pretty big images (17GB), so I would like to be sure wether `img =
> data.open(fname)` use SCIFIO to open them.
>
> If it does I guess virtual stack is used in case the opened image is
> big. Am I correct ?
>
> --
> Hadrien Mary
>
> Ph.D student in Biology
> Tournier-Gachet Team
> CNRS - LBCMCP - UMR 5088
>
> Université de Toulouse - Bât. 4R3B1
> 118, route de Narbonne - 31062 Toulouse
>
>
> On Sat, Jan 24, 2015 at 9:25 PM, Hadrien Mary <[hidden email]> wrote:
>> Hi,
>>
>> I am trying to write a small script to perform z projection on an
>> image. It seems that I use the wrong signature for ops.project()
>> function. I tried many combinations without success...
>>
>> -------------------------------
>> # @DatasetService data
>> # @DisplayService display
>> # @OpService ops
>>
>> from net.imagej.ops.statistics import Max
>> from net.imglib2.type.numeric import RealType
>>
>> fname = "/home/hadim/test_small.ome.tif"
>> img = data.open(fname)
>> display.createDisplay(img.getName(), img)
>>
>> #op = ops.sum(RealType, img)
>> img2 = ops.project(img, Max, 1)
>> display.createDisplay(img2.getName(), img2)
>>
>> data.save(img2, "/home/hadim/projected.ome.tif")
>> -----------------------------------
>>
>> I looked the doc, imagej-ops tests but I can't find the correct
>> signature for python. Maybe you can help.
>>
>> Thank you
>>
>> --
>> Hadrien Mary
>>
>> Ph.D student in Biology
>> Tournier-Gachet Team
>> CNRS - LBCMCP - UMR 5088
>>
>> Université de Toulouse - Bât. 4R3B1
>> 118, route de Narbonne - 31062 Toulouse

_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel


_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel