JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for SPM Archives


SPM Archives

SPM Archives


SPM@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

SPM Home

SPM Home

SPM  2000

SPM 2000

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: How to use spm_dbm.m

From:

John Ashburner <[log in to unmask]>

Reply-To:

John Ashburner <[log in to unmask]>

Date:

Mon, 20 Nov 2000 17:48:37 +0000 (GMT)

Content-Type:

MULTIPART/mixed

Parts/Attachments:

Parts/Attachments

TEXT/plain (65 lines) , spm_affdef.c (75 lines) , spm_procrustes_ui.m (184 lines) , spm_load_float.m (18 lines)


| >I suspect that what you really want is some kind of SPM that localises
| >significant shape differences (as done by Gaser et al).
| 
| I once tried a Gaser's-like method as follows:
|    Creating a symmetric T1 template by averaging L-R flipped and unflipped
|       T1 template images.
| 
|    Creating a symmetric brainmask using the same way.
| 
|    Smoothing original T1 images with 8mm FWHM (24 subjects).
| 
|    Normalizing the smoothed images to the symmetric template using
|       affine transformation only, with the symmetric brain mask.

You shouldn't need to smooth first.  This is done as the first processing
step of spatial normalisation.

| 
|    Normalizing the affine-normalized images with 11*13*10 nonlinear
|       basis functions using the same template and brainmask.
| 
|    Creating deformation field images (*_y1-3.img) from the *_sn3d.mat
|       files produced by the second normalization, using spm_write_defs.m.
| 
| Then, I created L-R flipped images of these deformation fields, and
| intended to perform 3-variate T-square test or MANOVA on the flipped
| and unflipped images. However, I encountered a confusing situation.
| 
| All the deformation field images have a linear-like slope in the
| corresponding direction. For example, the values in the *_y1.img were
| low in the left hemisphere and high in the right hemisphere. They seemed
| to increase linearly (not exactly, just approximately) from left to right.
| Since this tendency was observed in all subjects, any statistical test on
| the hemispheric differences (flipped vs. unflipped) produced awfully
| low P values over the whole brain.
| 
| Do you have any idea what caused this?
| I am afraid I am missing something very important.

The deformation fields contain information about position as well as shape
information.  Therefore, it is important that the positional information
is first removed.  You may also wish to factor out the effects of size.

This can be done by finding the rotations, translations and possibly the
isotropic zoom that minimises the procrustes distance between the images,
and then transforming the deformation fields so that this information
is removed.

The attached code may provide some clues about how this can be done, but it
will probably not work "as is".  Your deformation fields will need to be
either converted so that they map to co-ordinates in millimeters, or you
need to modify the code so that it converts from voxels to millimeters.

I am not that keen on methods that produce SPMs based on absolute
displacements.  I would much rather see analyses done on volume
differences, or other analyses done on some features of the Jacobian
matrices of the deformations.  This is basically because the results
are so dependent on the way that the positional information is removed
from the deformations.

Best regards,
-John



function spm_procrustes_ui % Removes pose (and global size effects) from deformation fields. % Corrected fields are written prefixed by 'p'. %_______________________________________________________________________ % Example Reference: % F. L. Bookstein (1997). "Landmark Methods for Forms Without % Landmarks: Morphometrics of Group Differences in Outline Shape" % Medical Image Analysis 1(3):225-243 %_______________________________________________________________________ % %W% John Ashburner %E% n = spm_input('Number of subjects','+0', 'n', '1', 1)'; for i=1:n, P{i} = spm_get(3,'*y?_*.img',['Select deformation field ' num2str(i)]); end; PW = spm_get(1,'*.img','Weighting image'); flg = spm_input('Remove size?','+1','y/n',[1,0],1); VW = spm_vol(PW); spm_progress_bar('Init',n,'Tweaking deformations','volumes completed'); for i=1:n, doit(P{i},VW,flg); spm_progress_bar('Set',i); end; spm_progress_bar('Clear') return; %_______________________________________________________________________ %_______________________________________________________________________ function doit(P,VW,flg) V = spm_vol(P); y1 = spm_load_float(V(1)); y2 = spm_load_float(V(2)); y3 = spm_load_float(V(3)); T = procrustes(y1,y2,y3,V(1).mat,VW,flg); spm_affdef(y1,y2,y3,T); disp(T) VO = V(1); VO.fname = prepend(V(1).fname, 'p'); VO.dim(4) = spm_type('float'); VO.pinfo = [1 0 0]'; VO.descrip = 'Shape field - X'; spm_write_vol(VO,y1); VO = V(2); VO.fname = prepend(V(2).fname, 'p'); VO.dim(4) = spm_type('float'); VO.pinfo = [1 0 0]'; VO.descrip = 'Shape field - Y'; spm_write_vol(VO,y2); VO = V(3); VO.fname = prepend(V(3).fname, 'p'); VO.dim(4) = spm_type('float'); VO.pinfo = [1 0 0]'; VO.descrip = 'Shape field - Y'; spm_write_vol(VO,y3); return; %_______________________________________________________________________ %_______________________________________________________________________ function out = prepend(in, pre) [pth,nme,ext,ver] = fileparts(in); out = fullfile(pth,[pre nme ext ver]); return; %_______________________________________________________________________ %_______________________________________________________________________ function T = procrustes(Y1,Y2,Y3,M1,V,flg) % Compute the affine transformation that minimises the % Procrustes distance between transformed and un-transformed % points. % % FORMAT T = procrustes(Y1,Y2,Y3,M1,V,flg) % Y1, Y2 and Y3 - spatial mapping % M1 - voxel to mm mapping of Y1, Y2 and Y3. % V - a handle for a weighting image. % flg - a flag to say if zooming should be included. % 1 means no % T - the determined affine transformation matrix. %_______________________________________________________________________ % Example Reference: % F. L. Bookstein (1997). "Landmark Methods for Forms Without % Landmarks: Morphometrics of Group Differences in Outline Shape" % Medical Image Analysis 1(3):225-243 %_______________________________________________________________________ % %W% John Ashburner %E% [z1,z2] = ndgrid(1:size(Y1,1),1:size(Y1,2)); z1 = z1(:); z2 = z2(:); %_______________________________________________________________________ % Compute centres of mass. sm = 0; c1 = [0 0 0]; c2 = [0 0 0]; for j=1:size(Y1,3), M = V.mat\M1*spm_matrix([0 0 j]); wt = spm_slice_vol(V,M,V.dim(1:2),0); wt = wt(:); y1 = double(Y1(:,:,j)); y1 = y1(:); y2 = double(Y2(:,:,j)); y2 = y2(:); y3 = double(Y3(:,:,j)); y3 = y3(:); x1 = M1(1,1)*z1 + M1(1,2)*z2 + (M1(1,3)*j + M1(1,4)); x2 = M1(2,1)*z1 + M1(2,2)*z2 + (M1(2,3)*j + M1(2,4)); x3 = M1(3,1)*z1 + M1(3,2)*z2 + (M1(3,3)*j + M1(3,4)); sm = sm + sum(wt); c1 = c1 + sum([x1.*wt x2.*wt x3.*wt]); c2 = c2 + sum([y1.*wt y2.*wt y3.*wt]); end; c1 = c1/sm; c2 = c2/sm; %_______________________________________________________________________ if nargin<6 | flg, % Compute centroid size. sm = 0; mom1 = 0; mom2 = 0; for j=1:size(Y1,3), M = V.mat\M1*spm_matrix([0 0 j]); wt = spm_slice_vol(V,M,V.dim(1:2),0); wt = wt(:); y1 = double(Y1(:,:,j)); y1 = y1(:); y2 = double(Y2(:,:,j)); y2 = y2(:); y3 = double(Y3(:,:,j)); y3 = y3(:); x1 = M1(1,1)*z1 + M1(1,2)*z2 + (M1(1,3)*j + M1(1,4)); x2 = M1(2,1)*z1 + M1(2,2)*z2 + (M1(2,3)*j + M1(2,4)); x3 = M1(3,1)*z1 + M1(3,2)*z2 + (M1(3,3)*j + M1(3,4)); sm = sm + sum(wt); mom1 = mom1 + sum([(x1-c1(1)).^2.*wt (x2-c1(2)).^2.*wt (x3-c1(3)).^2.*wt]); mom2 = mom2 + sum([(y1-c2(1)).^2.*wt (y2-c2(2)).^2.*wt (y3-c2(3)).^2.*wt]); end; zm = sqrt(mom1/mom2); else, zm = 1; end; ZM = spm_matrix([0 0 0 0 0 0 zm zm zm 0 0 0]); %_______________________________________________________________________ % Compute rotations C = zeros(3); for j=1:size(Y1,3), M = V.mat\M1*spm_matrix([0 0 j]); wt = spm_slice_vol(V,M,V.dim(1:2),0); wt = wt(:); y1 = double(Y1(:,:,j)); y1 = y1(:); y2 = double(Y2(:,:,j)); y2 = y2(:); y3 = double(Y3(:,:,j)); y3 = y3(:); x1 = M1(1,1)*z1 + M1(1,2)*z2 + (M1(1,3)*j + M1(1,4)); x2 = M1(2,1)*z1 + M1(2,2)*z2 + (M1(2,3)*j + M1(2,4)); x3 = M1(3,1)*z1 + M1(3,2)*z2 + (M1(3,3)*j + M1(3,4)); wt1 = wt*zm; C = C + [(x1-c1(1)).*wt (x2-c1(2)).*wt (x3-c1(3)).*wt ]' * ... [(y1-c2(1)).*wt1 (y2-c2(2)).*wt1 (y3-c2(3)).*wt1]; end; [u,s,v] = svd(C); R = eye(4); R(1:3,1:3) = u*v'; %_______________________________________________________________________ % Combine rotations, translations (and zooms) into a single % affine transformation matrix. T = spm_matrix(c1)*R*ZM*spm_matrix(-c2); return; %_______________________________________________________________________
function dat = spm_load_float(V) % Load a volume into a floating point array % FORMAT dat = spm_load_float(V) % V - handle from spm_vol % dat - a 3D floating point array %_______________________________________________________________________ % %W% John Ashburner %E% dim = V(1).dim(1:3); dat = single(0); dat(dim(1),dim(2),dim(3))=0; for i=1:V(1).dim(3), M = spm_matrix([0 0 i]); dat(:,:,i) = single(spm_slice_vol(V(1),M,dim(1:2),1)); end; return;

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
2006
2005
2004
2003
2002
2001
2000
1999
1998


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager