<div dir="ltr">Hi Hadrien!<div><br></div><div>>s<span style="font-size:12.8000001907349px">o I am not sure wether it's a </span><span style="font-size:12.8000001907349px">bug or it's something not supported right now.</span></div><div><span style="font-size:12.8000001907349px"><br></span><div>It looks like it's a limitation of the DefaultDataset[1] right now. I updated the message to suggest a workaround, at least[2].</div><div><br></div><div>So if you change your next to last line to:</div><div><br></div><div>ds2 = ij.op().crop(interval, ds.getImgPlus())<br></div><div><br></div><div>to crop the ImgPlus that's wrapped by the Dataset, your script should work (or at least not crash).</div><div><br></div><div>Thanks, as always, for the report :)</div><div><br></div><div>Best,</div><div>Mark</div><div><br></div><div>[1] <a href="https://github.com/imagej/imagej-common/blob/59bfc3cebf8204a48bc559adf079f227652514ed/src/main/java/net/imagej/DefaultDataset.java#L734-736">https://github.com/imagej/imagej-common/blob/59bfc3cebf8204a48bc559adf079f227652514ed/src/main/java/net/imagej/DefaultDataset.java#L734-736</a></div><div>[2] <a href="https://github.com/imagej/imagej-common/commit/75330a95c66013390cf4b6b4511e08357a8a28b0">https://github.com/imagej/imagej-common/commit/75330a95c66013390cf4b6b4511e08357a8a28b0</a></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 25, 2015 at 9:14 AM, Hadrien Mary <span dir="ltr"><<a href="mailto:hadrien.mary@gmail.com" target="_blank">hadrien.mary@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I am having an issue with a script which crop an image with<br>
imagej-ops. The error shows a "TODO" so I am not sure wether it's a<br>
bug or it's something not supported right now.<br>
<br>
-------------------------------<br>
# @DatasetService data<br>
# @ImageJ ij<br>
<br>
from jarray import array<br>
<br>
from net.imglib2 import FinalInterval<br>
from net.imglib2.img.array import ArrayImgs<br>
from net.imagej.axis import Axes<br>
from net.imglib2.util import Intervals<br>
<br>
fname = "/home/hadim/test_small.ome.tif"<br>
ds = data.open(fname)<br>
<br>
# Initiate dimensions<br>
dims = {}<br>
dim_names = [None] * 5<br>
for ax in [Axes.X, Axes.Y, Axes.Z, Axes.TIME, Axes.CHANNEL]:<br>
ax_index = ds.dimensionIndex(ax)<br>
dim_names[ax_index] = str(ax)<br>
if int(ds.dimension(ax_index)) == 1:<br>
dims[str(ax)] = (0, 0)<br>
else:<br>
dims[str(ax)] = (0, int(ds.dimension(ax_index)) - 1)<br>
<br>
# Set cropped regions<br>
dims['X'] = (10, 40)<br>
dims['Y'] = (5, 20)<br>
<br>
# Set crop intervals<br>
begin_interval = [dims[name][0] for name in dim_names]<br>
end_interval = [dims[name][1] for name in dim_names]<br>
interval = FinalInterval(begin_interval, end_interval)<br>
print(begin_interval)<br>
print(end_interval)<br>
print(Intervals.contains(ds, interval))<br>
<br>
ds2 = ij.op().crop(interval, ds)<br>
ij.ui().show(ds2.getName(), ds2)<br>
----------------------------------------------------<br>
<br>
Error shows:<br>
<br>
----------------------------------------------------<br>
ds2 = ij.op().crop(interval, ds)<br>
at net.imagej.DefaultDataset.factory(DefaultDataset.java:735)<br>
at net.imagej.ImgPlus.factory(ImgPlus.java:280)<br>
at net.imagej.ops.crop.CropImgPlus.run(CropImgPlus.java:74)<br>
at org.scijava.command.CommandModule.run(CommandModule.java:201)<br>
at net.imagej.ops.DefaultOpService.run(DefaultOpService.java:363)<br>
at net.imagej.ops.DefaultOpService.run(DefaultOpService.java:78)<br>
at net.imagej.ops.DefaultOpService.crop(DefaultOpService.java:215)<br>
at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)<br>
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br>
at java.lang.reflect.Method.invoke(Method.java:606)<br>
<br>
java.lang.UnsupportedOperationException:<br>
java.lang.UnsupportedOperationException: TODO<br>
-------------------------------------------------------<br>
<br>
Thank you<br>
<br>
--<br>
Hadrien Mary<br>
<br>
Ph.D student in Biology<br>
Tournier-Gachet Team<br>
CNRS - LBCMCP - UMR 5088<br>
<br>
Université de Toulouse - Bât. 4R3B1<br>
118, route de Narbonne - 31062 Toulouse<br>
<br>
_______________________________________________<br>
ImageJ-devel mailing list<br>
<a href="mailto:ImageJ-devel@imagej.net">ImageJ-devel@imagej.net</a><br>
<a href="http://imagej.net/mailman/listinfo/imagej-devel" target="_blank">http://imagej.net/mailman/listinfo/imagej-devel</a><br>
</blockquote></div><br></div>