Last active
August 29, 2015 14:06
-
-
Save andrewgiessel/01fb27f936345bc78225 to your computer and use it in GitHub Desktop.
make literal ephus pulse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makePulses(frameLengthsMS, orderedOdors) | |
global state | |
sample_rate = getGlobal(progmanager, 'sampleRate', 'ephys', 'ephys'); | |
trace_length_in_samples = round(sum(frameLengthsMS) * length(orderedOdors) * sample_rate/1000); | |
if trace_length_in_samples == 0 | |
return | |
end | |
stim_literal_pulse = zeros(1, trace_length_in_samples); | |
state_literal_pulse = zeros(1, trace_length_in_samples); | |
for i=1:length(orderedOdors) | |
start = round( ((i-1) * sum(frameLengthsMS)*10) + frameLengthsMS(1)*10); | |
stop = round( ((i-1) * sum(frameLengthsMS)*10) + sum(frameLengthsMS(1:2))*10); | |
stim_literal_pulse(start:stop) = 10000; | |
state_literal_pulse(start:stop) = orderedOdors(i)*1000; | |
end | |
stimPulse = signalobject('Name', 'olfactoTrigPulse', 'sampleRate', 10000); | |
literal(stimPulse, stim_literal_pulse); | |
statePulse = signalobject('Name', 'olfactoStatePulse', 'sampleRate', 10000); | |
literal(statePulse, state_literal_pulse); | |
allPulses = [stimPulse, statePulse]; | |
destdir = 'C:\scanimage_conf\olfactoPulses\olfactoPulses'; | |
for signal = allPulses | |
saveCompatible(fullfile(destdir, [get(signal, 'Name') '.signal']), 'signal', '-mat'); | |
end | |
delete(allPulses) | |
% set acquierer, ephys, and stim trace lengths | |
ephys_setTraceLength(ceil(trace_length_in_samples/sample_rate)); | |
acq_setTraceLength(ceil(trace_length_in_samples/sample_rate)); | |
stim_setTraceLength(ceil(trace_length_in_samples/sample_rate)); | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
seconds = 10; | |
sample_rate = 10000; | |
stim_literal_pulse = zeros(1, seconds*sample_rate); | |
stim_literal_pulse(50000:51000) = 5000; | |
stimPulse = signalobject('Name', 'stimPulse', 'sampleRate', 10000); | |
literal(stimPulse, stim_literal_pulse); | |
destdir = 'C:\scanimage_conf\olfactoPulses\demo'; % directory must exist and contain a sub directory called '_subpulses' | |
saveCompatible(fullfile(destdir, [get(stimPulse, 'Name') '.signal']), 'stimPulse', '-mat'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment