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:

Monospaced Font

LISTSERV Archives

LISTSERV Archives

SPM Home

SPM Home

SPM  2006

SPM 2006

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: problem with reslicing in an arbitrary angle

From:

Ged Ridgway <[log in to unmask]>

Reply-To:

Ged Ridgway <[log in to unmask]>

Date:

Wed, 25 Oct 2006 19:31:20 +0100

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (88 lines)

Amir M. Tahmasebi wrote:
> So here is what I am trying to do: Suppose I have two datasets, a
> template data (name it as A) and another not normalized data (name it as
> B). I am interested in finding a particular slice image in B that
> corresponds to a chosen slice in A. So first I do the registration using
> spm_coreg function. Lets say I end up with a transformation matrix T_r
> (registering B to A).

Okay, let's make sure we're clear here, at this point, T_r maps from
A's world coords to B's world coords. So:
  [BX;BY;BZ;1] = T_r * [AX;AY;AZ;1] % world coords (mm)
and:
  [Bx;By;Bz;1] = B.mat \ T_r * A.mat * [Ax;Ay;Az;1] % voxel coords

> Now I locate the desired slice in A, save the
> orientation matrix (T_d_A) and calculate the orientation in B's space:
> T_d_B = inv(T_r) * T_d_A. The way I locate the slice in A is by using
> the orthoviews and GUI's reorient button. I mean I use manual
> reorientation to display the desired slice and then press "reorient"
> button. I do *NOT* change the location of blobs using mouse.

Now, by changing A's reorientation (e.g. setting roll to 0.2), you
change its voxel-world mapping (and this will be permanent if you
click "reorient images" and select it -- I would avoid this). What
happens is that A.mat gets replaced with R * A.mat, where R is
spm_matrix(params_entered). I think my R is your T_d_A, but I have
changed notation in case you meant T_d_A to be R*A.mat or something else.

There is a little known feature here that might help, which is that
with the image showing in Display (or Check Reg) you can say:
   global st
and then have access to the image's current R from the reorientation
parameters:
   R = st.vols{1}.premul

At this point you can check that if you enter arbitrary voxel
coordinates in the display GUI, you can match the world coords that
the GUI shows with:
   R*A.mat*[Ax;Ay;Az;1]
This hopefully answers your question about whether orth_views is doing
something weird (I don't think it is; I personally think spm_slice_vol
is weird...)

Note, having changed the orientation, the image you are looking at is
no longer world-registered to B, so let's call the new image C, and
note that:
  [CX;CY;CZ;1] = R * [AX;AY;AZ;1] % world coords (mm)
               = R * inv(T_r) * [BX;BY;BZ;1]
               = R * inv(T_r) * B.mat * [Bx;By;Bz;1]

It's my understanding that you are now looking at the plane CZ=0, and
you want to find the corresponding plane of B, right?

Since we have a mapping from C's world-space to B's voxel-space, we
should certainly be able to do this...

Here however, is where I would use spm_sample_vol, rather than
spm_slice_vol. As I said, I find the latter very confusing, so I'm
afraid you will have to rely on someone else on the list (e.g. John,
if he's around?) to help you with that. To use spm_sample_vol though,
we just need to build up matrices of coordinates of the slice CZ=0,
transform these to B's voxel-space, and then pass these to
spm_sample_vol. Something like this should work:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  [CX CY] = meshgrid(-100:100,100:-1:-150); CZ = 0 * CX;
  % I chose the X and Y ranges above (in mm) roughly, by looking at
  % the corners in the GUI Display (could *calculate* bounding box)
  Cworld = [CX(:) CY(:) CZ(:) ones(numel(CX), 1)]';
  Bvoxel = (R * inv(T_r) * B.mat) \ Cworld; % (as derived earlier)
  Bx = reshape(Bvoxel(1,:), size(CX));
  By = reshape(Bvoxel(2,:), size(CY));
  Bz = reshape(Bvoxel(3,:), size(CZ));
  figure; imagesc(spm_sample_vol(B, Bx, By, Bz, 1));
  % should look like graphics window, with luck...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

> To do a test, I use the template A itself and T_d_A as inputs

Good idea! And indeed, I have tested my above suggestion like this
(with T_r = eye(4) and B==C,) and it seems to do what I want, so
hopefully it will work for you in your more general case. If not, I do
hope this email provides you with the info you need to make progress
(as it's taken a while to write!).

Best of luck,
Ged.

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

May 2024
April 2024
March 2024
February 2024
January 2024
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
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

For help and support help@jisc.ac.uk

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