<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ccn-wiki.caset.buffalo.edu/index.php?action=history&amp;feed=atom&amp;title=Data_Simulation</id>
	<title>Data Simulation - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://ccn-wiki.caset.buffalo.edu/index.php?action=history&amp;feed=atom&amp;title=Data_Simulation"/>
	<link rel="alternate" type="text/html" href="https://ccn-wiki.caset.buffalo.edu/index.php?title=Data_Simulation&amp;action=history"/>
	<updated>2026-04-13T16:17:01Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://ccn-wiki.caset.buffalo.edu/index.php?title=Data_Simulation&amp;diff=1713&amp;oldid=prev</id>
		<title>Chris: /* Step 2: Multiply the HRF basis function by each time point */</title>
		<link rel="alternate" type="text/html" href="https://ccn-wiki.caset.buffalo.edu/index.php?title=Data_Simulation&amp;diff=1713&amp;oldid=prev"/>
		<updated>2019-02-13T22:05:50Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Step 2: Multiply the HRF basis function by each time point&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 18:05, 13 February 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l20&quot;&gt;Line 20:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 20:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Now at this point, there&amp;#039;s an HRF, and there&amp;#039;s one or more time series in a matrix, &amp;#039;&amp;#039;&amp;#039;M&amp;#039;&amp;#039;&amp;#039;, which could all be 0,1 or be values in between, representing the intensity of the event at time &amp;#039;&amp;#039;t&amp;#039;&amp;#039;. Matrix multiplication doesn&amp;#039;t get the job done. Instead, it seems the way to do it is to make a big matrix, 1 row per time point, and then multiply the value at that time point by the HRF, and store it in the next open row. At the end of it all, you will have a time points &amp;amp;times; (time points + HRF window) matrix. Think of each row as being a moving window. Summing these windows, we collapse our time points together to get what seems to be the convolution of the HRF with the time series.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Now at this point, there&amp;#039;s an HRF, and there&amp;#039;s one or more time series in a matrix, &amp;#039;&amp;#039;&amp;#039;M&amp;#039;&amp;#039;&amp;#039;, which could all be 0,1 or be values in between, representing the intensity of the event at time &amp;#039;&amp;#039;t&amp;#039;&amp;#039;. Matrix multiplication doesn&amp;#039;t get the job done. Instead, it seems the way to do it is to make a big matrix, 1 row per time point, and then multiply the value at that time point by the HRF, and store it in the next open row. At the end of it all, you will have a time points &amp;amp;times; (time points + HRF window) matrix. Think of each row as being a moving window. Summing these windows, we collapse our time points together to get what seems to be the convolution of the HRF with the time series.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;i&lt;/del&gt;=&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;2&lt;/del&gt;; %supposing column i of the time series matrix M contains the time series you wish to convolve&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;cols&lt;/ins&gt;=&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[4:11]&lt;/ins&gt;; %supposing column i of the time series matrix M contains the time series you wish to convolve&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  bf=xBF.bf;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  bf=xBF.bf;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  winsize=length(bf); %the window seems to be xBF.length + 1&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  winsize=length(bf); %the window seems to be xBF.length + 1&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  simTS=zeros(size(M,1)+winsize, size(M,1));&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  simTS=zeros(size(M,1)+winsize, size(M,1));&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  for t=1:size(M,1)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;allsimTS=[]; %keep appending rows to the empty matrix&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;   &lt;/del&gt;thisscale=M(t,i);&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; for i=cols&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;   &lt;/del&gt;tbf=(bf*thisscale)&amp;#039;;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    &lt;/ins&gt;for t=1:size(M,1)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;   &lt;/del&gt;simTS(t,t:t+winsize-1)=tbf;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;        &lt;/ins&gt;thisscale=M(t,i);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;        &lt;/ins&gt;tbf=(bf*thisscale)&amp;#039;;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;        &lt;/ins&gt;simTS(t,t:t+winsize-1)=tbf&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    end&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    simTS=sum(simTS); %summing all the temporally overlapping time series windows to collapse into a single time series&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    allsimTS=[allsimTS;simTS]&lt;/ins&gt;;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  end&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  end&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; simTS=sum&lt;/del&gt;(&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;simTS&lt;/del&gt;)&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;; %summing all the temporally overlapping time series windows to collapse into a single time series&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Did it work? Kind of &lt;/ins&gt;(&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;?&lt;/ins&gt;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Chris</name></author>
	</entry>
	<entry>
		<id>https://ccn-wiki.caset.buffalo.edu/index.php?title=Data_Simulation&amp;diff=1712&amp;oldid=prev</id>
		<title>Chris: Created page with &quot;==Convolving a Simulated fMRI Time Series== &#039;&#039;&#039;Scenario:&#039;&#039;&#039; A multilayer feedforward network was created in MikeNet with manually-set weights to produce an artificial system o...&quot;</title>
		<link rel="alternate" type="text/html" href="https://ccn-wiki.caset.buffalo.edu/index.php?title=Data_Simulation&amp;diff=1712&amp;oldid=prev"/>
		<updated>2019-02-13T21:39:56Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Convolving a Simulated fMRI Time Series== &amp;#039;&amp;#039;&amp;#039;Scenario:&amp;#039;&amp;#039;&amp;#039; A multilayer feedforward network was created in MikeNet with manually-set weights to produce an artificial system o...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Convolving a Simulated fMRI Time Series==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Scenario:&amp;#039;&amp;#039;&amp;#039; A multilayer feedforward network was created in MikeNet with manually-set weights to produce an artificial system of interconnected regions that would behave in a predictable manner according to inputs of different types (e.g., input of type A would activate some regions, deactivate other regions, and have no influence on a third set of regions; the simultaneous input of A and B was required to maximally activate one of the regions, etc.). A continuous time series of simulated activations was read from each of the network regions as inputs A and B were given, where each region&amp;#039;s activation could range from 0.0 to 1.0, and was dependent on the activity of the region that connected into it at the previous time point. This introduced the concept of a lag into the network, such that regions directly receiving input were activated faster than those that were further down the connectivity train.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Problem:&amp;#039;&amp;#039;&amp;#039; to make the synthetic activations as realistic as possible, I wished to convolve the simulated time series with SPM&amp;#039;s canonical HRF, under the assumption of additivity of activity. It seemed that this might be possible using the spm_Volterra command, but alas, no. In the end, I accomplished this in two steps:&lt;br /&gt;
&lt;br /&gt;
=== Step 1: Compute the HRF basis function ===&lt;br /&gt;
With SPM in your MATLAB path, we can call the spm_get_bf function:&lt;br /&gt;
 %first, create a data structure with some defining parameters&lt;br /&gt;
 xBF.name=&amp;#039;hrf&amp;#039;;&lt;br /&gt;
 xBF.length=16;&lt;br /&gt;
 xBF.dt=0.25;&lt;br /&gt;
 xBF.order=2;&lt;br /&gt;
 xBF.T=16;&lt;br /&gt;
 xBF.dt=2;&lt;br /&gt;
 xBF=spm_get_bf(xBF); %if you plot(xBF.bf) you will see the characteristic canonical HRF&lt;br /&gt;
&lt;br /&gt;
Having the HRF helps, but that&amp;#039;s the immediate response to one event. I wish to convolve this function with an entire simulated time series, similar to how the spm_Volterra function convolves this function with a time series generated from a vector of event onsets. &lt;br /&gt;
&lt;br /&gt;
=== Step 2: Multiply the HRF basis function by each time point ===&lt;br /&gt;
Now at this point, there&amp;#039;s an HRF, and there&amp;#039;s one or more time series in a matrix, &amp;#039;&amp;#039;&amp;#039;M&amp;#039;&amp;#039;&amp;#039;, which could all be 0,1 or be values in between, representing the intensity of the event at time &amp;#039;&amp;#039;t&amp;#039;&amp;#039;. Matrix multiplication doesn&amp;#039;t get the job done. Instead, it seems the way to do it is to make a big matrix, 1 row per time point, and then multiply the value at that time point by the HRF, and store it in the next open row. At the end of it all, you will have a time points &amp;amp;times; (time points + HRF window) matrix. Think of each row as being a moving window. Summing these windows, we collapse our time points together to get what seems to be the convolution of the HRF with the time series.&lt;br /&gt;
&lt;br /&gt;
 i=2; %supposing column i of the time series matrix M contains the time series you wish to convolve&lt;br /&gt;
 bf=xBF.bf;&lt;br /&gt;
 winsize=length(bf); %the window seems to be xBF.length + 1&lt;br /&gt;
 simTS=zeros(size(M,1)+winsize, size(M,1));&lt;br /&gt;
 for t=1:size(M,1)&lt;br /&gt;
   thisscale=M(t,i);&lt;br /&gt;
   tbf=(bf*thisscale)&amp;#039;;&lt;br /&gt;
   simTS(t,t:t+winsize-1)=tbf;&lt;br /&gt;
 end&lt;br /&gt;
 simTS=sum(simTS); %summing all the temporally overlapping time series windows to collapse into a single time series&lt;/div&gt;</summary>
		<author><name>Chris</name></author>
	</entry>
</feed>