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;



写作助手,把中式英语变成专业英文


Want to receive new post notification? 有新文章通知我

第五十一期fNIRS Journal Club通知2024/05/11, 10am 雷心博士

机器人通常以合作者的身份出现,以礼貌、鼓励、友好的方式与人类互动,但如果有一个竞争导向的机器人出现会如何?人们更喜欢与合作导向的机器人互动,还是更愿意通过竞争来激发自身动力呢?当我们与机器人合作或竞争
Wanling Zhu
13 sec read

第五十期fNIRS Journal Club视频 王一晖

Youtube: https://youtu.be/a2QlCFZUytA优酷:https://v.youku.com/v_show/id_XNjM3MjMyNjUxMg==.html 早期的 STE
Wanling Zhu
13 sec read

第五十期fNIRS Journal Club通知2024/03/30, 10am 王一晖

早期的 STEM 教育对于以后的学习至关重要。现有研究尚未就STEM教学法达成共识,学生先验知识对基于故事的STEM教学法的影响还有待探讨。来自澳门大学张娟教授团队的王一晖将会分享基于fNIRS超扫描
Wanling Zhu
9 sec read

Leave a Reply

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