Dear ImageJ list members,
I hope that some of the image processing experts here can help me with some 3D affine transformations I am currently struggling with. I am trying to deskew light sheet data that is recorded by a diSPIM light sheet setup, where two lenses are mounted above a coverslip – they have a 90° angle towards each other and an angle of 45° to the cover slip. The light sheet and the objective lenses are synchronously scanned to generate fast volumetric data. Normally, I use Stephan Preibisch’s fantastic “Multiview Reconstruction” plugin to rotate the single views and/or fuse the two viewpoints. However, in a recent upgrade of the acquisition software, the microscope gained the ability to record data by stage scanning. This has the huge advantage that we can acquire very fast and have a fixed light sheet, removing the need to synchronously move the excitation sheet with the imaging lense. This makes the overall handling much easier. The problem with this is that the imaging planes are oriented at a 45°(and 135° for the second view) angle in relation to the movement direction of the stage, meaning that the resulting data is skewed in one direction. The second problem is that the voxel size is anisotropic. We move the XY—stage in discrete steps (in most cases 0.5 um or 1 um in X, but we can choose the step size) and our pixel size is 0.165 um.) I have tried descewing the data by using Eric Meijering’s TransformJ , using affine shear operations, but I am at a loss how to bring in the anisotropy / different pixel sizes in the deskewing matrix. The same problem occurs when I want to rotate my data recorded by light sheet/objective scanning, where I also would have to account for anisotropic voxels. I think that I have to account for the recording angle and the step size, however, I am not sure how I calculate the scaling factors. I have found some literature on the net, however, most of what I fund is dealing with isotropic voxel sizes. I assume that there are some easy formulas with which one would calculate the respective skewing/scaling factors to account for the anisotropic pixel sizes. I hope that somebody here has some experience with this and can send me in the right direction. Thanks a lot! Kay Kay Oliver Schink Dept. of Molecular Cell Biology - Stenmark lab Institute for Cancer research The Norwegian Radium Hospital Ullernchausseen 70 - Montebello 0379 Oslo Norway -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Kay,
> I am trying to deskew light sheet data that is recorded by a diSPIM light sheet setup. The light sheet and the objective lenses are synchronously scanned to generate fast volumetric data. Normally, I use Stephan Preibisch’s fantastic “Multiview Reconstruction” plugin to rotate the single views and/or fuse the two viewpoints. > However, in a recent upgrade of the acquisition software, the microscope gained the ability to record data by stage scanning. > I have tried descewing the data by using Eric Meijering’s TransformJ. Using the TransformJ plugin, I used the following matrices for this purpose. For channel 1: -0.5 0 6.06 0 0 1 0 0 -1 0 0 0 0 0 0 1 For channel 2: B * A; -0.5 0 -6.06 0 0 1 0 0 1 0 0 0 0 0 0 1 These matrices will transform the image such that you will look at the sample from the top (or bottom), just as you are used to with a normal microscope. Since this corrects for the difference in pixel size between x/y and z, make sure to set the pixel size (Image > Properties) for all dimensions to 1 before opening the data set in a 3D viewer (b.t.w.: Clear Viewer is great!). To do something similar in Stephan's Multiview Reconstruction plugin, I used the matrix: (1.0, 0.0, 0.5, 0.0,) (0.0, 1.0, 0.0, 0.0,) (0.0, 0.0, 1.0, 0.0) for channel 1, and (1.0, 0.0, -0.5, 0.0,) (0.0, 1.0, 0.0, 0.0,) (0.0, 0.0, 1.0, 0.0) for the other. These are applied after the regular pixel size transform and the rotation over the y-axis. There is still a significant shift in x after these transforms (maybe dependent on the experimental conditions). At this point, I am having trouble to find enough points for registration (will try to sprinkle in some beads in the future), but very much would like to see an intensity based registration that can do the job. B.t.w., it would be great if this information could live on the diSPIM wiki: http://dispim.org/ (probably after it all really works). Best, Nico -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Kay Oliver Schink
Hi all,
I'm trying to find information on the methods getCalibration and setGlobalCalibration in the Imagej API and i've looked in ij.measure.Calibration class but can't find them there. Also i'm editing a plugin which has an if statement which begins: if (doDialog)) { Which seems to be referring to a variable called "doDialog" yet this variable is not declared anywhere in the plugin, am i missing something? Thanks, Matt -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Matt,
It's a little difficult to tell what you want specifically but getCalibration and setGlobalCalibration are member functions of the ImagePlus class (http://rsb.info.nih.gov/ij/developer/api/ij/ImagePlus.html) and they use the ij.measure.Calibration class you found. For your question related to the dialog it might be good to provide the code. In the meantime though, maybe check the class that the plugin is extending for member functions or variables with 'doDialog'. My guess is that is actually a method call (i.e., 'if (doDialog())') and probably using a GenericDialog, maybe in the super class. HTH, John Le 28 juil. 2015 à 14:14, PEARSON Matthew a écrit : > Hi all, > > I'm trying to find information on the methods getCalibration and setGlobalCalibration in the Imagej API and i've looked in ij.measure.Calibration class but can't find them there. > > Also i'm editing a plugin which has an if statement which begins: > if (doDialog)) { > > Which seems to be referring to a variable called "doDialog" yet this variable is not declared anywhere in the plugin, am i missing something? > > Thanks, > > Matt > > > > -- > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by PEARSON Matthew
Hi Wayne,
Thats good to know thanks. The code below comes from the Microscope Scale plugin: public void run(ImageProcessor ip) { if (doDialog()) { Calibration oc = imp.getCalibration().copy(); oc.setUnit(units[magIndex]); oc.pixelWidth=xscales[magIndex]; oc.pixelHeight=oc.pixelWidth; if (isGlobalCal) { imp.setGlobalCalibration(oc); int[] list = WindowManager.getIDList(); if (list==null) return; for (int i=0; i<list.length; i++) { ImagePlus imp2 = WindowManager.getImage(list[i]); if (imp2!=null) imp2.getWindow().repaint(); } } else { imp.setGlobalCalibration(null); imp.setCalibration(oc); imp.getWindow().repaint(); } if (addScaleBar){ IJ.run("Scale Bar..."); } } } Thanks, Matt On 28 Jul 2015, at 19:25, "Rasband, Wayne (NIH/NIMH) [E]" <[hidden email]<mailto:[hidden email]>> wrote: Hi Matt, On Jul 28, 2015, at 2:14 PM, PEARSON Matthew <[hidden email]<mailto:[hidden email]>> wrote: Hi all, I'm trying to find information on the methods getCalibration and setGlobalCalibration in the Imagej API and i've looked in ij.measure.Calibration class but can't find them there. The getCalibration() and setGlobalCalibration() methods are in the ImagePlus class. Also i'm editing a plugin which has an if statement which begins: if (doDialog)) { Which seems to be referring to a variable called "doDialog" yet this variable is not declared anywhere in the plugin, am i missing something? I is difficult to answer a question like this without seeing the plugin’s source code. Could you make is available? Best regards, -wayne -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by PEARSON Matthew
Hi,
this is not specific to your question, but I have recently discovered "Javadoc Search Frame", which is available as an extension to Chrome and Firefox and makes it very easy to explore any Java API and answer questions like the ones you're asking. https://chrome.google.com/webstore/detail/javadoc-search-frame/mfgkihmpcjjnijmkchojlbccbmhcdfcd?hl=en On Tue, Jul 28, 2015 at 6:14 PM, PEARSON Matthew < [hidden email]> wrote: > Hi all, > > I'm trying to find information on the methods getCalibration and > setGlobalCalibration in the Imagej API and i've looked in > ij.measure.Calibration class but can't find them there. > > Also i'm editing a plugin which has an if statement which begins: > if (doDialog)) { > > Which seems to be referring to a variable called "doDialog" yet this > variable is not declared anywhere in the plugin, am i missing something? > > Thanks, > > Matt > > > > -- > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by PEARSON Matthew
The private method doDialog() is in the class, but not in your code
snippet. http://rsb.info.nih.gov/ij/plugins/download/Microscope_Scale.java On Tue, Jul 28, 2015 at 6:33 PM, PEARSON Matthew < [hidden email]> wrote: > Hi Wayne, > > Thats good to know thanks. The code below comes from the Microscope Scale > plugin: > > public void run(ImageProcessor ip) { > if (doDialog()) { > Calibration oc = imp.getCalibration().copy(); > oc.setUnit(units[magIndex]); > oc.pixelWidth=xscales[magIndex]; > oc.pixelHeight=oc.pixelWidth; > if (isGlobalCal) { > imp.setGlobalCalibration(oc); > int[] list = WindowManager.getIDList(); > if (list==null) return; > for (int i=0; i<list.length; i++) { > ImagePlus imp2 = > WindowManager.getImage(list[i]); > if (imp2!=null) > imp2.getWindow().repaint(); > } > } else { > imp.setGlobalCalibration(null); > imp.setCalibration(oc); > imp.getWindow().repaint(); > } > if (addScaleBar){ > IJ.run("Scale Bar..."); > } > } > } > > > Thanks, > > Matt > > > > On 28 Jul 2015, at 19:25, "Rasband, Wayne (NIH/NIMH) [E]" < > [hidden email]<mailto:[hidden email]>> > wrote: > > Hi Matt, > > On Jul 28, 2015, at 2:14 PM, PEARSON Matthew < > [hidden email]<mailto:[hidden email]>> > wrote: > > Hi all, > > I'm trying to find information on the methods getCalibration and > setGlobalCalibration in the Imagej API and i've looked in > ij.measure.Calibration class but can't find them there. > > The getCalibration() and setGlobalCalibration() methods are in the > ImagePlus class. > > Also i'm editing a plugin which has an if statement which begins: > if (doDialog)) { > > Which seems to be referring to a variable called "doDialog" yet this > variable is not declared anywhere in the plugin, am i missing something? > > I is difficult to answer a question like this without seeing the plugin’s > source code. Could you make is available? > > Best regards, > > -wayne > > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by PEARSON Matthew
Hi david,
Ah yes now I see it! Sorry should open my eyes next time. And thanks for the note on chrome that could be very useful! Cheers, Matt -------- Original message -------- From: Davíð Þór Bragason <[hidden email]> Date: 28/07/2015 19:57 (GMT+00:00) To: [hidden email] Subject: Re: Java questions Hi, this is not specific to your question, but I have recently discovered "Javadoc Search Frame", which is available as an extension to Chrome and Firefox and makes it very easy to explore any Java API and answer questions like the ones you're asking. https://chrome.google.com/webstore/detail/javadoc-search-frame/mfgkihmpcjjnijmkchojlbccbmhcdfcd?hl=en On Tue, Jul 28, 2015 at 6:14 PM, PEARSON Matthew < [hidden email]> wrote: > Hi all, > > I'm trying to find information on the methods getCalibration and > setGlobalCalibration in the Imagej API and i've looked in > ij.measure.Calibration class but can't find them there. > > Also i'm editing a plugin which has an if statement which begins: > if (doDialog)) { > > Which seems to be referring to a variable called "doDialog" yet this > variable is not declared anywhere in the plugin, am i missing something? > > Thanks, > > Matt > > > > -- > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > -- > 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 The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Kay Oliver Schink
Hi Niko,
thanks a lot, that works! I applied it to my data (so far my testing set is iSPIM data) and it looks good! Can you give me some hints how you got to this matrix? I am asking since a different stage step would probably require a different matrix, right? Assuming the matrix looks like A B C D E F G H I J K L M N O P I see that you scale the x-axis by -0.5 (A) and skew for 45° with the "1" at position I , but how did you get to the 6.06 at position C? And why is there a 0 at position K, should it not be a 1 to keep the overall scaling intact? I am sorry if this should be obvious, I am trying to understand how this works, but so far these matrices are way out of my usual comfort zone.. Thanks a lot Kay -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Kay,
> thanks a lot, that works! > > I applied it to my data (so far my testing set is iSPIM data) and it looks good! > > Can you give me some hints how you got to this matrix? I have the following notes: PIxel size is 0.165 micron in x and y, 1 micron in z -> Z needs to be enlarged by a factor of 6.06. Also rotate by 90 degrees over the y axis yields matrix A: 0 0 6.06 0 0 1 0 0 -1 0 0 0 0 0 0 1 Now skew over the z axis (matrix B): 1 0 0.5 0 0 1 0 0 0 0 1 0 0 0 0 1 In this case we need to multiple B * A, which yields: -0.5 0 6.06 0 0 1 0 0 -1 0 0 0 0 0 0 1 For the other side I used: Matrix A: 0 0 -6.06 0 0 1 0 0 1 0 0 0 0 0 0 1 Matrix B: 1 0 -0.5 0 0 1 0 0 0 0 1 0 0 0 0 1 > I am asking since a different stage step would probably require a different matrix, right? Yes, this is for 1 micron step size. If you change the step size, change the factor 6.06 in the very first matrix, and multiply B * A. Best, Nico -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
An easy mental mechanism to understand affine matrices is that the
columns in the leading n*n block represent the transformed x,y,z,... axes of the original coordinate space in transformed coordinate space, 3d example for matrix A: x y z . . . a b c A = d e f g h i i.e. x = (1,0,0)T x' = Ax = (a,d,g)T y = (0,1,0)T y' = Ax = (b,e,h)T z = (0,0,1)T z' = Ax = (c,f,i)T the fourth column is the location t of the translated origin, and the rest is 0001, mapping this into homogeneous space to be able to do x' = Ax + t in a single matrix multiplication x' = Ax Cheers, Stephan On Tue, 2015-07-28 at 21:50 -0700, Nico Stuurman wrote: > Hi Kay, > > > thanks a lot, that works! > > > > I applied it to my data (so far my testing set is iSPIM data) and it looks good! > > > > Can you give me some hints how you got to this matrix? > I have the following notes: > > PIxel size is 0.165 micron in x and y, 1 micron in z -> Z needs to be > enlarged by a factor of 6.06. Also rotate by 90 degrees over the y axis > yields matrix A: > > 0 0 6.06 0 > 0 1 0 0 > -1 0 0 0 > 0 0 0 1 > > Now skew over the z axis (matrix B): > > 1 0 0.5 0 > 0 1 0 0 > 0 0 1 0 > 0 0 0 1 > > In this case we need to multiple B * A, which yields: > > -0.5 0 6.06 0 > 0 1 0 0 > -1 0 0 0 > 0 0 0 1 > > > For the other side I used: > > Matrix A: > 0 0 -6.06 0 > 0 1 0 0 > 1 0 0 0 > 0 0 0 1 > > > Matrix B: > 1 0 -0.5 0 > 0 1 0 0 > 0 0 1 0 > 0 0 0 1 > > > I am asking since a different stage step would probably require a different matrix, right? > Yes, this is for 1 micron step size. If you change the step size, > change the factor 6.06 in the very first matrix, and multiply B * A. > > Best, > > Nico > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Kay,
I will add support for the stage-scanning to the Multiview Reconstruction (http://fiji.sc/Multiview-Reconstruction <http://fiji.sc/Multiview-Reconstruction>) <http://fij/> very soon, it is pretty straight forward as a pre-processing step and it will allow for all further reconstruction steps. All the best, Stephan --- Dr. Stephan Preibisch Group Leader Berlin Institute of Medical Systems Biology of the MDC email: [hidden email] <mailto:[hidden email]> web: http://www.preibisch.net/\ <http://www.preibisch.net/%5C> > On 29 Jul 2015, at 17:04, Saalfeld, Stephan <[hidden email]> wrote: > > An easy mental mechanism to understand affine matrices is that the > columns in the leading n*n block represent the transformed x,y,z,... > axes of the original coordinate space in transformed coordinate space, > 3d example for matrix A: > > > x y z > . . . > > a b c > A = d e f > g h i > > > i.e. > > x = (1,0,0)T x' = Ax = (a,d,g)T > y = (0,1,0)T y' = Ax = (b,e,h)T > z = (0,0,1)T z' = Ax = (c,f,i)T > > > the fourth column is the location t of the translated origin, and the > rest is 0001, mapping this into homogeneous space to be able to do > > x' = Ax + t > > in a single matrix multiplication > > x' = Ax > > Cheers, > Stephan > > > > > > On Tue, 2015-07-28 at 21:50 -0700, Nico Stuurman wrote: >> Hi Kay, >> >>> thanks a lot, that works! >>> >>> I applied it to my data (so far my testing set is iSPIM data) and it looks good! >>> >>> Can you give me some hints how you got to this matrix? >> I have the following notes: >> >> PIxel size is 0.165 micron in x and y, 1 micron in z -> Z needs to be >> enlarged by a factor of 6.06. Also rotate by 90 degrees over the y axis >> yields matrix A: >> >> 0 0 6.06 0 >> 0 1 0 0 >> -1 0 0 0 >> 0 0 0 1 >> >> Now skew over the z axis (matrix B): >> >> 1 0 0.5 0 >> 0 1 0 0 >> 0 0 1 0 >> 0 0 0 1 >> >> In this case we need to multiple B * A, which yields: >> >> -0.5 0 6.06 0 >> 0 1 0 0 >> -1 0 0 0 >> 0 0 0 1 >> >> >> For the other side I used: >> >> Matrix A: >> 0 0 -6.06 0 >> 0 1 0 0 >> 1 0 0 0 >> 0 0 0 1 >> >> >> Matrix B: >> 1 0 -0.5 0 >> 0 1 0 0 >> 0 0 1 0 >> 0 0 0 1 >> >>> I am asking since a different stage step would probably require a different matrix, right? >> Yes, this is for 1 micron step size. If you change the step size, >> change the factor 6.06 in the very first matrix, and multiply B * A. >> >> Best, >> >> Nico >> >> -- >> 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 |
In reply to this post by Kay Oliver Schink
Hi Nico and Stephan,
thanks a lot, it is much clearer now. The rotations and resizing are now clear - I was initally confused because I was working with 0.5 um stepping size, which of course yields different values. However, I have one more question (sorry).. I am not sure how you got the shearing factor in the second matrix. I have found from other sources that the scew ratio is defined by tan(theta) (or rather tan(deg2rad(theta)), with theta being the 45° angle of the light sheet in relation to the moving axis. However, for 45°, this yields not 0.5, but rather 1.0, which would result in the matrix -1 0 6.06 0 0 1 0 0 -1 0 0 0 0 0 0 1 If I apply this to my data set, the planes and scaling look fine, whereas they still look slightly skewed if I use 0.5 instead. Am I now completely wrong again? Thanks for your input! Kay -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Stephan Preibisch
Hi Stephan,
> I will add support for the stage-scanning to the Multiview Reconstruction (http://fiji.sc/Multiview-Reconstruction <http://fiji.sc/Multiview-Reconstruction>) <http://fij/> very soon, it is pretty straight forward as a pre-processing step and it will allow for all further reconstruction steps. What is involved in that other than the de-skewing using the matrices: (1.0, 0.0, 0.5, 0.0,) (0.0, 1.0, 0.0, 0.0,) (0.0, 0.0, 1.0, 0.0) for channel 1, and (1.0, 0.0, -0.5, 0.0,) (0.0, 1.0, 0.0, 0.0,) (0.0, 0.0, 1.0, 0.0) for the other ? It would be really great to have an intensity-based registration method. The interest point-based approach does not work at all for my stage scanning samples (I can make some available off-list if you are interested). Best, Nico -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Nico,
the next major version will have an intensity-based registration … I think it will be a great addition for samples that are almost aligned like these data. I will write you off-list for the example dataset. Thanks a lot, Stephan --- Dr. Stephan Preibisch Group Leader Berlin Institute of Medical Systems Biology of the MDC email: [hidden email] <mailto:[hidden email]> web: http://www.preibisch.net/ <http://fly.mpi-cbg.de/preibisch> > On 29 Jul 2015, at 19:54, Nico Stuurman <[hidden email]> wrote: > > Hi Stephan, > >> I will add support for the stage-scanning to the Multiview Reconstruction (http://fiji.sc/Multiview-Reconstruction <http://fiji.sc/Multiview-Reconstruction>) <http://fij/> very soon, it is pretty straight forward as a pre-processing step and it will allow for all further reconstruction steps. > What is involved in that other than the de-skewing using the matrices: > (1.0, 0.0, 0.5, 0.0,) (0.0, 1.0, 0.0, 0.0,) (0.0, 0.0, 1.0, 0.0) for channel 1, and > (1.0, 0.0, -0.5, 0.0,) (0.0, 1.0, 0.0, 0.0,) (0.0, 0.0, 1.0, 0.0) for the other ? > > It would be really great to have an intensity-based registration method. The interest point-based approach does not work at all for my stage scanning samples (I can make some available off-list if you are interested). > > Best, > > Nico > > > > > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |