<div dir="ltr"><div><div class="gmail_extra">Hi Brian,<br></div><div class="im"><div class="gmail_extra"><br><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">


<div><br></div><div>On first glance it would seem to me the 
SAMPLE_FORMAT should be set to 3 (for float) somehow in the 
typedTranslate function.   However I'm not overly familiar with the 
code. </div></blockquote></div>
<br></div></div><div class="gmail_extra"> Your fix was absolutely correct. I <a href="https://github.com/scifio/scifio/commit/ece33ccc7c1b4bfdb13e749dce96b440d66db534" target="_blank">updated SCIFIO master</a> to account for floats when translating.<br>


<br></div><div class="gmail_extra"> Anyway, I really appreciate you 
taking the time - not just to report the bug - but to delve into the 
code! Since it takes extra effort on your part to debug, if you ever 
would like your name attached to your work, please feel welcome to 
submit pull requests (e.g. to <a href="https://github.com/scifio/scifio/pulls" target="_blank">scifio</a>).<br>
<br></div>Thanks again for reporting this issue - let us know if anything else comes up!<br><br></div>- Mark<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Dec 12, 2013 at 8:23 AM, Brian Northan <span dir="ltr"><<a href="mailto:bnorthan@gmail.com" target="_blank">bnorthan@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi Curtis<br><br></div><div>I was testing out the ImgSaver updates and seem to be having trouble saving a 32 bit float image.  At some point in the chain the format seems to be getting set to 32 bit unsigned int. <br>


<br></div><div>Not sure if I am doing something wrong... basically my code looks exactly like your example.  I did step through the scifio code a bit and was looking at the translation steps for the meta data.  In TiffFormat.java, "typedTranslate" the format gets set to either 2 or 1 depending on whether it is signed...<br>


<br>firstIFD.putIFDValue(IFD.SAMPLE_FORMAT, FormatTools.isSigned(m<br>                .getPixelType()) ? 2 : 1);<br><br></div><div>In the next step where the translated meta data is set for the destination, it seems to be looking for a sample format of 3 for float.  But the sample format was set to 2 in the previous step...<br>


<br>final int bitFormat = getIFDIntValue(SAMPLE_FORMAT);<br>....<br>case 32:<br>                if (bitFormat == 3) return FormatTools.FLOAT;<br>                return bitFormat == 2 ? FormatTools.INT32 : FormatTools.UINT32; <br>


</div><div><br></div><div>On first glance it would seem to me the SAMPLE_FORMAT should be set to 3 (for float) somehow in the typedTranslate function.   However I'm not overly familiar with the code. <br></div><span class="HOEnZb"><font color="#888888"><div>

<br>
Brian<br></div><div><br></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Dec 4, 2013 at 4:57 PM, Curtis Rueden <span dir="ltr"><<a href="mailto:ctrueden@wisc.edu" target="_blank">ctrueden@wisc.edu</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Brian & everyone,<div><br></div><div><div><div><div>> there is currently a bug in ImgSaver preventing things from working</div>


</div><div>...</div><div><div>> We are working on a fix now and will reply back when the bug is</div>

<div>> resolved.</div></div></div></div><div><br></div><div>Just a quick update that ImgSaver of scifio-0.7.3 is working better. The following code now produces a multi-page TIFF as expected:</div><div><br></div><div>


--snip--</div>

<div><div>import io.scif.SCIFIO;</div><div>import io.scif.img.ImgOpener;</div><div>import io.scif.img.ImgOptions;</div><div>import io.scif.img.ImgOptions.ImgMode;</div><div>import io.scif.img.ImgSaver;</div><div>import net.imglib2.meta.ImgPlus;</div>




<div><br></div><div>public class WriteAnImgPlus {</div><div><span style="white-space:pre-wrap">     </span>public static void main(final String... args) throws Exception {</div><div><span style="white-space:pre-wrap">         </span>final SCIFIO scifio = new SCIFIO();</div>




<div><span style="white-space:pre-wrap">          </span>final ImgOpener opener = new ImgOpener(scifio.getContext());</div><div><br></div><div><span style="white-space:pre-wrap">            </span>// NB: ImgSaver only supports PlanarImg for now!</div>




<div><span style="white-space:pre-wrap">          </span>final ImgOptions options = new ImgOptions().setImgModes(ImgMode.PLANAR);</div><div><span style="white-space:pre-wrap">         </span>final ImgPlus<?> imgPlus =</div>

<div><span style="white-space:pre-wrap">                  </span>opener.openImg("stack&axes=X,Y,Z&lengths=128,128,10.fake", options);</div><div><br></div><div><span style="white-space:pre-wrap">          </span>System.out.println("imgPlus = " + imgPlus);</div>




<div><span style="white-space:pre-wrap">          </span>System.out.println("numDimensions = " + imgPlus.numDimensions());</div><div><span style="white-space:pre-wrap">              </span>for (int d=0; d<imgPlus.numDimensions(); d++) {</div>




<div><span style="white-space:pre-wrap">                  </span>System.out.println("dim #" + d + " = " + imgPlus.dimension(d));</div><div><span style="white-space:pre-wrap">                      </span>System.out.println("axis #" + d + " = " + imgPlus.axis(d).type());</div>




<div><span style="white-space:pre-wrap">          </span>}</div><div><br></div><div><span style="white-space:pre-wrap">               </span>final ImgSaver saver = new ImgSaver(scifio.getContext());</div><div><span style="white-space:pre-wrap">                </span>saver.saveImg("stack.tif", (ImgPlus) imgPlus);</div>




<div><span style="white-space:pre-wrap">  </span>}</div><div>}</div></div><div>--snap--</div><div><br></div><div>As of this writing, please note that you will only be able to save as OME-TIFF if you include the ome-formats library [1] plus dependencies on your classpath.</div>




<div><br></div><div>Regards,</div><div>Curtis</div><div><br></div><div>[1] <a href="https://github.com/scifio/ome-formats" target="_blank">https://github.com/scifio/ome-formats</a></div></div><div><div>
<div class="gmail_extra"><br><br><div class="gmail_quote">

On Thu, Oct 24, 2013 at 1:14 PM, Curtis Rueden <span dir="ltr"><<a href="mailto:ctrueden@wisc.edu" target="_blank">ctrueden@wisc.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr"><div>Hi Brian,<br></div><div><br></div><div>Apologies for the long delay in reply. It is better to write to a public mailing list. I am CCing imagej-devel.</div><div><br></div><div><div><div>> Is the following code snippet still correct given recent changes??</div>








<div>> </div></div><div><div>> AxisType[] ax = new AxisType[3]; ax[0]=Axes.X; ax[1]=Axes.Y;</div><div>> ax[2]=Axes.Z;</div><div>> </div><div>> ImgPlus<T> imgPlus = new ImgPlus<T>(image, name, ax);</div>




<div>



> </div><div>> new ImgSaver().saveImg("name.ome.tif", imgPlus);</div></div></div><div><br></div><div>Firstly, as an aside, please note that ImgSaver has moved from the net.imglib2:imglib2-io project into io.scif:scifio core.</div>





<div><br></div><div>But yes, the above code is still supposed to work.</div><div><br>

</div><div>However, in practice there is currently a bug in ImgSaver preventing things from working correctly.</div><div><br></div><div>Here is a complete (non-)working example:</div>
<div><a href="https://gist.github.com/ctrueden/6234396" target="_blank">https://gist.github.com/ctrueden/6234396</a><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">We are working on a fix now and will reply back when the bug is resolved.</div>





<div class="gmail_extra"><br></div><div class="gmail_extra">Regards,</div><div class="gmail_extra">Curtis</div><div><div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">

On Tue, Aug 13, 2013 at 5:21 AM, Brian Northan <span dir="ltr"><<a href="mailto:bnorthan@gmail.com" target="_blank">bnorthan@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 Curtis<br><br>So after updating imglib this morning I now get lots of errors.  Which is expected after your changes.  So I suspect after I sort through them and rework my code for the changes that saving the axis types will work again.<br>






<br>But one other quick question.  Is the ImageJ2 scripting ready for use??  I looked at it a bit a while ago but it didn't seem quite ready.   I have a series of commands I call, so temporarily I just use a bash script calling Imagej2 in headless mode, with a utility I wrote to parse command name and parameters.   Eventually I will switch to the ImageJ scripting...  is it usable yet or should I wait a few more months?<br>






<br>Thanks, this stuff is really great.<span><font color="#888888"><br><br>Brian  <br></font></span><div><div><br><div class="gmail_quote">On Tue, Aug 13, 2013 at 4:46 AM, Brian Northan <span dir="ltr"><<a href="mailto:bnorthan@gmail.com" target="_blank">bnorthan@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 Curtis<br><br>I have some simple code to wrap an 3D Img<T> as an ImgPlus, define the axis as x,y and z and then save it.  Up until a week or so ago it seemed to work fine.  But now when I read back the image it come in as x, y, t.   Is the following code snippet still correct given recent changes??   Thanks- Brian <br>







<br>AxisType[] ax = new AxisType[3];<br>        ax[0]=Axes.X;<br>        ax[1]=Axes.Y;<br>        ax[2]=Axes.Z;<br><br>ImgPlus<T> imgPlus = new ImgPlus<T>(image, name, ax);<br><br>new ImgSaver().saveImg("name.ome.tif", imgPlus);<br>







<br><div class="gmail_quote"><div><br><br>On Mon, Aug 12, 2013 at 1:39 PM, Curtis Rueden <span dir="ltr"><<a href="mailto:ctrueden@wisc.edu" target="_blank">ctrueden@wisc.edu</a>></span> wrote:<br></div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
<div dir="ltr">Hi all,<div><div><br></div><div><div>> I will merge the img-metadata branch to master on Thursday.</div></div><div><br></div></div><div>Got a bit busy in the interim, but img-metadata is now merged to imglib.git's master branch:</div>









<div><br></div><div><a href="https://github.com/imagej/imglib/commit/e4e26aa05e0f42ff1a90e8c6d67235431471de44" target="_blank">https://github.com/imagej/imglib/commit/e4e26aa05e0f42ff1a90e8c6d67235431471de44</a><br></div>







<div><br></div>
<div>
The commit message gives a quick gist of the changes, including future directions.</div><div><br></div><div>Please let me know of any questions or problems with it!</div><div><br></div><div>Regards,</div><div>Curtis</div>









</div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 30, 2013 at 10:28 AM, Curtis Rueden <span dir="ltr"><<a href="mailto:ctrueden@wisc.edu" target="_blank">ctrueden@wisc.edu</a>></span> wrote:<br>









<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all, and especially ImgLib2 developers,<div><br></div><div>At the ImgLib2 hackathon this past May, I started work on a branch to make it easier to attach per-axis metadata to N-dimensional spaces. I think this branch is finally in a merge-worthy state.</div>











<div><br></div><div>It introduces an AnnotatedSpace extension to EuclideanSpace which lets you attach on Axis per dimension. It defines TypedSpace, which declares an AxisType for each Axis, as well as a CalibratedSpace, which in addition adds a calibration value and optional unit name to the mix.</div>











<div><br></div><div>This approach is much more flexible than the previous CalibratedSpace, which has been renamed to OldCalibratedSpace and deprecated until we can fully transition all the code away from it. In particular, having the axes attached to the space directly will allows Views to maintain the axis metadata without much additional work.</div>











<div><br></div><div>Note that these new classes are defined in the net.imglib2.meta component, which was split into a separate module called imglib2-meta. The ImgPlus class moved there, too (it should have been there all along). So merging this branch will cause some code breakage, but all should be straightforward to fix: rename usages of CalibratedSpace to OldCalibratedSpace, and rename the ImgPlus package from net.imglib2.img to net.imglib2.meta.</div>











<div><br></div><div>Going forward, we can also add a CalibratedViews class to the net.imglib2.meta package which has some additional features such as exposing resampled Imgs from a source CalibratedSpace into a target one based on the units used. We can lean on a units library for this, as we have discussed in the past.</div>











<div><br></div><div>If interested, you can browse the branch at:</div><div><a href="https://github.com/imagej/imglib/compare/img-metadata" target="_blank">https://github.com/imagej/imglib/compare/img-metadata</a><br></div>










<div><br></div>
<div>If no one objects, I will merge the img-metadata branch to master on Thursday.</div><div><br></div><div>Regards,</div><div>Curtis</div><div><br></div></div>
</blockquote></div><br></div>
</div></div><br></div>_______________________________________________<br>
ImageJ-devel mailing list<br>
<a href="mailto:ImageJ-devel@imagej.net" target="_blank">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>
<br></blockquote></div><br>
</blockquote></div><br>
</div></div></blockquote></div><br></div></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div><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>
<br></blockquote></div><br></div>