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 get equivalent data to XA.mat in spm99?

From:

Karl Friston <[log in to unmask]>

Reply-To:

Karl Friston <[log in to unmask]>

Date:

Wed, 9 Feb 2000 14:14:23 GMT

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (260 lines)

> From [log in to unmask] Wed Feb  9 01:51:39 2000
> Date: Tue, 8 Feb 2000 19:48:07 -0600
> Subject: how to get equivalent data to XA.mat in spm99?
Dear Darren,

> I have previously analyzed some data in spm96 but want to move to
> spm99. For this particular analysis (fmri data) I have no covariates of
> interest but several covariates of no interest. I remove the covariates
> of no interest from the raw data and I'm left with data in XA.mat with
> covariates of no interest removed, which I can then use in other
> analyses.
> 
> How do I do this in spm99? My guess is this involves taking the data
> saved in Y.mad and removing covariates of no interest but I'm not sure
> of the exact steps. The complicating factor is that I want this
> information basically for all voxels Y.mad at once and it looks like I
> may have to extract the parameter estimates for every voxel. It was
> nice having XA.mat...

The advantage of SPM99 is that you can adjust your data using F
contrasts to specify [different] confounds post hoc.  Use V.O.I under
'Data extraction' in 'Results' and a large (e.g. 64mm) VOI radius to
encompass the entire brain.  The results are save in a ???.mat file and
include:

  Y      - first eigenvariate of VOI
  xY     - structure with:
        xY.name         - name of VOI
        xY.y            - voxel-wise data (filtered and adjusted)
        xY.u            - first eigenvariate
        xY.v            - first eigenimage
        xY.s            - eigenimages
        xY.XYZmm        - Co-ordinates of voxels used within VOI
        xY.xyz          - centre of VOI (mm)
        xY.radius       - radius of VOI (mm)
        xY.dstr         - description of filtering & adjustment applied

(see spm_regions.m).  I have included an updated version of
spm_regions.m that handles large numbers of voxels (a similar
functionality is already available in SPM99, as released, but it will be
slower with large VOIs).


> Second question- If I want to effect a low pass filter of a specific Hz
> is there some conversion from the FWHM in seconds which is entered in
> spm99 and the Hz of the filter? Let's say I want .09 Hz?

No.  Low-pass filtering uses a convolution scheme (hence the FWHM of
the kernel).  The modulation transfer function of this is the Fourier
Transform of the kernel and does not correspond to a Low-pass filter
with a sharp cut-off.  This is for computational efficiency - Low pass
filtering uses a sparse convolution matrix and High-pass filtering uses
the residual forming matrix of some low frequency confounds.

I Hope this helps - Karl

___________________________________________________________________________

spm_regions.m

function [Y,xY] = spm_regions(SPM,VOL,xX,xCon,xSDM,hReg)
% VOI time-series extraction of adjusted data (local eigenimage analysis)
% FORMAT [Y xY] = spm_regions(SPM,VOL,xX,xCon,xSDM,hReg);
%
% SPM    - structure containing SPM, distribution & filtering detals
% VOL    - structure containing details of volume analysed
% xX     - Design Matrix structure
% xSDM   - structure containing contents of SPM.mat file
% xCon   - Contrast definitions structure (see spm_FcUtil.m for details)
% hReg   - Handle of results section XYZ registry (see spm_results_ui.m)
%
% Y      - first eigenvariate of VOI
% xY     - structure with:
%       xY.name         - name of VOI
%       xY.y            - voxel-wise data (filtered and adjusted)
%       xY.u            - first eigenvariate
%       xY.v            - first eigenimage
%       xY.s            - eigenimages
%       xY.XYZmm        - Co-ordinates of voxels used within VOI
%       xY.xyz          - centre of VOI (mm)
%       xY.radius       - radius of VOI (mm)
%       xY.dstr         - description of filtering & adjustment applied
%
% Y and xY are also saved in VOI_*.mat in the SPM working directory
%
% (See spm_getSPM for details on the SPM,VOL, xX & xSDM structures.)
%
%_______________________________________________________________________
%
% spm_regions extracts a representative time course from voxel data in
% Y.mad in terms of the first eigenvariate of the filtered abd adjusted
% data in all suprathreshold voxels saved (in Y.mad) within a spherical VOI
% centered on the nearest Y.mad voxel to the selected location.
%
% If temporal filtering has been specified (fMRI), then the data is
% temporally filtered. Adjustment is with respect to the null space of
% a selected contrast, or can be omitted.
%
% For a VOI of radius 0, the (filtered &) adjusted voxel time-series is
% returned, scaled to have a 2-norm or 1. The actual (filtered &)
% adjusted voxel time series can be extracted from xY.y, and will be
% the same as the (filtered &) adjusted data returned by the plotting
% routine (spm_graph.m) for the same contrast.
%
% See spm_spm.m for further details of how voxels are selected for the
% saving of their raw data in Y.mad.
%_______________________________________________________________________
% @(#)spm_regions.m	2.4 Karl Friston 00/02/09


% get figure handles
%-----------------------------------------------------------------------
Finter = spm_figure('GetWin','Interactive');
Fgraph = spm_figure('GetWin','Graphics');
set(Finter,'Name','VOI time-series extraction')


%-Find nearest voxel [Euclidean distance] in point list with data saved
% in Y.mad, and update GUI location
%-----------------------------------------------------------------------
if ~length(SPM.XYZmm)
	spm('alert!','No suprathreshold voxels!',mfilename,0);
	Y = []; xY = [];
	return
elseif exist(fullfile(SPM.swd,'Y.mad')) ~= 2
	spm('alert!','No raw data saved with this analysis!',mfilename,0);
	Y = []; xY = [];
	return
elseif ~any(SPM.QQ)
	spm('alert!','No raw data saved for any suprathreshold location!',...
		mfilename,0);
	Y = []; xY = [];
	return
end


[xyz,i] = spm_XYZreg('NearestXYZ',...
		spm_XYZreg('GetCoords',hReg),SPM.XYZmm(:,find(SPM.QQ)));
spm_XYZreg('SetCoords',xyz,hReg);


%-Get adjustment options, VOI name and radius
%-----------------------------------------------------------------------
spm_input(sprintf('at [%3.0f %3.0f %3.0f]',xyz),1,'d',...
	'VOI time-series extraction')
Ic      = spm_input('Adjust data for (select contrast)',2,'m',...
		{'<don''t adjust>',xCon.name})-1;
Rname   = spm_input('name of region',3,'s');
R       = spm_input('VOI radius (mm)',4,'r',0,1,[0,Inf]);

%-Find suprathreshold voxels within radius, & note those also in Y.mad
%-----------------------------------------------------------------------
d       = [SPM.XYZmm(1,:)-xyz(1); SPM.XYZmm(2,:)-xyz(2); SPM.XYZmm(3,:)-xyz(3)];
Q       = find(sum(d.^2) <= R^2);
q       = find(SPM.QQ(Q));

if any(SPM.QQ(Q)==0)
    spm('alert"',{...
        sprintf('Don''t have raw data for all %d suprathreshold',length(Q)),...
	sprintf('voxels within %.1gmm of [%3.0f %3.0f %3.0f]',R,xyz),' ',...
	sprintf('Proceeding using the %d voxels that are.',length(q)),...
	},mfilename,sqrt(-1));
end


%-Extract required data from results files
%=======================================================================

%-Get (approximate) raw data y from Y.mad file
%-NB: Data in Y.mad file is compressed, and therefore not fully accurate
%-----------------------------------------------------------------------
y       = spm_extract(fullfile(SPM.swd,'Y.mad'),SPM.QQ(Q(q)));
rcp     = VOL.iM(1:3,:)*[SPM.XYZmm(:,Q(q));ones(size(q))];

%-Parameter estimates: beta = xX.pKX*xX.K*y; (load from file for accuracy)
%-----------------------------------------------------------------------
nBeta = length(xSDM.Vbeta);
beta  = ones(nBeta,size(q,2));
for   i = 1:nBeta
	beta(i,:) = spm_sample_vol(xSDM.Vbeta(i),rcp(1,:),rcp(2,:),rcp(3,:),0);
end


%-Computation
%=======================================================================

% filter and remove confounds
%-----------------------------------------------------------------------
y    = spm_filter('apply',xX.K, y);

if Ic
	y = y - spm_FcUtil('Y0',xCon(Ic),xX.xKXs,beta);
	dstr = ['adjusted for ',xCon(Ic).name];
else
	dstr = 'not adjusted';
end

% compute regional response in terms of first eigenvariate
%-----------------------------------------------------------------------
[m n]   = size(y);
if m > n
	[v s v] = svd(spm_atranspa(y));
	s       = diag(s);
	v       = v(:,1);
	u       = y'*v/sqrt(s(1));
else
	[u s u] = svd(spm_atranspa(y'));
	s       = diag(s);
	u       = u(:,1);
	v       = y'*u/sqrt(s(1));
end
d       = sign(sum(v));
u       = u*d;
v       = v*d;
Y       = u;


%-Display MIP of VOI weighting and timecourse
% NB: timecourse axes overlap MIP: This obscures the coronal MIP (for MIP96)
%     in 3D mode, but for 2D data half the plane image will be obscured.
%-----------------------------------------------------------------------
spm_results_ui('Clear',Fgraph);
figure(Fgraph);
axes('Position',[0.0500,0.1100,0.5500,0.3388])
spm_mip(v(:,1),SPM.XYZmm(:,Q(q)),VOL.M,VOL.DIM)
title('VOI weighting                                          ')

axes('Position',[0.376,0.130,0.520,0.294])
plot(Y)
set(gca,'YAxisLocation','Right')
title(['1st eigenvariate: ' Rname],'FontSize',16)
str = {	'scan number';' ';sprintf(...
	'%d voxels in sphere of radius %.1gmm at [%3.0f %3.0f %3.0f]',...
	length(q),R,xyz);dstr;sprintf('Variance: %0.2f%%',s(1)*100/sum(s))};
xlabel(str)

% create structure
%-----------------------------------------------------------------------
xY      = struct('name',	Rname,...
		 'y',		y,...
		 'u',		u,...
		 'v',		v,...
		 's',		s,...
		 'XYZmm',	SPM.XYZmm(:,Q(q)),...
		 'xyz',		xyz,...
		 'radius',	R,...
		 'dstr',	dstr);
% save
%-----------------------------------------------------------------------
save(fullfile(SPM.swd,['VOI_',Rname]),'Y','xY')

%-Reset title
%-----------------------------------------------------------------------
spm('FigName',['SPM{',SPM.STAT,'}: Results']);




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

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