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  March 2010

SPM March 2010

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: orthogonalization of regressors

From:

Misha Koshelev <[log in to unmask]>

Reply-To:

Misha Koshelev <[log in to unmask]>

Date:

Fri, 5 Mar 2010 10:31:44 -0600

Content-Type:

multipart/mixed

Parts/Attachments:

Parts/Attachments

text/plain (30 lines) , spm_get_ons.m (256 lines) , spm_get_ons.m.txt (256 lines)

Stephen J. Fromm wrote:
> On Tue, 2 Mar 2010 19:21:22 -0600, Misha Koshelev <[log in to unmask]>
> wrote:
>
> Why do you think regressors are always orthogonalized?
>

I have attached the file spm_get_ons.m for SPM2.

On line 224-226 it reads:
	% orthogonalize inputs
	%---------------------------------------------------------------
	u          = spm_orth(u);

Per my lab members advice, this is the line where orthogonalization of regressor is done. In fact, he toggles this line (or not) to determine whether or not his regressors are orthogonalized (if commented out - no orthogonalization). Is this not the case?

Thank you
Misha Koshelev

--
Misha Koshelev
MD/PhD Student

Human Neuroimaging Laboratory
One Baylor Plaza
S104
Baylor College of Medicine
Houston, TX 77030



function [U] = spm_get_ons(SPM,s) % returns input [designed effects] structures % FORMAT [U] = spm_get_ons(SPM,s) % % s - session number (used by batch system) % % U - (1 x n) struct array of (n) trial-specific structures % % U(i).name - cell of names for each input or cause % U(i).u - inputs or stimulus function matrix % U(i).dt - time bin (seconds) % U(i).ons - onsets (in SPM.xBF.UNITS) % U(i).dur - durations (in SPM.xBF.UNITS) % U(i).P - parameter struct. % % U(i).P(p).name - parameter name % U(i).P(p).P - parameter vector % U(i).P(p).h - order of polynomial expansion % U(i).P(p).i - sub-indices of u pertaining to P %_______________________________________________________________________ % % % SLICE TIMIING % % With longs TRs you may want to shift the regressors so that they are % aligned to a particular slice. This is effected by resetting the % values of defaults.stats.fmri.t and defaults.stats.fmri.t0 in % spm_defaults. defaults.stats.fmri.t is the number of time-bins per % scan used when building regressors. Onsets are defined % in temporal units of scans starting at 0. defaults.stats.fmri.t0 is % the first time-bin at which the regressors are resampled to coincide % with data acquisition. If defaults.stats.fmri.t0 = 1 then the % regressors will be appropriate for the first slice. If you want to % temporally realign the regressors so that they match responses in the % middle slice then make defaults.stats.fmri.t0 = % defaults.stats.fmri.t/2 (assuming there is a negligible gap between % volume acquisitions. Default values are defaults.stats.fmri.t = 16 % and defaults.stats.fmri.t0 = 1. % % %_______________________________________________________________________ % @(#)spm_get_ons.m 2.42 Karl Friston 03/11/12 %-GUI setup %----------------------------------------------------------------------- spm_help('!ContextHelp',mfilename) % time units %----------------------------------------------------------------------- k = SPM.nscan(s); T = SPM.xBF.T; dt = SPM.xBF.dt; try UNITS = SPM.xBF.UNITS; catch UNITS = 'scans'; end switch UNITS case 'scans' %---------------------------------------------------------------- TR = T*dt; case 'secs' %---------------------------------------------------------------- TR = 1; end % get inputs and names (try SPM.Sess(s).U first) %======================================================================= try U = SPM.Sess(s).U; v = length(U); catch %-prompt string %--------------------------------------------------------------- str = sprintf('Session %d: trial specification in %s',s,UNITS); spm_input(str,1,'d') U = {}; v = spm_input('number of conditions/trials',2,'w1'); end % get trials %----------------------------------------------------------------------- for i = 1:v % get names %--------------------------------------------------------------- try Uname = U(i).name(1); catch str = sprintf('name for condition/trial %d ?',i); Uname = {spm_input(str,3,'s',sprintf('trial %d',i))}; U(i).name = Uname; end % get main [trial] effects %================================================================ % onsets %--------------------------------------------------------------- try ons = U(i).ons; ons = ons(:); catch ons = []; end if ~length(ons) str = ['vector of onsets - ' Uname{1}]; ons = spm_input(str,4,'r',' ',[Inf 1]); U(i).ons = ons(:); end % durations %--------------------------------------------------------------- try dur = U(i).dur; dur = dur(:); catch dur = []; end if ~length(dur) str = 'duration[s] (events = 0)'; while 1 dur = spm_input(str,5,'r',' ',[Inf 1]); if length(dur) == 1 dur = dur*ones(size(ons)); end if length(dur) == length(ons), break, end str = sprintf('enter a scalar or [%d] vector',... length(ons)); end U(i).dur = dur; end % peri-stimulus times {seconds} %--------------------------------------------------------------- pst = [1:k]*T*dt - ons(1)*TR; for j = 1:length(ons) w = [1:k]*T*dt - ons(j)*TR; v = find(w >= -1); pst(v) = w(v); end % add parameters x trial interactions %================================================================ % get parameter stucture xP %---------------------------------------------------------------- try xP = U(i).P; Pname = xP(1).name; switch Pname case 'none' %------------------------------------------------ xP.name = 'none'; xP.h = 0; end catch Pname = {'none','time','other'}; Pname = spm_input('parametric modulation',6,'b',Pname); switch Pname case 'none' %-------------------------------------------------------- xP(1).name = 'none'; xP(1).h = 0; case 'time' %-------------------------------------------------------- xP(1).name = 'time'; xP(1).P = ons*TR; xP(1).h = spm_input('polynomial order',8,'n1',1); case 'other' %-------------------------------------------------------- str = ['# parameters (' Uname{1} ')']; for q = 1:spm_input(str,7,'n1',1); % get names and parametric variates %------------------------------------------------ str = sprintf('parameter %d name',q); Pname = spm_input(str,7,'s'); P = spm_input(Pname,7,'r',[],[length(ons),1]); % order of polynomial expansion h %------------------------------------------------ h = spm_input('polynomial order',8,'n1',1); % sub-indices and inputs %------------------------------------------------ xP(q).name = Pname; xP(q).P = P(:); xP(q).h = h; end end % switch end % try % interaction with causes (u) - 1st = main effects %---------------------------------------------------------------- u = ons.^0; for q = 1:length(xP) xP(q).i = [1, ([1:xP(q).h] + size(u,2))]; for j = 1:xP(q).h P = spm_en(xP(q).P);   u = [u P.^j]; str = sprintf('%sx%s^%d',Uname{1},xP(q).name,j); Uname{end + 1} = str; end end % orthogonalize inputs %--------------------------------------------------------------- u = spm_orth(u); % and scale so sum(u*dt) = number of events, if event-related %--------------------------------------------------------------- if ~any(dur) u = u/dt; end % create stimulus functions (32 bin offset) %=============================================================== ton = round(ons*TR/dt) + 32; % onsets tof = round(dur*TR/dt) + ton + 1; % offset sf = sparse((k*T + 128),size(u,2)); for j = 1:length(ton) sf(ton(j),:) = sf(ton(j),:) + u(j,:); sf(tof(j),:) = sf(tof(j),:) - u(j,:); end sf = cumsum(sf); % integrate sf = sf(1:(k*T + 32),:); % stimulus % place in ouputs structure %--------------------------------------------------------------- U(i).name = Uname; % - input names U(i).dt = dt; % - time bin {seconds} U(i).u = sf; % - stimulus function matrix U(i).pst = pst; % - pst (seconds) U(i).P = xP; % - parameter struct end % (v)
function [U] = spm_get_ons(SPM,s) % returns input [designed effects] structures % FORMAT [U] = spm_get_ons(SPM,s) % % s - session number (used by batch system) % % U - (1 x n) struct array of (n) trial-specific structures % % U(i).name - cell of names for each input or cause % U(i).u - inputs or stimulus function matrix % U(i).dt - time bin (seconds) % U(i).ons - onsets (in SPM.xBF.UNITS) % U(i).dur - durations (in SPM.xBF.UNITS) % U(i).P - parameter struct. % % U(i).P(p).name - parameter name % U(i).P(p).P - parameter vector % U(i).P(p).h - order of polynomial expansion % U(i).P(p).i - sub-indices of u pertaining to P %_______________________________________________________________________ % % % SLICE TIMIING % % With longs TRs you may want to shift the regressors so that they are % aligned to a particular slice. This is effected by resetting the % values of defaults.stats.fmri.t and defaults.stats.fmri.t0 in % spm_defaults. defaults.stats.fmri.t is the number of time-bins per % scan used when building regressors. Onsets are defined % in temporal units of scans starting at 0. defaults.stats.fmri.t0 is % the first time-bin at which the regressors are resampled to coincide % with data acquisition. If defaults.stats.fmri.t0 = 1 then the % regressors will be appropriate for the first slice. If you want to % temporally realign the regressors so that they match responses in the % middle slice then make defaults.stats.fmri.t0 = % defaults.stats.fmri.t/2 (assuming there is a negligible gap between % volume acquisitions. Default values are defaults.stats.fmri.t = 16 % and defaults.stats.fmri.t0 = 1. % % %_______________________________________________________________________ % @(#)spm_get_ons.m 2.42 Karl Friston 03/11/12 %-GUI setup %----------------------------------------------------------------------- spm_help('!ContextHelp',mfilename) % time units %----------------------------------------------------------------------- k = SPM.nscan(s); T = SPM.xBF.T; dt = SPM.xBF.dt; try UNITS = SPM.xBF.UNITS; catch UNITS = 'scans'; end switch UNITS case 'scans' %---------------------------------------------------------------- TR = T*dt; case 'secs' %---------------------------------------------------------------- TR = 1; end % get inputs and names (try SPM.Sess(s).U first) %======================================================================= try U = SPM.Sess(s).U; v = length(U); catch %-prompt string %--------------------------------------------------------------- str = sprintf('Session %d: trial specification in %s',s,UNITS); spm_input(str,1,'d') U = {}; v = spm_input('number of conditions/trials',2,'w1'); end % get trials %----------------------------------------------------------------------- for i = 1:v % get names %--------------------------------------------------------------- try Uname = U(i).name(1); catch str = sprintf('name for condition/trial %d ?',i); Uname = {spm_input(str,3,'s',sprintf('trial %d',i))}; U(i).name = Uname; end % get main [trial] effects %================================================================ % onsets %--------------------------------------------------------------- try ons = U(i).ons; ons = ons(:); catch ons = []; end if ~length(ons) str = ['vector of onsets - ' Uname{1}]; ons = spm_input(str,4,'r',' ',[Inf 1]); U(i).ons = ons(:); end % durations %--------------------------------------------------------------- try dur = U(i).dur; dur = dur(:); catch dur = []; end if ~length(dur) str = 'duration[s] (events = 0)'; while 1 dur = spm_input(str,5,'r',' ',[Inf 1]); if length(dur) == 1 dur = dur*ones(size(ons)); end if length(dur) == length(ons), break, end str = sprintf('enter a scalar or [%d] vector',... length(ons)); end U(i).dur = dur; end % peri-stimulus times {seconds} %--------------------------------------------------------------- pst = [1:k]*T*dt - ons(1)*TR; for j = 1:length(ons) w = [1:k]*T*dt - ons(j)*TR; v = find(w >= -1); pst(v) = w(v); end % add parameters x trial interactions %================================================================ % get parameter stucture xP %---------------------------------------------------------------- try xP = U(i).P; Pname = xP(1).name; switch Pname case 'none' %------------------------------------------------ xP.name = 'none'; xP.h = 0; end catch Pname = {'none','time','other'}; Pname = spm_input('parametric modulation',6,'b',Pname); switch Pname case 'none' %-------------------------------------------------------- xP(1).name = 'none'; xP(1).h = 0; case 'time' %-------------------------------------------------------- xP(1).name = 'time'; xP(1).P = ons*TR; xP(1).h = spm_input('polynomial order',8,'n1',1); case 'other' %-------------------------------------------------------- str = ['# parameters (' Uname{1} ')']; for q = 1:spm_input(str,7,'n1',1); % get names and parametric variates %------------------------------------------------ str = sprintf('parameter %d name',q); Pname = spm_input(str,7,'s'); P = spm_input(Pname,7,'r',[],[length(ons),1]); % order of polynomial expansion h %------------------------------------------------ h = spm_input('polynomial order',8,'n1',1); % sub-indices and inputs %------------------------------------------------ xP(q).name = Pname; xP(q).P = P(:); xP(q).h = h; end end % switch end % try % interaction with causes (u) - 1st = main effects %---------------------------------------------------------------- u = ons.^0; for q = 1:length(xP) xP(q).i = [1, ([1:xP(q).h] + size(u,2))]; for j = 1:xP(q).h P = spm_en(xP(q).P);   u = [u P.^j]; str = sprintf('%sx%s^%d',Uname{1},xP(q).name,j); Uname{end + 1} = str; end end % orthogonalize inputs %--------------------------------------------------------------- u = spm_orth(u); % and scale so sum(u*dt) = number of events, if event-related %--------------------------------------------------------------- if ~any(dur) u = u/dt; end % create stimulus functions (32 bin offset) %=============================================================== ton = round(ons*TR/dt) + 32; % onsets tof = round(dur*TR/dt) + ton + 1; % offset sf = sparse((k*T + 128),size(u,2)); for j = 1:length(ton) sf(ton(j),:) = sf(ton(j),:) + u(j,:); sf(tof(j),:) = sf(tof(j),:) - u(j,:); end sf = cumsum(sf); % integrate sf = sf(1:(k*T + 32),:); % stimulus % place in ouputs structure %--------------------------------------------------------------- U(i).name = Uname; % - input names U(i).dt = dt; % - time bin {seconds} U(i).u = sf; % - stimulus function matrix U(i).pst = pst; % - pst (seconds) U(i).P = xP; % - parameter struct end % (v)

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

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