<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>matlab &#8211; Dr. Jian Chen</title>
	<atom:link href="http://localhost/jianchen/tag/matlab/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.jianchen.info</link>
	<description>陈建博士</description>
	<lastBuildDate>Wed, 29 Jun 2022 00:07:12 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>

<image>
	<url>https://www.jianchen.info/wp-content/uploads/2022/06/cropped-Frued_Cartoon-32x32.png</url>
	<title>matlab &#8211; Dr. Jian Chen</title>
	<link>https://www.jianchen.info</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Get real-time gaze positions from the eye tracker</title>
		<link>https://www.jianchen.info/2017/03/30/get-real-time-gaze-positions-from-the-eye-tracker/</link>
		
		<dc:creator><![CDATA[saturn]]></dc:creator>
		<pubDate>Thu, 30 Mar 2017 00:06:55 +0000</pubDate>
				<category><![CDATA[research]]></category>
		<category><![CDATA[eyelink]]></category>
		<category><![CDATA[eyetracker]]></category>
		<category><![CDATA[gaze]]></category>
		<category><![CDATA[matlab]]></category>
		<guid isPermaLink="false">https://www.jianchen.info/?p=119</guid>

					<description><![CDATA[If I want to make sure the participants are fixating on the cross before starting each trial, how should I do? With the help of Eyetracker (Eyelink in this case), we can get the realtime gaze position and therefore we can monitor the gaze position to make sure it falls into a certain area before ... <a title="Get real-time gaze positions from the eye tracker" class="read-more" href="https://www.jianchen.info/2017/03/30/get-real-time-gaze-positions-from-the-eye-tracker/" aria-label="More on Get real-time gaze positions from the eye tracker">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p>If I want to make sure the participants are fixating on the cross before starting each trial, how should I do?</p>



<p>With the help of Eyetracker (Eyelink in this case), we can get the realtime gaze position and therefore we can monitor the gaze position to make sure it falls into a certain area before the participants start the trial.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<pre class="wp-block-code"><code>% make sure participants are fixating on the central
while isEyeLink  % if Eyelink was connected
status = Eyelink('newfloatsampleavailable');  % check to see if everything is fine in Eyelink
if status /=0; % if all is fine
evt = Eyelink('newestfloatsample'); % get the newest float sample from Eyelink
realtime.x = evt.gx(1);  % get the x axis of gaze
realtime.y = evt.gy(1);  % get the y axis of gaze
end;

if abs(realtime.x-512)\&lt;=50&amp;abs(realtime.y-384)\&lt;=50  % if the gaze falls into  a 50\*50 pixel square around the cross
break; % jump out the loop and start the trial
end
end</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>EEG Processing Steps (based on EEGLAB and ERPLAB)</title>
		<link>https://www.jianchen.info/2017/01/18/eeg-processing-steps-based-on-eeglab-and-erplab/</link>
		
		<dc:creator><![CDATA[saturn]]></dc:creator>
		<pubDate>Wed, 18 Jan 2017 00:01:26 +0000</pubDate>
				<category><![CDATA[research]]></category>
		<category><![CDATA[eeg]]></category>
		<category><![CDATA[eeglab]]></category>
		<category><![CDATA[matlab]]></category>
		<guid isPermaLink="false">https://www.jianchen.info/?p=113</guid>

					<description><![CDATA[Here are the basic steps I used to process BioSemi EEG data. 1 load raw data 2 channel location 3 re-reference 4 filtering&#160;(sometimes the data is very huge and therefore the filtering will be very slow, so we can do the filtering later) 5 Create EEG event list (ERPLAB from now on) 6 Assign bins ... <a title="EEG Processing Steps (based on EEGLAB and ERPLAB)" class="read-more" href="https://www.jianchen.info/2017/01/18/eeg-processing-steps-based-on-eeglab-and-erplab/" aria-label="More on EEG Processing Steps (based on EEGLAB and ERPLAB)">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p>Here are the basic steps I used to process BioSemi EEG data.</p>



<p><strong>1 load raw data</strong></p>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/eegsteps/809C496A-8039-4D2E-9B13-70B6B7721A10.png" alt=""/></figure>



<p><strong>2 channel location</strong></p>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/eegsteps/030CC12C-9735-43A2-AD38-53EBF6240A46.png" alt=""/></figure>



<p><strong>3 re-reference</strong></p>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/eegsteps/3135436B-A01A-4FED-9B9E-E426C7FA3CB4.png" alt=""/></figure>



<p><strong>4 filtering</strong>&nbsp;(sometimes the data is very huge and therefore the filtering will be very slow, so we can do the filtering later)</p>



<p><strong>5 Create EEG event list (ERPLAB from now on)</strong></p>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/eegsteps/F18A0B75-3355-4EBE-B7CA-E62720858371.png" alt=""/></figure>



<p><strong>6 Assign bins (how to operate on bins? see&nbsp;<a href="https://github.com/lucklab/erplab/wiki/Assigning-Events-to-Bins-with-BINLISTER:-Tutorial" target="_blank" rel="noreferrer noopener">here</a>)</strong></p>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/eegsteps/43ABAD39-3E41-4BA7-9607-34EA61FE7D74.png" alt=""/></figure>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/eegsteps/8A8EC18C-86E4-4AB8-8242-1E6D23716321.png" alt=""/></figure>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/eegsteps/4AC21F49-0134-4FE3-83E1-12B663C404DF.png" alt=""/></figure>



<p><strong>7 extract bin-based epoch</strong></p>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/eegsteps/B1B02461-7F46-4AB1-8371-AF769E9F3E26.png" alt=""/></figure>



<p><strong>8 artifact rejection</strong></p>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/eegsteps/40120CE4-073E-4CEF-A35D-98DDB2DDD429.png" alt=""/></figure>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/eegsteps/9234B231-7612-41D2-9349-5682C3027FD8.png" alt=""/></figure>



<p><strong>-&gt; choose channel around the eye. -&gt; update and then reject</strong></p>



<p><strong>9 compute average erps</strong></p>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/eegsteps/289AC38D-87CF-4234-9B90-D5C01D010D9A.png" alt=""/></figure>



<p><strong>10 filter if you don’t do it in step 4</strong></p>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/eegsteps/CD5AD34D-B8EC-4825-B5A8-90EA5C31611D.png" alt=""/></figure>



<p><strong>11 bin operations if necessary&nbsp;</strong></p>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/eegsteps/1E8272A4-A250-4471-945D-2D764439AE61.png" alt=""/></figure>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/eegsteps/3FA48AA1-9212-4A49-A8B4-73CEFFB13B38.png" alt=""/></figure>



<p><strong>12 Plot ERPs</strong></p>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/eegsteps/AB81310E-9BC5-422B-95FD-B3718883494D.png" alt=""/></figure>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/eegsteps/F1F2CFBD-3018-4E77-B960-35EEFB103226.png" alt=""/></figure>



<p><strong>13 Save figures if you want</strong></p>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/eegsteps/14A0D60A-40B2-4697-9F30-84312AFCEEBF.png" alt=""/></figure>



<p>Remember, these are basic steps to illustrate how to process the EEG data using EEGLAB and ERPLAB toolbox, you’re suggested not to strictly follow these steps.</p>



<p><a href="https://jianch.github.io/author/saturn/"></a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Merge Behavioral Data into EEG</title>
		<link>https://www.jianchen.info/2016/12/16/merge-behavioral-data-into-eeg/</link>
		
		<dc:creator><![CDATA[saturn]]></dc:creator>
		<pubDate>Fri, 16 Dec 2016 23:58:17 +0000</pubDate>
				<category><![CDATA[research]]></category>
		<category><![CDATA[eeg]]></category>
		<category><![CDATA[eeglab]]></category>
		<category><![CDATA[matlab]]></category>
		<guid isPermaLink="false">https://www.jianchen.info/?p=109</guid>

					<description><![CDATA[An example code of how I merge behavioral data into EEG Code:]]></description>
										<content:encoded><![CDATA[
<p>An example code of how I merge behavioral data into EEG</p>



<figure class="wp-block-image"><img decoding="async" src="https://jianch.github.io/wp-content/uploads/2021/02/WX20161213-192101.png" alt="" class="wp-image-95"/></figure>



<figure class="wp-block-image"><img decoding="async" src="https://jianch.github.io/wp-content/uploads/2021/02/WX20161213-192033.png" alt="" class="wp-image-96"/></figure>



<p>Code:</p>



<pre class="wp-block-code"><code>%% merge behavioral data into EEG

% Sometimes, it's hard to lively send behavioral data to EEG system, i.e.

% oral response. Here is a code example to merge behavioral result into EEG

% data.

% Author: Jian Chen

% saturn.jian.chen@gmail.com

% 13/Dec/2016

%+++++++++++++%

%% load EEG data first, finish 'channel location', 're-reference'

% get event data via 'event = EEG.event'

event = EEG.event;

event\_back = event;

%% load behavioral data

fid = fopen('YourResponse\_acc.txt');  % here is a vector with length of 540

acc = textscan(fid,'%d');

fclose(fid);

%% set the latency between target code and inserted code

time = 100;

%% creat response event

for i = 2 : 2 : length(event)

Nevent(i/2).bepoch    = event(i).bepoch;

Nevent(i/2).bini      = event(i).bini;

Nevent(i/2).binlabel  = event(i).binlabel;

Nevent(i/2).codelabel = event(i).codelabel;

Nevent(i/2).duration  = event(i).duration;

Nevent(i/2).enable    = event(i).enable;

Nevent(i/2).flag      = event(i).flag;

Nevent(i/2).item      = event(i).item + 1;

Nevent(i/2).latency   = event(i).latency + time;

Nevent(i/2).type      = acc{1}(i/2);

end

%% add new events to original event list

for i = 1:length(Nevent)

event(2*i+i+1:end+1) = event(2*i+i:end); % move rows down

event(2\*i+i) = Nevent(i); % insert response mark

end

%% save event in case of overwrite

save event\_merge.mat event

%% if the EEG data was currently loaded, simply replace the EEG.event with event, then operate as normal

EEG.event = event;

%replace ERPLAB event if you are using ERPLAB plugin

ERP.EVENTLIST.eventinfo = event;</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Place errorbars on a grouped bar graph in MATLAB</title>
		<link>https://www.jianchen.info/2016/12/12/place-errorbars-on-a-grouped-bar-graph-in-matlab/</link>
		
		<dc:creator><![CDATA[saturn]]></dc:creator>
		<pubDate>Mon, 12 Dec 2016 23:57:27 +0000</pubDate>
				<category><![CDATA[research]]></category>
		<category><![CDATA[errorbar]]></category>
		<category><![CDATA[matlab]]></category>
		<guid isPermaLink="false">https://www.jianchen.info/?p=107</guid>

					<description><![CDATA[Well, although MATLAB is not great for plotting, a few tricks can make it drawing easier. We often use errorbar function to plot errorbar but it’s impossible for Matlab to put error bars on a grouped bar graph. Matlab simply gives a shit if you command it straightforwardly. For example: The error bars are located ... <a title="Place errorbars on a grouped bar graph in MATLAB" class="read-more" href="https://www.jianchen.info/2016/12/12/place-errorbars-on-a-grouped-bar-graph-in-matlab/" aria-label="More on Place errorbars on a grouped bar graph in MATLAB">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p>Well, although MATLAB is not great for plotting, a few tricks can make it drawing easier.</p>



<p>We often use errorbar function to plot errorbar but it’s impossible for Matlab to put error bars on a grouped bar graph. Matlab simply gives a shit if you command it straightforwardly. For example:</p>



<figure class="wp-block-image"><img decoding="async" src="https://jianch.github.io/wp-content/uploads/2021/02/WX20161212-171137.png" alt="" class="wp-image-90"/></figure>



<p>The error bars are located in the center of each grouped bars, rather than the individual bar in each grouped bars.</p>



<p>Here is the note I made, the main code is from the link below:</p>



<figure class="wp-block-embed"><div class="wp-block-embed__wrapper">
https://au.mathworks.com/matlabcentral/answers/102220-how-do-i-place-errorbars-on-my-grouped-bar-graph-using-function-errorbar-in-matlab-7-13-r2011b
</div></figure>



<figure class="wp-block-image"><img decoding="async" src="https://jianch.github.io/wp-content/uploads/2021/02/GG01Dec16a_rt_visual-field-copy-1024x732.jpg" alt="" class="wp-image-92"/><figcaption>MATLAB Handle Graphics</figcaption></figure>



<p>Code example:</p>



<pre class="wp-block-code"><code>Data set:

mm: 4 by 6 matrix; ci: 4 by 6 matrix



mm =

&#91;0.2081 0.3440 0.3470 0.7018 0.8422 0.9874
0.2628 0.3043 0.4032 0.7287 0.8462 1.1055
0.2928 0.3139 0.4176 0.7241 0.8319 1.0483
0.2287 0.2538 0.3665 0.4895 0.8999 1.1309]

ci =

&#91;0.0176 0.0473 0.0443 0.0724 0.0855 0.0931
0.0312 0.0201 0.0407 0.0621 0.0604 0.0874
0.0291 0.0330 0.0403 0.0756 0.0732 0.0847
0.0228 0.0150 0.0264 0.0598 0.0922 0.0861]</code></pre>



<pre class="wp-block-code"><code>figure;
h = bar(mm');
set(h,'BarWidth',0.8);    % The bars will now touch each other
set(gca,'fontsize', 18);
set(get(gca,'YLabel'),'String','RT in Seconds')
lh = legend('Valid Left', 'Invalid left', 'Valid right', 'Invalid right');
set(lh,'Location','BestOutside','Orientation','horizontal')
hold on;

% Aligning errorbar to individual bar within groups
% Based on barweb.m by Bolu Ajiboye from MATLAB File Exchange
groupwidth = min(0.8, 4/(4+1.5));
for i = 1:4
x = (1:6) - groupwidth/2 + (2*i-1) * groupwidth / (2*4);
errorbar(x,mm(i,:),ci(i,:),'k', 'linestyle', 'none');
end</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Sublime Text 2 with MATLAB Syntax – Windows</title>
		<link>https://www.jianchen.info/2016/01/07/sublime-text-2-with-matlab-syntax-windows/</link>
		
		<dc:creator><![CDATA[saturn]]></dc:creator>
		<pubDate>Thu, 07 Jan 2016 23:45:26 +0000</pubDate>
				<category><![CDATA[sideProject]]></category>
		<category><![CDATA[matlab]]></category>
		<category><![CDATA[sublime]]></category>
		<category><![CDATA[windows]]></category>
		<guid isPermaLink="false">https://www.jianchen.info/?p=103</guid>

					<description><![CDATA[Sublime text does not recognize .m file from MATLAB after installation and show it in Object-c syntax. How to fix it? Here is the solution: Select&#160;Preferences -&#62; Browse Packages… to open your Packages folder, and open the Objective-C subfolder. Open Objective-C.tmLanguage in Sublime as an XML file (open it in sublime), and comment out (or ... <a title="Sublime Text 2 with MATLAB Syntax – Windows" class="read-more" href="https://www.jianchen.info/2016/01/07/sublime-text-2-with-matlab-syntax-windows/" aria-label="More on Sublime Text 2 with MATLAB Syntax – Windows">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p>Sublime text does not recognize .m file from MATLAB after installation and show it in Object-c syntax. How to fix it?</p>



<p>Here is the solution:</p>



<figure class="wp-block-image"><img decoding="async" src="https://jianchen.info/images/sublime/sublime_matlab.png" alt="sublime\_matlab"/></figure>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>Select&nbsp;<strong>Preferences -&gt; Browse Packages</strong>… to open your Packages folder, and open the Objective-C subfolder. Open Objective-C.tmLanguage in Sublime as an XML file (open it in sublime), and comment out (or remove entirely) Line 7:</p>



<pre class="wp-block-code"><code>&lt;string&gt;m&lt;/string&gt;</code></pre>



<p>Save the file and close it. Next, open Objective-C++.tmLanguage and do the same thing to Line 8:</p>



<pre class="wp-block-code"><code>&lt;string&gt;M&lt;/string&gt;</code></pre>



<p>Save and close that file as well.</p>



<p>Finally, just to make sure your Open all with current extension as… command worked, go to Packages/User and check for the existence of a file called MATLAB.sublime-settings. Open it as a JSON file, and double-check that its contents are as follows:</p>



<pre class="wp-block-code"><code>{
     "extensions";
     &#91;
         "m"
     ]
}</code></pre>



<p>If for some reason the file doesn’t exist, create it with the above contents and save it.</p>



<p>Preference – User – above contents – save it as ‘MATLAB.sublime-settings</p>



<p>You should now be able to open any .m file and have the syntax automatically set to MATLAB.</p>



<p><em>(This solution mainly come from&nbsp;<a href="http://stackoverflow.com/questions/24016186/setting-default-syntax-for-sublime-doesnt-work" target="_blank" rel="noreferrer noopener">http://stackoverflow.com/questions/24016186/setting-default-syntax-for-sublime-doesnt-work</a>)</em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>EEG topography sample</title>
		<link>https://www.jianchen.info/2016/01/01/eeg-topography-sample/</link>
		
		<dc:creator><![CDATA[saturn]]></dc:creator>
		<pubDate>Fri, 01 Jan 2016 23:44:53 +0000</pubDate>
				<category><![CDATA[research]]></category>
		<category><![CDATA[eeg]]></category>
		<category><![CDATA[matlab]]></category>
		<category><![CDATA[topography]]></category>
		<guid isPermaLink="false">https://www.jianchen.info/?p=101</guid>

					<description><![CDATA[A sample to illustrate how a period of EEG topography looks like.]]></description>
										<content:encoded><![CDATA[
<p>A sample to illustrate how a period of EEG topography looks like.</p>



<figure class="wp-block-image"><img decoding="async" src="https://jianch.github.io/wp-content/uploads/2021/02/topo.gif" alt="" class="wp-image-79"/></figure>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Send Triggers via Parallel Port in Linux – using pp &#038; ppMEX.c</title>
		<link>https://www.jianchen.info/2015/12/30/send-triggers-via-parallel-port-in-linux-using-pp-ppmex-c/</link>
		
		<dc:creator><![CDATA[saturn]]></dc:creator>
		<pubDate>Wed, 30 Dec 2015 23:40:33 +0000</pubDate>
				<category><![CDATA[research]]></category>
		<category><![CDATA[matlab]]></category>
		<category><![CDATA[trigger]]></category>
		<guid isPermaLink="false">https://www.jianchen.info/?p=97</guid>

					<description><![CDATA[This method is developed by&#160;Erik Flister. It is designed to read/write TTL levels on parallel port pins under Linux, win32 (using porttalk), or matlab32 on win64 (using io32). This method includes two code files:&#160;pp.m&#160;and&#160;ppMex.c. The way to implement this method is easy, just to insert a line of code in your matlab script. To even ... <a title="Send Triggers via Parallel Port in Linux – using pp &#038; ppMEX.c" class="read-more" href="https://www.jianchen.info/2015/12/30/send-triggers-via-parallel-port-in-linux-using-pp-ppmex-c/" aria-label="More on Send Triggers via Parallel Port in Linux – using pp &#038; ppMEX.c">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p>This method is developed by&nbsp;<a href="https://groups.yahoo.com/neo/groups/psychtoolbox/conversations/messages/13972" target="_blank" rel="noreferrer noopener">Erik Flister</a>. It is designed to read/write TTL levels on parallel port pins under Linux, win32 (using porttalk), or matlab32 on win64 (using io32). This method includes two code files:&nbsp;<em><strong>pp.m</strong></em>&nbsp;and&nbsp;<em><strong>ppMex.c</strong></em>.</p>



<p>The way to implement this method is easy, just to insert a line of code in your matlab script. To even simplify the triggering job, I wrote a function here to share. So you basically only need to input the triggers you want to send into the trigger.m function. For example, trigger(1); trigger(2).</p>



<p>Download all three files at here:</p>



<p><a href="https://jianch.github.io/wp-content/uploads/2021/02/pp_ppMex.zip">pp_ppMex</a><a href="https://jianch.github.io/wp-content/uploads/2021/02/pp_ppMex.zip">Download</a></p>



<p><em><strong>trigger.m</strong></em></p>



<pre class="wp-block-code"><code>function trigger(sti_trigger)

% &#91;input] = pp(pins,&#91;output],&#91;slowChecks],&#91;port],&#91;address])
% pp(uint8(&#91;2 3 4 5 6 7 8 9]), &#91;0 0 0 0 0 0 0 0], 0, uint8(0), uint64(53248));

if sti_trigger == 0
    bin_value = &#91;0 0 0 0 0 0 0 0];
    pp(uint8(&#91;2 3 4 5 6 7 8 9]), bin_value, 0, uint8(0), uint64(53248));
end

if sti_trigger == 1
    bin_value = &#91;1 0 0 0 0 0 0 0];
    pp(uint8(&#91;2 3 4 5 6 7 8 9]), bin_value, 0, uint8(0), uint64(53248));
end

if (1 &lt; sti_trigger)&amp;&amp;(sti_trigger &lt; 4)
    bin_value = strcat('000000',dec2bin(sti_trigger));
    bin_value = fliplr(bin_value);
    bin_value = bin_value - '0' ;
    pp(uint8(&#91;2 3 4 5 6 7 8 9]), bin_value, 0, uint8(0), uint64(53248));
end

if (3 &lt; sti_trigger)&amp;&amp;(sti_trigger &lt; 8)
    bin_value = strcat('00000',dec2bin(sti_trigger));
    bin_value = fliplr(bin_value);
    bin_value = bin_value - '0' ;
    pp(uint8(&#91;2 3 4 5 6 7 8 9]), bin_value, 0, uint8(0), uint64(53248));
end

if (7 &lt; sti_trigger)&amp;&amp;(sti_trigger &lt; 16)
    bin_value = strcat('0000',dec2bin(sti_trigger));
    bin_value = fliplr(bin_value);
    bin_value = bin_value - '0' ;
    pp(uint8(&#91;2 3 4 5 6 7 8 9]), bin_value, 0, uint8(0), uint64(53248));
end

if (15 &lt; sti_trigger)&amp;&amp;(sti_trigger &lt; 32)
    bin_value = strcat('000',dec2bin(sti_trigger));
    bin_value = fliplr(bin_value);
    bin_value = bin_value - '0' ;
    pp(uint8(&#91;2 3 4 5 6 7 8 9]), bin_value, 0, uint8(0), uint64(53248));
end

if (31 &lt; sti_trigger)&amp;&amp;(sti_trigger &lt; 64)
    bin_value = strcat('00',dec2bin(sti_trigger));
    bin_value = fliplr(bin_value);
    bin_value = bin_value - '0' ;
    pp(uint8(&#91;2 3 4 5 6 7 8 9]), bin_value, 0, uint8(0), uint64(53248));
end

if (63 &lt; sti_trigger)&amp;&amp;(sti_trigger &lt; 128)
    bin_value = strcat('0',dec2bin(sti_trigger));
    bin_value = fliplr(bin_value);
    bin_value = bin_value - '0' ;
    pp(uint8(&#91;2 3 4 5 6 7 8 9]), bin_value, 0, uint8(0), uint64(53248));
end

if sti_trigger &gt; 127
    bin_value = dec2bin(sti_trigger);
    bin_value = fliplr(bin_value);
    bin_value = bin_value - '0' ;
    pp(uint8(&#91;2 3 4 5 6 7 8 9]), bin_value, 0, uint8(0), uint64(53248));
end</code></pre>



<p><em>[update 2/12/2016]</em></p>



<p><em>An minor error was found in trigger.m and has been fixed.</em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>A MATLAB Toolbox for Face Research</title>
		<link>https://www.jianchen.info/2015/12/28/a-matlab-toolbox-for-face-research/</link>
		
		<dc:creator><![CDATA[saturn]]></dc:creator>
		<pubDate>Mon, 28 Dec 2015 23:36:32 +0000</pubDate>
				<category><![CDATA[research]]></category>
		<category><![CDATA[face]]></category>
		<category><![CDATA[matlab]]></category>
		<category><![CDATA[toolbox]]></category>
		<guid isPermaLink="false">https://www.jianchen.info/?p=91</guid>

					<description><![CDATA[This toolbox can resize the face and then rotate the face. I’m working on a function that can automatically crop the face and then do the luminance balance work. Here is the source code: Pupil_faceDownload How to use: Just feed face images into the source_face folder (1 arrow) and then open and run the ‘pupil_face.m’ ... <a title="A MATLAB Toolbox for Face Research" class="read-more" href="https://www.jianchen.info/2015/12/28/a-matlab-toolbox-for-face-research/" aria-label="More on A MATLAB Toolbox for Face Research">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p>This toolbox can resize the face and then rotate the face. I’m working on a function that can automatically crop the face and then do the luminance balance work.</p>



<p>Here is the source code:</p>



<p><a href="https://jianch.github.io/wp-content/uploads/2021/02/Pupil_face.zip">Pupil_face</a><a href="https://jianch.github.io/wp-content/uploads/2021/02/Pupil_face.zip">Download</a></p>



<p>How to use:</p>



<p>Just feed face images into the source_face folder (1 arrow) and then open and run the ‘pupil_face.m’ file (3 arrow) in the current directory. Remember to connect to the internet as I use some online face analysis tools. After computation, just go to the output_face folder to pick up processed face images (3 arrow).</p>



<figure class="wp-block-image"><img decoding="async" src="https://jianch.github.io/wp-content/uploads/2021/02/2.jpg" alt="" class="wp-image-50"/></figure>



<p>Run the pupil_face.m file, then it will automatically recognise the pupil position and resize the face to a grayscale pupil-distance constant face. Remember to connect to the Internet cause I use some online source.</p>



<p>Results showing as below:</p>



<figure class="wp-block-image"><img decoding="async" src="https://jianch.github.io/wp-content/uploads/2021/02/1.png" alt="" class="wp-image-49"/></figure>



<figure class="wp-block-image"><img decoding="async" src="https://jianch.github.io/wp-content/uploads/2021/02/3.jpg" alt="" class="wp-image-51"/></figure>



<figure class="wp-block-image"><img decoding="async" src="https://jianch.github.io/wp-content/uploads/2021/02/4.jpg" alt="" class="wp-image-52"/></figure>



<figure class="wp-block-image"><img decoding="async" src="https://jianch.github.io/wp-content/uploads/2021/02/5-1024x638.jpg" alt="" class="wp-image-53"/></figure>



<figure class="wp-block-image"><img decoding="async" src="https://jianch.github.io/wp-content/uploads/2021/02/6-1024x731.png" alt="" class="wp-image-54"/></figure>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>EEG Toolbox for lazy people</title>
		<link>https://www.jianchen.info/2015/12/06/eeg-toolbox-for-lazy-people/</link>
		
		<dc:creator><![CDATA[saturn]]></dc:creator>
		<pubDate>Sun, 06 Dec 2015 04:53:24 +0000</pubDate>
				<category><![CDATA[research]]></category>
		<category><![CDATA[eeg]]></category>
		<category><![CDATA[matlab]]></category>
		<category><![CDATA[toolbox]]></category>
		<guid isPermaLink="false">https://www.jianchen.info/?p=12</guid>

					<description><![CDATA[Shichun Guo and I developed a toolbox (based on MATLAB) to analyze EEG data, we called it ”EEGKiller” because it meets our demands so nicely. Download and try it!]]></description>
										<content:encoded><![CDATA[
<p>Shichun Guo and I developed a toolbox (based on MATLAB) to analyze EEG data, we called it ”EEGKiller” because it meets our demands so nicely.</p>



<p><a href="https://www.jianchen.info/wp-content/uploads/2022/06/EEGKiller.zip" data-type="URL" data-id="https://www.jianchen.info/wp-content/uploads/2022/06/EEGKiller.zip">Download</a> and try it!</p>



<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="502" height="483" src="https://www.jianchen.info/wp-content/uploads/2022/06/interface.jpg" alt="" class="wp-image-13" srcset="https://www.jianchen.info/wp-content/uploads/2022/06/interface.jpg 502w, https://www.jianchen.info/wp-content/uploads/2022/06/interface-300x289.jpg 300w" sizes="(max-width: 502px) 100vw, 502px" /></figure>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
