NITRC Computational Morphometry Toolkit (CMTK) Forum: users
http://www.nitrc.org/forum/forum.php?forum_id=857
Forum for CMTK User questionsen-usCopyright 2000-2019 NITRC OSIThu, 20 Jun 2019 11:30:24 GMThttp://blogs.law.harvard.edu/tech/rssNITRC RSS generatorRE: Applying transformation matrix from dof2mat to a traced neuron (swc) file
http://www.nitrc.org/forum/forum.php?thread_id=10305&forum_id=857
[i]Originally posted by Zane Aldworth:[/i][quote][i]Originally posted by Greg Jefferis:[/i][quote]Thanks, Greg. I had previously been trying to transpose the matrix, but it ended up being the latter case of needing the inverse of the transformation matrix.[/quote][/quote]<br />
Glad that was quickly sorted out.[quote][quote]And I'm specifically happy to get advice from you, as now that I have a set of registered, traced neurons, I would like to compare them to each other using NBLAST.[/quote][quote]I imagine this is a conversation we could/should have elsewhere, but I'd love some advice on how to run NBLAST on pairs of my own (non-fly) neurons. Is there a best manner to contact you for such a query?[/quote][/quote]Queries welcome at https://groups.google.com/forum/#!forum/nat-user<br />
<br />
Best, Greg.Greg JefferisTue, 18 Jun 2019 18:13:57 GMThttp://www.nitrc.org/forum/forum.php?thread_id=10305&forum_id=857RE: Applying transformation matrix from dof2mat to a traced neuron (swc) file
http://www.nitrc.org/forum/forum.php?thread_id=10305&forum_id=857
Thanks, Torsten.Zane AldworthTue, 18 Jun 2019 17:02:39 GMThttp://www.nitrc.org/forum/forum.php?thread_id=10305&forum_id=857RE: Applying transformation matrix from dof2mat to a traced neuron (swc) file
http://www.nitrc.org/forum/forum.php?thread_id=10305&forum_id=857
[i]Originally posted by Greg Jefferis:[/i][quote][color=#000000]Dear Zane,[/color]<br />
[/quote][quote]1. a difference in the convention for row-major and column-major representation of the matrix. Essentially you may need to transpose.<br />
2. a difference in your expectations about the transformation direction. You may actually want the inverse of what you have tried to apply.<br />
[/quote][quote]<br />
[/quote][quote]Thanks, Greg. I had previously been trying to transpose the matrix, but it ended up being the latter case of needing the inverse of the transformation matrix.[/quote][quote]And I'm specifically happy to get advice from you, as now that I have a set of registered, traced neurons, I would like to compare them to each other using NBLAST.[/quote][quote]I imagine this is a conversation we could/should have elsewhere, but I'd love some advice on how to run NBLAST on pairs of my own (non-fly) neurons. Is there a best manner to contact you for such a query?[/quote][quote]<br />
[/quote][quote]Cheers,[/quote][quote]Zane[/quote]Zane AldworthTue, 18 Jun 2019 17:01:36 GMThttp://www.nitrc.org/forum/forum.php?thread_id=10305&forum_id=857RE: Applying transformation matrix from dof2mat to a traced neuron (swc) file
http://www.nitrc.org/forum/forum.php?thread_id=10305&forum_id=857
Thanks Greg - I think you pretty much covered the possible sources of errors :)<br />
<br />
Just to add a bit of theoretical background why often one would want the inverse transformation:<br />
<br />
Say you align image A to image B via transform X such that you can reslice B to match A.<br />
<br />
Then if your neuron model is in the coordinates of image B, in order to get it transformed into the space of A, you need to apply the inverse of X.<br />
<br />
That is because for reslicing, one takes the coordinate of each pixel in A, maps it to B via X, then pulls back the interpolated image intensity from B. So intensities move the opposite direction between coordinate systems as do geometries (e.g., pixel or model coordinates).<br />
<br />
Best,<br />
TorstenTorsten RohlfingTue, 18 Jun 2019 16:05:34 GMThttp://www.nitrc.org/forum/forum.php?thread_id=10305&forum_id=857RE: Applying transformation matrix from dof2mat to a traced neuron (swc) file
http://www.nitrc.org/forum/forum.php?thread_id=10305&forum_id=857
[color=#000000]Dear Zane,[/color]<br />
[i]Originally posted by Zane Aldworth:[/i][quote]Since brain registration usually involves a decrease in image resolution, we'd like to trace the neurons in the original images, perform the registration to a template brain, and then apply the transformation matrix from said registration to the traced neuron.<br />
[/quote]<br />
This is generally the best thing to do, but can be a little bit more fiddly.[quote]The dof2mat seems to be the correct tool,[/quote]<br />
I take it you are only trying to apply affine transformations?[quote]however when I apply the matrix to my swc file (in Matlab), the traced neuron is significantly off from transformed image. The misalignment is beyond just a simple translation, and appears to consist of both rotation and shear errors.<br />
[/quote]<br />
It is most likely that you have not interpreted the matrix correctly (or at least in the same way as CMTK!). The two most common problems are:<br />
<br />
1. a difference in the convention for row-major and column-major representation of the matrix. Essentially you may need to transpose.<br />
2. a difference in your expectations about the transformation direction. You may actually want the inverse of what you have tried to apply.<br />
<br />
I have regularly encountered these issues when working with different transform tools / representations. I actually use an R-based toolkit (https://jefferis.github.io/nat/) to look after the details. The minimal approach would look like this:<br />
[code]library(nat)<br />
nl=read.neurons('/path/to/inputneurons/')<br />
nlt=xform(nl, 'path/to/cmtk/transform')<br />
write.neurons(nlt, 'path/to/outputneurons/', format='swc')[/code]<br />
If you need to apply different transforms for each neuron then a little more effort is required to match neurons to transform. If you are interested then we would be happy to support your use of this toolkit over at https://groups.google.com/forum/#!forum/nat-user.<span id="_plain_text_marker"> </span><br />
<span><br />
</span>[quote]Are there any known issues that would cause the error with this workflow? [/quote]<br />
No.[quote]Should I instead be trying to sequentially apply the translation/rotation/scale/shear matrices from the xform file? [/quote]<br />
No. Best to use a single matrix multiplication of the homogenous affine transformation matrix.<br />
<br />
Best wishes,<br />
<br />
Greg Jefferis.Greg JefferisTue, 18 Jun 2019 10:12:15 GMThttp://www.nitrc.org/forum/forum.php?thread_id=10305&forum_id=857Applying transformation matrix from dof2mat to a traced neuron (swc) file
http://www.nitrc.org/forum/forum.php?thread_id=10305&forum_id=857
Hi,<br />
<br />
I'm having problems applying the transform matrix from dof2mat to traced neurons.<br />
A little background for my problem: we're trying to trace neurons from many different insect brains in different alignments. Since brain registration usually involves a decrease in image resolution, we'd like to trace the neurons in the original images, perform the registration to a template brain, and then apply the transformation matrix from said registration to the traced neuron.<br />
<br />
The dof2mat seems to be the correct tool, however when I apply the matrix to my swc file (in Matlab), the traced neuron is significantly off from transformed image. The misalignment is beyond just a simple translation, and appears to consist of both rotation and shear errors.<br />
<br />
Are there any known issues that would cause the error with this workflow? Should I instead be trying to sequentially apply the translation/rotation/scale/shear matrices from the xform file? If so, what are the units on these sub matrices (radians on the rotation matrix, microns on the translation, etc?)<br />
<br />
Thanks!Zane AldworthMon, 17 Jun 2019 19:36:59 GMThttp://www.nitrc.org/forum/forum.php?thread_id=10305&forum_id=857RE: average_image : output in 16 bits?
http://www.nitrc.org/forum/forum.php?thread_id=10189&forum_id=857
Hi Guillaume - sorry for the delay.<br />
<br />
CMTK actually has an image conversion tool, convertx, which supports pixel type conversions.<br />
<br />
As for the question why your average images exceeded the value range of the input images - when you reslice images using higher-order interpolation (cubic or sinc), then such overruns can occur simply because of the coefficients of the interpolation kernels. Not sure this is what happened here, but if you did use higher-order interpolation, it would be absolutely expected.<br />
<br />
Best,<br />
TorstenTorsten RohlfingFri, 10 May 2019 1:57:04 GMThttp://www.nitrc.org/forum/forum.php?thread_id=10189&forum_id=857RE: average_image : output in 16 bits?
http://www.nitrc.org/forum/forum.php?thread_id=10189&forum_id=857
I think there was a problem with my preprocessing and rescaling. It is now fixed and I had no trouble converting the output 32bit average image in 16bit with ImageJ. Still, it could be a nice feature to add in the future to the average_images function.<br />
For reference, I used NRRD file generated from TIFF stacks through MATLAB.<br />
<br />
Thanks for your help.<br />
<br />
GuillaumeGuillaume Le GocThu, 09 May 2019 14:34:32 GMThttp://www.nitrc.org/forum/forum.php?thread_id=10189&forum_id=857RE: average_image : output in 16 bits?
http://www.nitrc.org/forum/forum.php?thread_id=10189&forum_id=857
Torsten is the right person to respond here and you may need to give an example e.g. some small input images and an output image if debugging is required.<br />
<br />
Assuming that you have used the default behaviour of average_images, I believe it should just calculate the simple mean of the input images. What format are they in? Is it possible that they have some kind of calibration (which could be stored in a nii file).<br />
<br />
You could show stack histograms from ImageJ or use the cmtk histogram tool to show full histogram inc min / max information for your inputs and outputs.<br />
<br />
Best,<br />
<br />
Greg.Greg JefferisTue, 07 May 2019 17:19:15 GMThttp://www.nitrc.org/forum/forum.php?thread_id=10189&forum_id=857average_image : output in 16 bits?
http://www.nitrc.org/forum/forum.php?thread_id=10189&forum_id=857
Hi there,<br />
I am using CMTK to register several stacks on one, and then I averaged them to make a mean stack.<br />
To do so, I used the included average_images tool. But I see there's only two options for the output image : single (which result in a 32bits image) and double.<br />
I would like to have a 16 bits output stack. All input stack are in 16 bit.<br />
I tried to convert it to 16bit through ImageJ, but some values are out of range and cap at 65535. How is it possible since all input are 16bit (65535 max) ?<br />
<br />
Thanks for your help and work,<br />
<br />
GuillaumeGuillaume Le GocTue, 07 May 2019 14:45:05 GMThttp://www.nitrc.org/forum/forum.php?thread_id=10189&forum_id=857