Trigger scanner script: E-Prime and MatLab

1 min read

E-Prime
This piece of code is used in Lucas Center scanner #2 at Stanford University.

SRBOX.Lamps "4"
Sleep(100)
SRBOX.Lamps ""

Set SumACC = New Summation

You also need to declare SumACC in user script

Dim SumACC = As Summation

MatLab
If you want to use MatLab to trigger the scanners, check out the following script.

function [status, time0] = StartScan(pulseLength);
% StartScan - Starts the MR scanner by sending a pulse
%  [status, time0] = StartScan(pulseLength);
%             when error ocurred status will be non-zero
%             time0 is the time (GetSecs) when the onset of the pulse
%             started, used for syncing stimulus and MR time.
%
% Uses PMD-1208FS and Psychtoolbox. Pin 14 will give ~5V signal, pin 17
% can be used as a ground.
%
% 24-Jun-2005 SOD Ported to OSX - uses DAQ toolbox and the
%                 PMD-1208FS data acquisition device (daq).
%                 The PMD-1208FS is made by Measurement Computing.
%                 http://www.measurementcomputing.com/pmd.html

% defaults
if nargin < 1 | isempty(pulseLength),
    pulseLength=0.001;
end;
status = 0; % unless we have problems

% Do we have a PMD-1208FS daq?
daq=DaqDeviceIndex;
if length(daq) == 0, % No we don't
    disp(sprintf(['[' mfilename ']:Sorry. Couldn''t find a PMD-1208FS box connected to your computer.\n' ... 
           'NOT RESPONDING? If PsychHID is not responding, e.g. after unplugging and\n' ...
           're-plugging the USB connector of your device, try quitting and restarting\n' ...
           'MATLAB. We find that this reliably restores normal communication.']));
    disp(sprintf(['[' mfilename ']:SCAN NOT STARTED!']));
    status = 1;
    time0  = GetSecs;
    return;
else, % Yes we do
    devices=PsychHID('Devices');
    d=devices(daq(1)); % use only first one if more connected
    disp(sprintf('[%s]:Found PMD-1208FS daq: device %d, serialNumber %s.',...
            mfilename,d.index,d.serialNumber));
end;

% Configuring digital ports for output
err=DaqDConfigPort(daq(1),1,0); % should be pin 14

% Make sure the PMD-1208FS is "attached". If not give a warning message.
% We may want to consider giving an error... 
if streq(err.name,'kIOReturnNotAttached')
    disp(sprintf(['[' mfilename ']:Mac OS error message says PMD-1208FS is "not attached".\n'...
          'If it is attached, we suggest that you quit and restart MATLAB.']));
    disp(sprintf(['[' mfilename ']:SCAN NOT STARTED!']));
    status = 1;
    time0  = GetSecs;
    return;
end

% get time0
time0 = GetSecs;

% Send pulse
DaqAOut(daq(1),1,1);    % send pulse
WaitSecs(pulseLength);  % for a particular length, and then
DaqAOut(daq(1),1,0);    % reset

return;

第三十期 fNIRS Journal Club 通知 2022/05/28,10am

三个臭皮匠顶个诸葛亮背后的机理是什么?浙江大学潘亚峰研究员将为大家讲解他们最近发布的一篇用三人超扫描研究合作学习的文章。热烈欢迎大家参与讨论。 时间: 北京时间2022年5月28日周六上午10点地点: https://zoom.com房间号: 869 5374 8016 密码: 383720 Pan, Cheng, Hu (2022) Three heads are better than one: cooperative learning brains wire together...
Xu Cui
6 sec read

第二十九期 fNIRS Journal Club 视频

光子在大脑中是如何散射的?如何用计算机模拟的方法了解fNIRS的测量基础?来自波士顿大学的程小峻博士为大家分享他们近期在 J Biomed Opt 发表的文章。 Youtube: https://youtu.be/rbqGI3tSEBw Youku: https://v.youku.com/v_show/id_XNTg2NjgzMjk4MA==.html 相关资源: 文献鸟(追踪科学文献)文献大分析(两分钟了解一个领域)
Xu Cui
5 sec read

第二十九期 fNIRS Journal Club 通知 2022/4/30,10:00am

光子在大脑中是如何散射的?如何用计算机模拟的方法了解fNIRS的测量基础?来自波士顿大学的程小峻博士将为大家分享他们近期在 J Biomed Opt 发表的文章。 热烈欢迎大家参与讨论。 时间: 北京时间2022年4月30日上午10:00地点: https://zoom.com房间号: 868 4070 8135密码: 655816 程小峻要讲解的文章如下: Cheng, Chen, Sie, Marsili, Boas (2022) Development of a Monte...
Xu Cui
9 sec read

Leave a Reply

Your email address will not be published. Required fields are marked *