Hi everybody
I’m working on 3d stacks of images of rat brains from confocal microscopy. I have to register them to an Allen standard template, so I’m testing AFNI on this.
I’m getting quite good results with 3dQwarp. Nonetheless, I need to further improve these results. I have a set of markers (or tagsets, as you call them in 3dTagalign) matching points in the atlas with points in the confocal images. Is there anyway I can integrate this information in a pipeline for nonlinear image coregistration?
PS: is plug_tag still available? I’d need a tool to insert custom markers in the header, setting attributes such as TAGSET_NUM, TAGSET_FLOATS. TAGSET_LABELS. I can not find the plug_tag tool tho.
I have been trying something like
x0=5.72
y0=2.30
z0=6.76
x1=5.70
y1=3.47
z1=6.76
3drefit -atrstring TAGSET_FLOATS “$x0 $y0 $z0 0 0 $x1 $y1 $z1 1 0” $dataset_name
but then the output of
3dAttribute TAGSET_FLOATS $dataset_name
is empty
Unlike 3dTagalign for affine alignment, 3dQwarp does not provide for tags in the alignment directly; however, you can be target particular locations. One way is to increase the weights at target points with the -weight option or the weight-enhancing options of -wball and -wmask. Besides that, you can also change the penalty factors with -penfac or -nopenalty to allow for bending in the warp.
Which Allen template are you using, and what is the use case here?
Hi, thanks for the kind reply
I’m trying to coregister images acquired with confocal microscopy with 25 micron isotropic resolution to the NISSL coronal Allen brain atlas (https://mouse.brain-map.org/static/atlas) obtained by converting to nifti a stack of tiff. As I said, results are almost satisfying, in particular for what regards outer edges, while there is still space for improvement in inner edges, maybe also due to the different contrast.
I will try to use the weights and penalty factors and keep you updated, thanks.
Meanwhile, is there any way you can help me with adding markers in the dataset header?
As mentioned, I tried with
3drefit -atrstring TAGSET_FLOATS “x0 y0 z0 0 0 x1 y1 z1 1 0 x2…” dataset_name
but it does not seem to work.
I would like to try to alternate stages of 3dQWarp with stages of 3dTagalign, but to do that, I have to be able to provide the tagsets to 3dTagalign
You can subdivide your output for particular regions of interest. The most obvious way to create tags is with the Tagset plugin. You can mark the tags there or read the tags from a file with this format below. The attribute in the header gets updated from that.
Multiple alignments would introduce multiple interpolations that may be more important to you. You can combine affine and nonlinear warps with 3dNwarpCat or with 3dNwarpApply.
In past work with similar microscopy data and this template, you will need to take into account the large amount of data and memory limits. Downsampling the data can help, depending on the needed final resolution. Also depending on the type of histology you are doing, you may want different kinds of alignment cost functions or blurring/feature sizes in the alignment process. I’ve used these commands for alignment with good results.
align data to Allen mouse template with affine transformation
Thank you so much for the detailed reply.
I managed to save the tags in the .HEAD using the plugin.
The 3dQwarp command I was testing is quite similar to the one you suggested, I only have to further test the workhard option. Using the option -iniwarp and always the same image as source I guess that I will have no problems of resampling.
Two more questions:
I tested 3dTagalign: how is this program working? Is it matching tags by label? I have for both datasets a set of tags with the same labels, but sometimes tags are close to each other, so I was wondering if the matching is computed between labels pairs.
I see that after warping a dataset with 3dQwarp, the tags in the header disappear. Is there a way to obtain a new warped dataset with updated tags in the header? Or should I find a way to apply the warp to the markers externally, and then use again the plugin to assign them to the new header?
(is there a 3dNwarpApply function for vectors??)
That all sounds good. I’ve recently been moving markers around too, and I’m happy to send that script if you would like. There is 3dNwarpXYZ for coordinates that you could apply to tag coordinates. Provide an xyz.1D file with 3 columns of coordinates in RAI order (Right-to-left, Anterior-to-posterior, Inferior-to-superior).
3dTagalign requires the order match exactly. Labels are a convenience. The method works by finding a least squares solution. This information is excerpted from the source, thd_shear3d.c, DLSQ_affine() function:
Compute an affine transformation to take one set of vectors into another.
That is, find general matrix R and vector V so that
yy = [R] xx + V (k=0..n-1)
k k
is true in the unweighted least squares sense.
Wow, 3dNwarpXYZ is exactly what I was looking for, thank you, I couldn’t find it. I’ll work on it, but yes of course, I would be happy to have that script!
Thank you for the excellent support
PS: now I have all the tools, but of course a scriptable way to insert markers in the header would be awesome.
Is there any news on the plug_tag.c function? Or maybe some way to use the tagset.h file?
EDIT: I SEE THAT ACTUALLY 3DTAGALIGN HAS A -TAGSET OPTION THAT ALLOWS TO USE .TAG FILES WITHOUT HAVING TO INSERT TAGS INTO THE HEADER. SO I GUESS I FIGURED OUT HOW TO SOLVE THE LAST ISSUE AS WELL.
THANKS
Yes, thank you very much for the script. I wanted to reply to you when I had some news or questions, but unfortunately this is a side project on which I don’t work full time, and I still have some tests to do. I will update you probably next week.
The
National Institute of Mental Health (NIMH) is part of the National Institutes of
Health (NIH), a component of the U.S. Department of Health and Human
Services.