function startBasicElectrophysiology % 102407 Only works with 700A/B for now % %Clear the workspace (prompt first). clearWorkspace; %Set up a wait bar to show the progress. wb = waitbarWithCancel(0, 'Starting ephys...', 'Name', 'Loading Physiology software...'); pos = get(wb, 'Position'); pos(2) = pos(2) - pos(4); set(wb, 'Position', pos); %-------------------------------------------------- %Set up the triggering. <<<<<<<<<<---------- CONFIG acqJob = daqjob('acquisition'); scopeJob = daqjob('scope'); setTriggerOrigin(acqJob, '/dev1/port0/line0'); setTriggerOrigin(scopeJob, '/dev1/port0/line0'); setTriggerDestination(acqJob, 'PFI0'); setTriggerDestination(scopeJob, 'PFI0'); %-------------------------------------------------- %Open the xsg. waitbar(0.10, wb, 'Opening experimentSavingGui...'); if isWaitbarCancelled(wb) delete(wb); return; end xsg_getFilename; %-------------------------------------------------- %Start ephys waitbar(0.15, wb, 'Opening ephys...'); if isWaitbarCancelled(wb) delete(wb); return; end ep = program('ephys', 'ephys', 'ephys'); openprogram(progmanager, ep); %-------------------------------------------------- %Set up amplifier(s). <<<<<<<<<<---------- CONFIG waitbar(0.20, wb, 'Creating amplifiers...'); if isWaitbarCancelled(wb) delete(wb); return; end patch{1} = multi_clamp('text_file_location', 'C:\dev\sandbox\Matlab\svobodalab\USERCLASSES\@multi_clamp\MClampChannel1.txt', 'scaledOutputBoardID', 1, 'scaledOutputChannelID', 0, ... 'vComBoardID', 1, 'vComChannelID', 0, 'channel', 1, 'name', '700B-1'); bindToDaqJob(patch{1}, acqJob); %-------------------------------------------------- %Add the amplifier(s) to ephys. waitbar(0.25, wb, 'Mounting amplifiers in ephys...'); if isWaitbarCancelled(wb) delete(wb); return; end ep = getGlobal(progmanager, 'hObject', 'ephys', 'ephys'); ephys_setAmplifiers(ep, patch); %-------------------------------------------------- waitbar(0.30, wb, 'Opening scopeGui...'); %Start the ephys-enabled scope. scg = program('scopeGui', 'scopeGui', 'scopeGui', 'ephysScopeAccessory', 'ephysScopeAccessory'); openprogram(progmanager, scg); ephysAcc = getGlobal(progmanager, 'hObject', 'ephysScopeAccessory', 'ScopeGui'); waitbar(0.35, wb, 'Mounting amplifiers in scopeGui...'); if isWaitbarCancelled(wb) delete(wb); return; end bindToDaqJob(patch{1}, scopeJob); setChannelProperty(scopeJob, getVComChannelName(patch{1}), 'dataSource', {@ephysAcc_getOutputData, ep, getVComChannelName(patch{1})}); ephysAcc_setAmplifiers(ephysAcc, patch); %-------------------------------------------------- %Open the stimulator gui. waitbar(0.40, wb, 'Opening stimulator...'); if isWaitbarCancelled(wb) delete(wb); return; end stim = program('stimulator', 'stimulator', 'stimulator'); openprogram(progmanager, stim); %-------------------------------------------------- %Open the stimulator gui. waitbar(0.45, wb, 'Mounting channels in stimulator...'); if isWaitbarCancelled(wb) delete(wb); return; end %Here's the channel(s) for the stimulator. stimChannels(1).channelName = 'shutter0';%<<<<<<<<<<---------- CONFIG stimChannels(1).boardID = 2;%<<<<<<<<<<---------- CONFIG stimChannels(1).channelID = 1;%<<<<<<<<<<---------- CONFIG stimChannels(2).channelName = 'shutter1';%<<<<<<<<<<---------- CONFIG stimChannels(2).boardID = 2;%<<<<<<<<<<---------- CONFIG stimChannels(2).channelID = 0;%<<<<<<<<<<---------- CONFIG % stimChannels(2).channelName = 'pockelsCell';%<<<<<<<<<<---------- CONFIG % stimChannels(2).boardID = 2;%<<<<<<<<<<---------- CONFIG % stimChannels(2).channelID = 0;%<<<<<<<<<<---------- CONFIG % % stimChannels(3).channelName = 'xMirror';%<<<<<<<<<<---------- CONFIG % stimChannels(3).boardID = 3;%<<<<<<<<<<---------- CONFIG % stimChannels(3).channelID = 0;%<<<<<<<<<<---------- CONFIG % % stimChannels(4).channelName = 'yMirror';%<<<<<<<<<<---------- CONFIG % stimChannels(4).boardID = 3;%<<<<<<<<<<---------- CONFIG % stimChannels(4).channelID = 1;%<<<<<<<<<<---------- CONFIG stim_setChannels(stim, stimChannels); %-------------------------------------------------- %Open the acquirer gui. waitbar(0.50, wb, 'Opening acquirer...'); if isWaitbarCancelled(wb) delete(wb); return; end acq = program('acquirer', 'acquirer', 'acquirer'); openprogram(progmanager, acq); %-------------------------------------------------- %Open the acquirer gui. waitbar(.55, wb, 'Mounting channels in acquirer...'); if isWaitbarCancelled(wb) delete(wb); return; end %Here's the channel(s) for the stimulator. acqChannels(1).channelName = 'photodiode1';%<<<<<<<<<<---------- CONFIG acqChannels(1).boardID = 2;%<<<<<<<<<<---------- CONFIG acqChannels(1).channelID = 0;%<<<<<<<<<<---------- CONFIG acq_setChannels(acq, acqChannels); %-------------------------------------------------- %Open the pulseEditor. waitbar(0.60, wb, 'Opening pulseEditor...'); if isWaitbarCancelled(wb) delete(wb); return; end pe = program('pulseEditor', 'pulseEditor', 'pulseEditor'); openprogram(progmanager, pe); %TO022406D try peCbm = getLocal(progmanager, pe, 'callbackManager'); addCallback(peCbm, 'pulseCreation', {@shared_pulseCreation, ep}, 'ephys_pulseCreation'); addCallback(peCbm, 'pulseDeletion', {@shared_pulseCreation, ep}, 'ephys_pulseDeletion'); addCallback(peCbm, 'pulseSetCreation', {@shared_pulseSetCreation, ep}, 'ephys_pulseSetCreation'); addCallback(peCbm, 'pulseSetDeletion', {@shared_pulseSetDeletionn, ep}, 'ephys_pulseSetDeletion'); addCallback(peCbm, 'pulseUpdate', {@shared_pulseCreation, ep}, 'ephys_pulseUpdate'); addCallback(peCbm, 'pulseCreation', {@shared_pulseCreation, stim}, 'stim_pulseCreation'); addCallback(peCbm, 'pulseDeletion', {@shared_pulseDeletion, stim}, 'stim_pulseDeletion'); addCallback(peCbm, 'pulseSetCreation', {@shared_pulseSetCreation, stim}, 'stim_pulseSetCreation'); addCallback(peCbm, 'pulseSetDeletion', {@shared_pulseSetDeletionn, stim}, 'stim_pulseSetDeletion'); addCallback(peCbm, 'pulseUpdate', {@shared_pulseUpdate, stim}, 'stim_pulseUpdate'); catch warning('Error registering callbacks for pulseEditor events.'); end %-------------------------------------------------- %Open the pulseEditor waitbar(0.65, wb, 'Registering loopable components...'); if isWaitbarCancelled(wb) delete(wb); return; end [lg lm] = lg_factory;%This opens the loop gui. registerLoopable(lm, {@shared_loopListener, ep}, 'ephys'); [lg lm] = lg_factory;%This opens the loop gui. registerLoopable(lm, {@shared_loopListener, ep}, 'ephys'); registerLoopable(lm, {@shared_loopListener, acq}, 'acquirer'); registerLoopable(lm, {@shared_loopListener, stim}, 'stimulator'); %-------------------------------------------------- %Open the userFcns gui. waitbar(0.70, wb, 'Opening userFcns...'); if isWaitbarCancelled(wb) delete(wb); return; end userFcns = program('userFcns', 'userFcns', 'userFcns'); openprogram(progmanager, userFcns); %-------------------------------------------------- %Open the autonotes gui. waitbar(0.75, wb, 'Opening autonotes...'); if isWaitbarCancelled(wb) delete(wb); return; end userFcns = program('autonotes', 'autonotes', 'autonotes'); openprogram(progmanager, userFcns); %-------------------------------------------------- %Open the pulse hijacking gui. waitbar(0.80, wb, 'Opening pulseJacker...'); pj = program('pulseJacker', 'pulseJacker', 'pulseJacker'); openprogram(progmanager, pj); pj_setPrograms(pj, {ep, stim}); addCallback(peCbm, 'pulseCreation', {@pj_pulseCreation, pj}, 'pj_pulseCreation'); addCallback(peCbm, 'pulseDeletion', {@pj_pulseDeletion, pj}, 'pj_pulseDeletion'); addCallback(peCbm, 'pulseSetCreation', {@pj_pulseSetCreation, pj}, 'pj_pulseSetCreation'); addCallback(peCbm, 'pulseSetDeletion', {@pj_pulseSetDeletionn, pj}, 'pj_pulseSetDeletion'); pj_setPrograms(pj, {ep, stim}); registerLoopable(lm, {@pj_loopListener, pj}, 'pulseJacker'); %-------------------------------------------------- %Open the hot switch gui. waitbar(0.85, wb, 'Opening HotSwitch...'); hs = program('hotswitch', 'hotswitch', 'hotswitch', 'hs_config', 'hs_config'); openprogram(progmanager, hs); %-------------------------------------------------- %Open the mirror configuration gui. % waitbar(.90, wb, 'Initializing imaging system...'); % if isWaitbarCancelled(wb) % delete(wb); % return; % end % % imagingSys = program('imagingSys', 'imagingSys', 'imagingSystemConfiguration'); % openprogram(progmanager, imagingSys); % % xMirrorBoardID = 3; % xMirrorChannelID = 0; % yMirrorBoardID = 3; % yMirrorChannelID = 1; % % setLocalBatch(progmanager, imagingSys, 'xBoardID', xMirrorBoardID, 'xChannelID', xMirrorChannelID, ... % 'yBoardID', yMirrorBoardID, 'yChannelID', yMirrorChannelID, 'name', 'Mapper-Scanner01'); %-------------------------------------------------- %Open the photodiode calibration gui. % waitbar(.95, wb, 'Initializing photodiode configuration...'); % if isWaitbarCancelled(wb) % delete(wb); % return; % end % % pdiodeConfig = program('photodiode', 'photodiode', 'photodiodeConfiguration'); % openprogram(progmanager, pdiodeConfig); % % pdiode = photodiode; % set(pdiode, 'boardID', acqChannels(1).boardID, 'channelID', acqChannels(1).channelID, 'name', acqChannels(1).channelName); % setLocalBatch(progmanager, pdiodeConfig, 'boardID', acqChannels(1).boardID, 'channelID', acqChannels(1).channelID, 'photodiodeName', acqChannels(1).channelName, 'photodiodeObject', pdiode); % % %-------------------------------------------------- % %Open the mirror configuration gui. % waitbar(0.98, wb, 'Starting mapper...'); % if isWaitbarCancelled(wb) % delete(wb); % return; % end % % mapper = program('mapper', 'mapper', 'mapper'); % openprogram(progmanager, mapper); % % setLocal(progmanager, mapper, 'photodiodeObject', pdiode); % % %Set the um/pixel for the video image here. % %This is necessary for importing from digital video. It tells the mapper how many microns are in the field of view. % %This is not superceded by the imagingSys, which may be calibrated against some visual standard that is not % %equal to the entire field of view. % setLocalBatch(progmanager, mapper, 'xVideoScaleFactor', 1820, 'yVideoScaleFactor', 1385);%<<<<<<<<<<---------- CONFIG %-------------------------------------------------- %Load a configuration (if requested). waitbar(0.99, wb, 'Loading configuration...'); loadConfigurations(progmanager); fprintf(1, '\nLoading Completed.\n\n'); % try % startDigitalVideo; % mapperObj = getLocal(progmanager, mapperObj, 'hObject'); % mapper('videoCapture_Callback', mapperObj, [], guidata(mapperObj)); % catch % fprintf(1, 'May have failed to start DigitalVideo and/or grab the video image in the Mapper during startup. %s\nMake sure it gets done manually.', lasterr); % end %Kill the waitbar. delete(wb); fprintf(1, '\n\n-----------------------------------\n-----------------------------------\n\n\n\n\n\n\n\n');