diff --git a/Figure Handlers/PowerSpectrumFigureHandler.m b/Figure Handlers/PowerSpectrumFigureHandler.m new file mode 100644 index 0000000..4e0d516 --- /dev/null +++ b/Figure Handlers/PowerSpectrumFigureHandler.m @@ -0,0 +1,124 @@ +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html + +classdef PowerSpectrumFigureHandler < FigureHandler + + properties (Constant) + figureType = 'Power Spectrum' + end + + properties + meanPlots % array of structures to store the properties of each class of epoch. + meanParamNames + end + + methods + + function obj = PowerSpectrumFigureHandler(protocolPlugin, varargin) + obj = obj@FigureHandler(protocolPlugin); + + xlabel(obj.axesHandle(), 'sec'); + set(obj.axesHandle(), 'XTickMode', 'auto'); + + obj.resetPlots(); + + ip = inputParser; + ip.addParamValue('GroupByParams', {}, @(x)iscell(x) || ischar(x)); + ip.parse(varargin{:}); + + if iscell(ip.Results.GroupByParams) + obj.meanParamNames = ip.Results.GroupByParams; + else + obj.meanParamNames = {ip.Results.GroupByParams}; + end + end + + + function handleCurrentEpoch(obj) + [responseData, sampleRate, units] = obj.protocolPlugin.response(); + responseData = fft(responseData); + responseData = responseData.*conj(responseData); + + % Get the parameters for this "class" of epoch. + % An epoch class is defined by a set of parameter values. + if isempty(obj.meanParamNames) + % Automatically detect the set of parameters. + epochParams = obj.protocolPlugin.epochSpecificParameters(); + else + % The protocol has specified which parameters to use. + for i = 1:length(obj.meanParamNames) + epochParams.(obj.meanParamNames{i}) = obj.protocolPlugin.epoch.ProtocolParameters.Item(obj.meanParamNames{i}); + end + end + + % Check if we have existing data for this class of epoch. + meanPlot = struct([]); + for i = 1:numel(obj.meanPlots) + if isequal(obj.meanPlots(i).params, epochParams) + meanPlot = obj.meanPlots(i); + break; + end + end + + if isempty(meanPlot) + % This is the first epoch of this class to be plotted. + meanPlot = {}; + meanPlot.params = epochParams; + meanPlot.data = responseData; + meanPlot.sampleRate = sampleRate; + meanPlot.units = [units,'^2']; + meanPlot.count = 1; + hold(obj.axesHandle(), 'on'); + meanPlot.plotHandle = loglog(obj.axesHandle(), (1:length(meanPlot.data)/2) * sampleRate, meanPlot.data(1:length(meanPlot.data)/2)); + obj.meanPlots(end + 1) = meanPlot; + else + % This class of epoch has been seen before, add the current response to the mean. + % TODO: Adjust response data to the same sample rate and unit as previous epochs if needed. + % TODO: if the length of data is varying then the mean will not be correct beyond the min length. + meanPlot.data = (meanPlot.data * meanPlot.count + responseData) / (meanPlot.count + 1); + meanPlot.count = meanPlot.count + 1; + set(meanPlot.plotHandle, 'XData', (1:length(meanPlot.data)/2) * sampleRate, ... + 'YData', meanPlot.data); + obj.meanPlots(i) = meanPlot; + end + + % Update the y axis with the units of the response. + ylabel(obj.axesHandle(), [units,'^2']); + + if isempty(epochParams) + titleString = 'All epochs grouped together.'; + else + paramNames = fieldnames(epochParams); + titleString = ['Grouped by ' humanReadableParameterName(paramNames{1})]; + for i = 2:length(paramNames) - 1 + titleString = [titleString ', ' humanReadableParameterName(paramNames{i})]; + end + if length(paramNames) > 1 + titleString = [titleString ' and ' humanReadableParameterName(paramNames{end})]; + end + end + title(obj.axesHandle(), titleString); + end + + + function clearFigure(obj) + obj.resetPlots(); + + clearFigure@FigureHandler(obj); + end + + + function resetPlots(obj) + obj.meanPlots = struct('params', {}, ... % The params that define this class of epochs. + 'data', {}, ... % The mean of all responses of this class. + 'sampleRate', {}, ... % The sampling rate of the mean response. + 'units', {}, ... % The units of the mean response. + 'count', {}, ... % The number of responses used to calculate the mean reponse. + 'plotHandle', {}); % The handle of the plot for the mean response of this class. + end + + end + +end \ No newline at end of file diff --git a/Protocols/Grid/allcombs.m b/Protocols/Grid/allcombs.m deleted file mode 100644 index 71ef394..0000000 --- a/Protocols/Grid/allcombs.m +++ /dev/null @@ -1,37 +0,0 @@ -% Copyright (c) 2012 Howard Hughes Medical Institute. -% All rights reserved. -% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. -% http://license.janelia.org/license/jfrc_copyright_1_1.html - -function A = allcombs(varargin) - -% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange -% modified so it can take a scalar (or vector) as the first input - -% modified part1 -if numel(varargin{1})==1 - varargin{1} = [varargin{1} NaN]; -end - -% simplified version of allcomb function -q = ~cellfun('isempty',varargin); -ni = sum(q) ; -ii = ni:-1:1 ; -if ni==0, - A = [] ; -else - args = varargin(q) ; - - if ni==1, - A = args{1}(:) ; - else - % flip using ii if last column is changing fastest - [A{ii}] = ndgrid(args{ii}) ; - % concatenate - A = reshape(cat(ni+1,A{:}),[],ni) ; - end -end -% end of allcomb function - -% modified part2 -A(isnan(A(:,1)),:) = []; diff --git a/Protocols/HotspotsDS/allcombs.m b/Protocols/HotspotsDS/allcombs.m deleted file mode 100755 index 71ef394..0000000 --- a/Protocols/HotspotsDS/allcombs.m +++ /dev/null @@ -1,37 +0,0 @@ -% Copyright (c) 2012 Howard Hughes Medical Institute. -% All rights reserved. -% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. -% http://license.janelia.org/license/jfrc_copyright_1_1.html - -function A = allcombs(varargin) - -% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange -% modified so it can take a scalar (or vector) as the first input - -% modified part1 -if numel(varargin{1})==1 - varargin{1} = [varargin{1} NaN]; -end - -% simplified version of allcomb function -q = ~cellfun('isempty',varargin); -ni = sum(q) ; -ii = ni:-1:1 ; -if ni==0, - A = [] ; -else - args = varargin(q) ; - - if ni==1, - A = args{1}(:) ; - else - % flip using ii if last column is changing fastest - [A{ii}] = ndgrid(args{ii}) ; - % concatenate - A = reshape(cat(ni+1,A{:}),[],ni) ; - end -end -% end of allcomb function - -% modified part2 -A(isnan(A(:,1)),:) = []; diff --git a/Protocols/LEDFlash/LEDFlash.m b/Protocols/LEDFlash/LEDFlash.m new file mode 100644 index 0000000..68cef69 --- /dev/null +++ b/Protocols/LEDFlash/LEDFlash.m @@ -0,0 +1,134 @@ +% Creates a single stimulus composed of mean + flash. +% Implements SymphonyProtocol +% +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html +% +% Modified by TA 9.8.12 from LED Family to create a single LED pulse protocol + +classdef LEDFlash < SymphonyProtocol + + properties (Constant) + identifier = 'helsinki.yliopisto.pal' + version = 1 + displayName = 'LED Flash' + end + + properties + stimPoints = uint16(100); + prePoints = uint16(1000); + tailPoints = uint16(4000); + stimAmplitude = 0.5; + lightMean = 0.0; + preSynapticHold = -60; + numberOfAverages = uint8(5); + interpulseInterval = 0.6; + continuousRun = false; + end + + properties (Dependent = true, SetAccess = private) % these properties are inherited - i.e., not modifiable + % ampOfLastStep; + end + + methods + + function [stimulus, lightAmplitude] = stimulusForEpoch(obj, ~) % epoch Num is usually required + % Calculate the light amplitude for this epoch. + % phase = single(mod(epochNum - 1, obj.stepsInFamily)); % Frank's clever way to determine which flash in a family to deliver + lightAmplitude = obj.stimAmplitude; % * obj.ampStepScale ^ phase; % Frank's clever way to determine the amplitude of the flash family to deliver + + % Create the stimulus + stimulus = ones(1, obj.prePoints + obj.stimPoints + obj.tailPoints) * obj.lightMean; + stimulus(obj.prePoints + 1:obj.prePoints + obj.stimPoints) = lightAmplitude; + end + + + function stimulus = sampleStimuli(obj) % Return a cell array + % you can only create one stimulus with this protocol TA + stimulus{1} = obj.stimulusForEpoch(); + end + + + function prepareRig(obj) + % Call the base class method to set the DAQ sample rate. + prepareRig@SymphonyProtocol(obj); + + %obj.setDeviceBackground('LED', obj.lightMean, 'V'); + +% if strcmp(obj.rigConfig.multiClampMode('Amplifier_Ch1'), 'IClamp') +% obj.setDeviceBackground('Amplifier_Ch1', double(obj.preSynapticHold) * 1e-12, 'A'); +% else +% obj.setDeviceBackground('Amplifier_Ch1', double(obj.preSynapticHold) * 1e-3, 'V'); +% end + end + + + function prepareRun(obj) + % Call the base class method which clears all figures. + prepareRun@SymphonyProtocol(obj); + + obj.openFigure('Response'); + obj.openFigure('Mean Response', 'GroupByParams', {'lightAmplitude'}); + obj.openFigure('Response Statistics', 'StatsCallback', @responseStatistics); + end + + + function prepareEpoch(obj) + % Call the base class method which sets up default backgrounds and records responses. + prepareEpoch@SymphonyProtocol(obj); + + [stimulus, lightAmplitude] = obj.stimulusForEpoch(obj.epochNum); + obj.addParameter('lightAmplitude', lightAmplitude); + %obj.addStimulus('LED', 'test-stimulus', stimulus, 'V'); % + obj.setDeviceBackground('LED', obj.lightMean, 'V'); + if strcmp(obj.multiClampMode, 'VClamp') + obj.setDeviceBackground('Amplifier_Ch1', double(obj.preSynapticHold) * 1e-3, 'V'); + else + obj.setDeviceBackground('Amplifier_Ch1', double(obj.preSynapticHold) * 1e-12, 'A'); + end + obj.addStimulus('LED', 'LED stimulus', stimulus, 'V'); % + end + + + function stats = responseStatistics(obj) + r = obj.response(); + + % baseline mean and var + if ~isempty(r) + stats.mean = mean(r(1:obj.prePoints)); + stats.var = var(r(1:obj.prePoints)); + else + stats.mean = 0; + stats.var = 0; + end + end + + + function completeEpoch(obj) + % Call the base class method which updates the figures. + completeEpoch@SymphonyProtocol(obj); + + % Pause for the inter-pulse interval. + pause on + pause(obj.interpulseInterval); + end + + + function keepGoing = continueRun(obj) + % First check the base class method to make sure the user hasn't paused or stopped the protocol. + keepGoing = continueRun@SymphonyProtocol(obj); + + if keepGoing + keepGoing = obj.epochNum < obj.numberOfAverages; + end + end + + +% function amp = get.ampOfLastStep(obj) % The product of the number of steps in family, the first step amplitude, and the 'scale factor' +% amp = obj.baseLightAmplitude * obj.ampStepScale ^ (obj.stepsInFamily - 1); +% end + + end +end \ No newline at end of file diff --git a/Protocols/LEDMultiFlash/LEDMultiFlash.m b/Protocols/LEDMultiFlash/LEDMultiFlash.m new file mode 100644 index 0000000..b390884 --- /dev/null +++ b/Protocols/LEDMultiFlash/LEDMultiFlash.m @@ -0,0 +1,134 @@ +% Creates a single stimulus composed of mean + flash for multiple LEDs +% Implements SymphonyProtocol +% +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html +% +% Modified by TA 9.8.12 from LED Family to create a single LED pulse protocol +classdef LEDMultiFlash < SymphonyProtocol + + properties (Constant) + identifier = 'helsinki.yliopisto.pal' + version = 1 + displayName = 'Multi LED Flash' + end + + properties + stimPoints = uint16(100); + prePoints = uint16(1000); + tailPoints = uint16(4000); + stimAmplitude = 0.5; + lightMean = 0.0; + preSynapticHold = -60; + numberOfAverages = uint8(5); + interpulseInterval = 0.6; + continuousRun = false; + LED = {'Red_LED','Green_LED','Blue_LED'}; + end + + properties (Dependent = true, SetAccess = private) % these properties are inherited - i.e., not modifiable + % ampOfLastStep; + end + + methods + + function [stimulus, lightAmplitude] = stimulusForEpoch(obj, ~) % epoch Num is usually required + % Calculate the light amplitude for this epoch. + % phase = single(mod(epochNum - 1, obj.stepsInFamily)); % Frank's clever way to determine which flash in a family to deliver + lightAmplitude = obj.stimAmplitude; % * obj.ampStepScale ^ phase; % Frank's clever way to determine the amplitude of the flash family to deliver + + % Create the stimulus + stimulus = ones(1, obj.prePoints + obj.stimPoints + obj.tailPoints) * obj.lightMean; + stimulus(obj.prePoints + 1:obj.prePoints + obj.stimPoints) = lightAmplitude; + end + + + function stimulus = sampleStimuli(obj) % Return a cell array + % you can only create one stimulus with this protocol TA + stimulus{1} = obj.stimulusForEpoch(); + end + + + function prepareRig(obj) + % Call the base class method to set the DAQ sample rate. + prepareRig@SymphonyProtocol(obj); + + %obj.setDeviceBackground('LED', obj.lightMean, 'V'); + +% if strcmp(obj.rigConfig.multiClampMode('Amplifier_Ch1'), 'IClamp') +% obj.setDeviceBackground('Amplifier_Ch1', double(obj.preSynapticHold) * 1e-12, 'A'); +% else +% obj.setDeviceBackground('Amplifier_Ch1', double(obj.preSynapticHold) * 1e-3, 'V'); +% end + end + + + function prepareRun(obj) + % Call the base class method which clears all figures. + prepareRun@SymphonyProtocol(obj); + + obj.openFigure('Response'); + obj.openFigure('Mean Response', 'GroupByParams', {'lightAmplitude'}); + obj.openFigure('Response Statistics', 'StatsCallback', @responseStatistics); + end + + + function prepareEpoch(obj) + % Call the base class method which sets up default backgrounds and records responses. + prepareEpoch@SymphonyProtocol(obj); + + [stimulus, lightAmplitude] = obj.stimulusForEpoch(obj.epochNum); + obj.addParameter('lightAmplitude', lightAmplitude); + %obj.addStimulus('LED', 'test-stimulus', stimulus, 'V'); % + obj.setDeviceBackground(obj.LED, obj.lightMean, 'V'); + if strcmp(obj.multiClampMode, 'VClamp') + obj.setDeviceBackground('Amplifier_Ch1', double(obj.preSynapticHold) * 1e-3, 'V'); + else + obj.setDeviceBackground('Amplifier_Ch1', double(obj.preSynapticHold) * 1e-12, 'A'); + end + obj.addStimulus(obj.LED, sprintf('%s stimulus',obj.LED), stimulus, 'V'); % + end + + + function stats = responseStatistics(obj) + r = obj.response(); + + % baseline mean and var + if ~isempty(r) + stats.mean = mean(r(1:obj.prePoints)); + stats.var = var(r(1:obj.prePoints)); + else + stats.mean = 0; + stats.var = 0; + end + end + + + function completeEpoch(obj) + % Call the base class method which updates the figures. + completeEpoch@SymphonyProtocol(obj); + + % Pause for the inter-pulse interval. + pause on + pause(obj.interpulseInterval); + end + + + function keepGoing = continueRun(obj) + % First check the base class method to make sure the user hasn't paused or stopped the protocol. + keepGoing = continueRun@SymphonyProtocol(obj); + + if keepGoing + keepGoing = obj.epochNum < obj.numberOfAverages; + end + end + + +% function amp = get.ampOfLastStep(obj) % The product of the number of steps in family, the first step amplitude, and the 'scale factor' +% amp = obj.baseLightAmplitude * obj.ampStepScale ^ (obj.stepsInFamily - 1); +% end + + end +end \ No newline at end of file diff --git a/Protocols/LoomingObjects/allcombs.m b/Protocols/LoomingObjects/allcombs.m deleted file mode 100644 index 71ef394..0000000 --- a/Protocols/LoomingObjects/allcombs.m +++ /dev/null @@ -1,37 +0,0 @@ -% Copyright (c) 2012 Howard Hughes Medical Institute. -% All rights reserved. -% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. -% http://license.janelia.org/license/jfrc_copyright_1_1.html - -function A = allcombs(varargin) - -% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange -% modified so it can take a scalar (or vector) as the first input - -% modified part1 -if numel(varargin{1})==1 - varargin{1} = [varargin{1} NaN]; -end - -% simplified version of allcomb function -q = ~cellfun('isempty',varargin); -ni = sum(q) ; -ii = ni:-1:1 ; -if ni==0, - A = [] ; -else - args = varargin(q) ; - - if ni==1, - A = args{1}(:) ; - else - % flip using ii if last column is changing fastest - [A{ii}] = ndgrid(args{ii}) ; - % concatenate - A = reshape(cat(ni+1,A{:}),[],ni) ; - end -end -% end of allcomb function - -% modified part2 -A(isnan(A(:,1)),:) = []; diff --git a/Protocols/MovingBar/allcombs.m b/Protocols/MovingBar/allcombs.m deleted file mode 100644 index 71ef394..0000000 --- a/Protocols/MovingBar/allcombs.m +++ /dev/null @@ -1,37 +0,0 @@ -% Copyright (c) 2012 Howard Hughes Medical Institute. -% All rights reserved. -% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. -% http://license.janelia.org/license/jfrc_copyright_1_1.html - -function A = allcombs(varargin) - -% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange -% modified so it can take a scalar (or vector) as the first input - -% modified part1 -if numel(varargin{1})==1 - varargin{1} = [varargin{1} NaN]; -end - -% simplified version of allcomb function -q = ~cellfun('isempty',varargin); -ni = sum(q) ; -ii = ni:-1:1 ; -if ni==0, - A = [] ; -else - args = varargin(q) ; - - if ni==1, - A = args{1}(:) ; - else - % flip using ii if last column is changing fastest - [A{ii}] = ndgrid(args{ii}) ; - % concatenate - A = reshape(cat(ni+1,A{:}),[],ni) ; - end -end -% end of allcomb function - -% modified part2 -A(isnan(A(:,1)),:) = []; diff --git a/Protocols/MovingGrid/allcombs.m b/Protocols/MovingGrid/allcombs.m deleted file mode 100644 index 71ef394..0000000 --- a/Protocols/MovingGrid/allcombs.m +++ /dev/null @@ -1,37 +0,0 @@ -% Copyright (c) 2012 Howard Hughes Medical Institute. -% All rights reserved. -% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. -% http://license.janelia.org/license/jfrc_copyright_1_1.html - -function A = allcombs(varargin) - -% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange -% modified so it can take a scalar (or vector) as the first input - -% modified part1 -if numel(varargin{1})==1 - varargin{1} = [varargin{1} NaN]; -end - -% simplified version of allcomb function -q = ~cellfun('isempty',varargin); -ni = sum(q) ; -ii = ni:-1:1 ; -if ni==0, - A = [] ; -else - args = varargin(q) ; - - if ni==1, - A = args{1}(:) ; - else - % flip using ii if last column is changing fastest - [A{ii}] = ndgrid(args{ii}) ; - % concatenate - A = reshape(cat(ni+1,A{:}),[],ni) ; - end -end -% end of allcomb function - -% modified part2 -A(isnan(A(:,1)),:) = []; diff --git a/Protocols/MovingObjects/allcombs.m b/Protocols/MovingObjects/allcombs.m deleted file mode 100644 index 71ef394..0000000 --- a/Protocols/MovingObjects/allcombs.m +++ /dev/null @@ -1,37 +0,0 @@ -% Copyright (c) 2012 Howard Hughes Medical Institute. -% All rights reserved. -% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. -% http://license.janelia.org/license/jfrc_copyright_1_1.html - -function A = allcombs(varargin) - -% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange -% modified so it can take a scalar (or vector) as the first input - -% modified part1 -if numel(varargin{1})==1 - varargin{1} = [varargin{1} NaN]; -end - -% simplified version of allcomb function -q = ~cellfun('isempty',varargin); -ni = sum(q) ; -ii = ni:-1:1 ; -if ni==0, - A = [] ; -else - args = varargin(q) ; - - if ni==1, - A = args{1}(:) ; - else - % flip using ii if last column is changing fastest - [A{ii}] = ndgrid(args{ii}) ; - % concatenate - A = reshape(cat(ni+1,A{:}),[],ni) ; - end -end -% end of allcomb function - -% modified part2 -A(isnan(A(:,1)),:) = []; diff --git a/Protocols/PowerSpectrum/PowerSpectrum.m b/Protocols/PowerSpectrum/PowerSpectrum.m new file mode 100644 index 0000000..faa17bd --- /dev/null +++ b/Protocols/PowerSpectrum/PowerSpectrum.m @@ -0,0 +1,136 @@ +% Creates a single stimulus composed of mean + flash for Red,Green,Blue LEDs +% Implements SymphonyProtocol +% +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html +% +% Modified by TA 17.9.12 from LED Family to create a single LED pulse +% protocol but also plots the power spectrum of the input +classdef PowerSpectrum < SymphonyProtocol + + properties (Constant) + identifier = 'helsinki.yliopisto.pal' + version = 1 + displayName = 'Power Spectrum' + end + + properties + stimPoints = uint16(100); + prePoints = uint16(1000); + tailPoints = uint16(4000); + stimAmplitude = 0.5; + lightMean = 0.0; + preSynapticHold = -60; + numberOfAverages = uint8(5); + interpulseInterval = 0.6; + continuousRun = false; + LED = {'Red_LED','Green_LED','Blue_LED'}; + end + + properties (Dependent = true, SetAccess = private) % these properties are inherited - i.e., not modifiable + % ampOfLastStep; + end + + methods + + function [stimulus, lightAmplitude] = stimulusForEpoch(obj, ~) % epoch Num is usually required + % Calculate the light amplitude for this epoch. + % phase = single(mod(epochNum - 1, obj.stepsInFamily)); % Frank's clever way to determine which flash in a family to deliver + lightAmplitude = obj.stimAmplitude; % * obj.ampStepScale ^ phase; % Frank's clever way to determine the amplitude of the flash family to deliver + + % Create the stimulus + stimulus = ones(1, obj.prePoints + obj.stimPoints + obj.tailPoints) * obj.lightMean; + stimulus(obj.prePoints + 1:obj.prePoints + obj.stimPoints) = lightAmplitude; + end + + + function stimulus = sampleStimuli(obj) % Return a cell array + % you can only create one stimulus with this protocol TA + stimulus{1} = obj.stimulusForEpoch(); + end + + + function prepareRig(obj) + % Call the base class method to set the DAQ sample rate. + prepareRig@SymphonyProtocol(obj); + + %obj.setDeviceBackground('LED', obj.lightMean, 'V'); + +% if strcmp(obj.rigConfig.multiClampMode('Amplifier_Ch1'), 'IClamp') +% obj.setDeviceBackground('Amplifier_Ch1', double(obj.preSynapticHold) * 1e-12, 'A'); +% else +% obj.setDeviceBackground('Amplifier_Ch1', double(obj.preSynapticHold) * 1e-3, 'V'); +% end + end + + + function prepareRun(obj) + % Call the base class method which clears all figures. + prepareRun@SymphonyProtocol(obj); + + obj.openFigure('Response'); + obj.openFigure('Power Spectrum','GroupByParams', {'lightAmplitude'}); + % obj.openFigure('Mean PS', 'GroupByParams', {'lightAmplitude'}); + % obj.openFigure('PS Response Statistics', 'StatsCallback', @responseStatistics); + end + + + function prepareEpoch(obj) + % Call the base class method which sets up default backgrounds and records responses. + prepareEpoch@SymphonyProtocol(obj); + + [stimulus, lightAmplitude] = obj.stimulusForEpoch(obj.epochNum); + obj.addParameter('lightAmplitude', lightAmplitude); + %obj.addStimulus('LED', 'test-stimulus', stimulus, 'V'); % + obj.setDeviceBackground(obj.LED, obj.lightMean, 'V'); + if strcmp(obj.multiClampMode, 'VClamp') + obj.setDeviceBackground('Amplifier_Ch1', double(obj.preSynapticHold) * 1e-3, 'V'); + else + obj.setDeviceBackground('Amplifier_Ch1', double(obj.preSynapticHold) * 1e-12, 'A'); + end + obj.addStimulus(obj.LED, sprintf('%s stimulus',obj.LED), stimulus, 'V'); % + end + + + function stats = responseStatistics(obj) + r = obj.response(); + + % baseline mean and var + if ~isempty(r) + stats.mean = mean(r(1:obj.prePoints)); + stats.var = var(r(1:obj.prePoints)); + else + stats.mean = 0; + stats.var = 0; + end + end + + + function completeEpoch(obj) + % Call the base class method which updates the figures. + completeEpoch@SymphonyProtocol(obj); + + % Pause for the inter-pulse interval. + pause on + pause(obj.interpulseInterval); + end + + + function keepGoing = continueRun(obj) + % First check the base class method to make sure the user hasn't paused or stopped the protocol. + keepGoing = continueRun@SymphonyProtocol(obj); + + if keepGoing + keepGoing = obj.epochNum < obj.numberOfAverages; + end + end + + +% function amp = get.ampOfLastStep(obj) % The product of the number of steps in family, the first step amplitude, and the 'scale factor' +% amp = obj.baseLightAmplitude * obj.ampStepScale ^ (obj.stepsInFamily - 1); +% end + + end +end \ No newline at end of file diff --git a/Protocols/RFcircleMapping/allcombs.m b/Protocols/RFcircleMapping/allcombs.m deleted file mode 100644 index 71ef394..0000000 --- a/Protocols/RFcircleMapping/allcombs.m +++ /dev/null @@ -1,37 +0,0 @@ -% Copyright (c) 2012 Howard Hughes Medical Institute. -% All rights reserved. -% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. -% http://license.janelia.org/license/jfrc_copyright_1_1.html - -function A = allcombs(varargin) - -% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange -% modified so it can take a scalar (or vector) as the first input - -% modified part1 -if numel(varargin{1})==1 - varargin{1} = [varargin{1} NaN]; -end - -% simplified version of allcomb function -q = ~cellfun('isempty',varargin); -ni = sum(q) ; -ii = ni:-1:1 ; -if ni==0, - A = [] ; -else - args = varargin(q) ; - - if ni==1, - A = args{1}(:) ; - else - % flip using ii if last column is changing fastest - [A{ii}] = ndgrid(args{ii}) ; - % concatenate - A = reshape(cat(ni+1,A{:}),[],ni) ; - end -end -% end of allcomb function - -% modified part2 -A(isnan(A(:,1)),:) = []; diff --git a/Protocols/RFgridMapping/allcombs.m b/Protocols/RFgridMapping/allcombs.m deleted file mode 100644 index 71ef394..0000000 --- a/Protocols/RFgridMapping/allcombs.m +++ /dev/null @@ -1,37 +0,0 @@ -% Copyright (c) 2012 Howard Hughes Medical Institute. -% All rights reserved. -% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. -% http://license.janelia.org/license/jfrc_copyright_1_1.html - -function A = allcombs(varargin) - -% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange -% modified so it can take a scalar (or vector) as the first input - -% modified part1 -if numel(varargin{1})==1 - varargin{1} = [varargin{1} NaN]; -end - -% simplified version of allcomb function -q = ~cellfun('isempty',varargin); -ni = sum(q) ; -ii = ni:-1:1 ; -if ni==0, - A = [] ; -else - args = varargin(q) ; - - if ni==1, - A = args{1}(:) ; - else - % flip using ii if last column is changing fastest - [A{ii}] = ndgrid(args{ii}) ; - % concatenate - A = reshape(cat(ni+1,A{:}),[],ni) ; - end -end -% end of allcomb function - -% modified part2 -A(isnan(A(:,1)),:) = []; diff --git a/Protocols/Circle/Circle.m b/Protocols_extra/Circle/Circle.m similarity index 100% rename from Protocols/Circle/Circle.m rename to Protocols_extra/Circle/Circle.m diff --git a/Protocols/Circle/allcombs.m b/Protocols_extra/Circle/allcombs.m similarity index 96% rename from Protocols/Circle/allcombs.m rename to Protocols_extra/Circle/allcombs.m index 71ef394..6bbe699 100644 --- a/Protocols/Circle/allcombs.m +++ b/Protocols_extra/Circle/allcombs.m @@ -1,37 +1,37 @@ -% Copyright (c) 2012 Howard Hughes Medical Institute. -% All rights reserved. -% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. -% http://license.janelia.org/license/jfrc_copyright_1_1.html - -function A = allcombs(varargin) - -% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange -% modified so it can take a scalar (or vector) as the first input - -% modified part1 -if numel(varargin{1})==1 - varargin{1} = [varargin{1} NaN]; -end - -% simplified version of allcomb function -q = ~cellfun('isempty',varargin); -ni = sum(q) ; -ii = ni:-1:1 ; -if ni==0, - A = [] ; -else - args = varargin(q) ; - - if ni==1, - A = args{1}(:) ; - else - % flip using ii if last column is changing fastest - [A{ii}] = ndgrid(args{ii}) ; - % concatenate - A = reshape(cat(ni+1,A{:}),[],ni) ; - end -end -% end of allcomb function - -% modified part2 -A(isnan(A(:,1)),:) = []; +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html + +function A = allcombs(varargin) + +% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange +% modified so it can take a scalar (or vector) as the first input + +% modified part1 +if numel(varargin{1})==1 + varargin{1} = [varargin{1} NaN]; +end + +% simplified version of allcomb function +q = ~cellfun('isempty',varargin); +ni = sum(q) ; +ii = ni:-1:1 ; +if ni==0, + A = [] ; +else + args = varargin(q) ; + + if ni==1, + A = args{1}(:) ; + else + % flip using ii if last column is changing fastest + [A{ii}] = ndgrid(args{ii}) ; + % concatenate + A = reshape(cat(ni+1,A{:}),[],ni) ; + end +end +% end of allcomb function + +% modified part2 +A(isnan(A(:,1)),:) = []; diff --git a/Protocols/DS_V1/DS_V1.m b/Protocols_extra/DS_V1/DS_V1.m similarity index 100% rename from Protocols/DS_V1/DS_V1.m rename to Protocols_extra/DS_V1/DS_V1.m diff --git a/Protocols/DS_V1/allcombs.m b/Protocols_extra/DS_V1/allcombs.m similarity index 96% rename from Protocols/DS_V1/allcombs.m rename to Protocols_extra/DS_V1/allcombs.m index 71ef394..6bbe699 100644 --- a/Protocols/DS_V1/allcombs.m +++ b/Protocols_extra/DS_V1/allcombs.m @@ -1,37 +1,37 @@ -% Copyright (c) 2012 Howard Hughes Medical Institute. -% All rights reserved. -% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. -% http://license.janelia.org/license/jfrc_copyright_1_1.html - -function A = allcombs(varargin) - -% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange -% modified so it can take a scalar (or vector) as the first input - -% modified part1 -if numel(varargin{1})==1 - varargin{1} = [varargin{1} NaN]; -end - -% simplified version of allcomb function -q = ~cellfun('isempty',varargin); -ni = sum(q) ; -ii = ni:-1:1 ; -if ni==0, - A = [] ; -else - args = varargin(q) ; - - if ni==1, - A = args{1}(:) ; - else - % flip using ii if last column is changing fastest - [A{ii}] = ndgrid(args{ii}) ; - % concatenate - A = reshape(cat(ni+1,A{:}),[],ni) ; - end -end -% end of allcomb function - -% modified part2 -A(isnan(A(:,1)),:) = []; +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html + +function A = allcombs(varargin) + +% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange +% modified so it can take a scalar (or vector) as the first input + +% modified part1 +if numel(varargin{1})==1 + varargin{1} = [varargin{1} NaN]; +end + +% simplified version of allcomb function +q = ~cellfun('isempty',varargin); +ni = sum(q) ; +ii = ni:-1:1 ; +if ni==0, + A = [] ; +else + args = varargin(q) ; + + if ni==1, + A = args{1}(:) ; + else + % flip using ii if last column is changing fastest + [A{ii}] = ndgrid(args{ii}) ; + % concatenate + A = reshape(cat(ni+1,A{:}),[],ni) ; + end +end +% end of allcomb function + +% modified part2 +A(isnan(A(:,1)),:) = []; diff --git a/Protocols/DS_V2/DS_V2.m b/Protocols_extra/DS_V2/DS_V2.m similarity index 100% rename from Protocols/DS_V2/DS_V2.m rename to Protocols_extra/DS_V2/DS_V2.m diff --git a/Protocols/DS_V2/allcombs.m b/Protocols_extra/DS_V2/allcombs.m similarity index 96% rename from Protocols/DS_V2/allcombs.m rename to Protocols_extra/DS_V2/allcombs.m index 71ef394..6bbe699 100644 --- a/Protocols/DS_V2/allcombs.m +++ b/Protocols_extra/DS_V2/allcombs.m @@ -1,37 +1,37 @@ -% Copyright (c) 2012 Howard Hughes Medical Institute. -% All rights reserved. -% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. -% http://license.janelia.org/license/jfrc_copyright_1_1.html - -function A = allcombs(varargin) - -% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange -% modified so it can take a scalar (or vector) as the first input - -% modified part1 -if numel(varargin{1})==1 - varargin{1} = [varargin{1} NaN]; -end - -% simplified version of allcomb function -q = ~cellfun('isempty',varargin); -ni = sum(q) ; -ii = ni:-1:1 ; -if ni==0, - A = [] ; -else - args = varargin(q) ; - - if ni==1, - A = args{1}(:) ; - else - % flip using ii if last column is changing fastest - [A{ii}] = ndgrid(args{ii}) ; - % concatenate - A = reshape(cat(ni+1,A{:}),[],ni) ; - end -end -% end of allcomb function - -% modified part2 -A(isnan(A(:,1)),:) = []; +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html + +function A = allcombs(varargin) + +% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange +% modified so it can take a scalar (or vector) as the first input + +% modified part1 +if numel(varargin{1})==1 + varargin{1} = [varargin{1} NaN]; +end + +% simplified version of allcomb function +q = ~cellfun('isempty',varargin); +ni = sum(q) ; +ii = ni:-1:1 ; +if ni==0, + A = [] ; +else + args = varargin(q) ; + + if ni==1, + A = args{1}(:) ; + else + % flip using ii if last column is changing fastest + [A{ii}] = ndgrid(args{ii}) ; + % concatenate + A = reshape(cat(ni+1,A{:}),[],ni) ; + end +end +% end of allcomb function + +% modified part2 +A(isnan(A(:,1)),:) = []; diff --git a/Protocols/ExpandingObjects/ExpandingObjects.m b/Protocols_extra/ExpandingObjects/ExpandingObjects.m similarity index 100% rename from Protocols/ExpandingObjects/ExpandingObjects.m rename to Protocols_extra/ExpandingObjects/ExpandingObjects.m diff --git a/Protocols/ExpandingObjects/allcombs.m b/Protocols_extra/ExpandingObjects/allcombs.m similarity index 96% rename from Protocols/ExpandingObjects/allcombs.m rename to Protocols_extra/ExpandingObjects/allcombs.m index 71ef394..6bbe699 100644 --- a/Protocols/ExpandingObjects/allcombs.m +++ b/Protocols_extra/ExpandingObjects/allcombs.m @@ -1,37 +1,37 @@ -% Copyright (c) 2012 Howard Hughes Medical Institute. -% All rights reserved. -% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. -% http://license.janelia.org/license/jfrc_copyright_1_1.html - -function A = allcombs(varargin) - -% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange -% modified so it can take a scalar (or vector) as the first input - -% modified part1 -if numel(varargin{1})==1 - varargin{1} = [varargin{1} NaN]; -end - -% simplified version of allcomb function -q = ~cellfun('isempty',varargin); -ni = sum(q) ; -ii = ni:-1:1 ; -if ni==0, - A = [] ; -else - args = varargin(q) ; - - if ni==1, - A = args{1}(:) ; - else - % flip using ii if last column is changing fastest - [A{ii}] = ndgrid(args{ii}) ; - % concatenate - A = reshape(cat(ni+1,A{:}),[],ni) ; - end -end -% end of allcomb function - -% modified part2 -A(isnan(A(:,1)),:) = []; +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html + +function A = allcombs(varargin) + +% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange +% modified so it can take a scalar (or vector) as the first input + +% modified part1 +if numel(varargin{1})==1 + varargin{1} = [varargin{1} NaN]; +end + +% simplified version of allcomb function +q = ~cellfun('isempty',varargin); +ni = sum(q) ; +ii = ni:-1:1 ; +if ni==0, + A = [] ; +else + args = varargin(q) ; + + if ni==1, + A = args{1}(:) ; + else + % flip using ii if last column is changing fastest + [A{ii}] = ndgrid(args{ii}) ; + % concatenate + A = reshape(cat(ni+1,A{:}),[],ni) ; + end +end +% end of allcomb function + +% modified part2 +A(isnan(A(:,1)),:) = []; diff --git a/Protocols/Grid/Grid.m b/Protocols_extra/Grid/Grid.m similarity index 100% rename from Protocols/Grid/Grid.m rename to Protocols_extra/Grid/Grid.m diff --git a/Protocols_extra/Grid/allcombs.m b/Protocols_extra/Grid/allcombs.m new file mode 100644 index 0000000..6bbe699 --- /dev/null +++ b/Protocols_extra/Grid/allcombs.m @@ -0,0 +1,37 @@ +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html + +function A = allcombs(varargin) + +% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange +% modified so it can take a scalar (or vector) as the first input + +% modified part1 +if numel(varargin{1})==1 + varargin{1} = [varargin{1} NaN]; +end + +% simplified version of allcomb function +q = ~cellfun('isempty',varargin); +ni = sum(q) ; +ii = ni:-1:1 ; +if ni==0, + A = [] ; +else + args = varargin(q) ; + + if ni==1, + A = args{1}(:) ; + else + % flip using ii if last column is changing fastest + [A{ii}] = ndgrid(args{ii}) ; + % concatenate + A = reshape(cat(ni+1,A{:}),[],ni) ; + end +end +% end of allcomb function + +% modified part2 +A(isnan(A(:,1)),:) = []; diff --git a/Protocols/Grid/calcEllipse.m b/Protocols_extra/Grid/calcEllipse.m similarity index 98% rename from Protocols/Grid/calcEllipse.m rename to Protocols_extra/Grid/calcEllipse.m index e424251..a971c94 100644 --- a/Protocols/Grid/calcEllipse.m +++ b/Protocols_extra/Grid/calcEllipse.m @@ -1,9 +1,9 @@ -% Copyright (c) 2012 Howard Hughes Medical Institute. -% All rights reserved. -% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. -% http://license.janelia.org/license/jfrc_copyright_1_1.html - -function [X Y] = calcEllipse(x,y,a,b,angle) -% calculate points for plotting ellipse -X=x+(a*cosd(0:360)*cosd(angle)-b*sind(0:360)*sind(angle)); +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html + +function [X Y] = calcEllipse(x,y,a,b,angle) +% calculate points for plotting ellipse +X=x+(a*cosd(0:360)*cosd(angle)-b*sind(0:360)*sind(angle)); Y=y+(a*cosd(0:360)*sind(angle)+b*sind(0:360)*cosd(angle)); \ No newline at end of file diff --git a/Protocols/Grid/gauss2Dfit.m b/Protocols_extra/Grid/gauss2Dfit.m similarity index 98% rename from Protocols/Grid/gauss2Dfit.m rename to Protocols_extra/Grid/gauss2Dfit.m index 94bbeca..32f910a 100644 --- a/Protocols/Grid/gauss2Dfit.m +++ b/Protocols_extra/Grid/gauss2Dfit.m @@ -1,44 +1,44 @@ -% Copyright (c) 2012 Howard Hughes Medical Institute. -% All rights reserved. -% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. -% http://license.janelia.org/license/jfrc_copyright_1_1.html - -function [RFstring muX muY sigmaX sigmaY rotationAngle]=gauss2Dfit(Xcoords,Ycoords,meanResp) -x=Xcoords(1):-1:Xcoords(end); -y=Ycoords(1):Ycoords(end); -meanRespIntp=interp2(Xcoords,Ycoords,meanResp,x,y','linear'); -errorFunc=@(p) sum((meanRespIntp(:)-gauss2D(p,x,y)).^2); -peakResp=max(meanRespIntp(:)); -[peakYindex peakXindex]=find(meanRespIntp==peakResp); -peakX=x(round(mean(peakXindex))); -peakY=y(round(mean(peakYindex))); -halfPeakDiff=abs(meanRespIntp-0.6*peakResp); -[halfPeakDistYindex halfPeakDistXindex]=find(halfPeakDiff==min(halfPeakDiff(:))); -halfPeakDistX=abs(peakX-x(round(mean(halfPeakDistXindex)))); -halfPeakDistY=abs(peakY-y(round(mean(halfPeakDistYindex)))); -seedValues=[peakResp*2*pi*halfPeakDistX*halfPeakDistY,peakX,peakY,halfPeakDistX,halfPeakDistY,0]; -fitParams=fminsearch(errorFunc,seedValues,optimset('MaxFunEvals',1e5,'MaxIter',1e5)); -fitR=corrcoef(meanResp,gauss2D(fitParams,Xcoords,Ycoords)); -fitRsq=round((fitR(1,2)^2)*100)/100; -roundFitParams=round(fitParams*10)/10; -RFstring=['RF: center [' num2str(roundFitParams(2)) ',' num2str(roundFitParams(3)) '], sd [' num2str(roundFitParams(4)) ',' num2str(roundFitParams(5)) '], rotation ' num2str(roundFitParams(6)) ' deg, fit r sq = ' num2str(fitRsq)]; -rotationAngle=roundFitParams(6); -% convert mu and sigma from degrees to image pixel coordinates -pixPerDeg=(numel(Ycoords)-1)/(Ycoords(end)-Ycoords(1)); -muX=pixPerDeg*(x(1)-fitParams(2))+1; -muY=pixPerDeg*(y(end)-fitParams(3))+1; -sigmaX=fitParams(4)*pixPerDeg; -sigmaY=fitParams(5)*pixPerDeg; - - -function z=gauss2D(p,x,y) -coords=allcombs(x,y); -% p(1:6)=[V,muX,muY,sigmaX,sigmaY,theta] -% 2D gauss with rotation, http://en.wikipedia.org/wiki/Gaussian_function -z = (p(1)/(2*pi*p(4)*p(5)))*exp(-(... - ((cosd(p(6))^2)/(2*p(4)^2)+(sind(p(6))^2)/(2*p(5)^2))*((coords(:,1)-p(2)).^2) +... - 2*((sind(2*p(6)))/(4*p(4)^2)+(sind(2*p(6)))/(4*p(5)^2))*(coords(:,1)-p(2)).*(coords(:,2)-p(3)) +... - ((sind(p(6))^2)/(2*p(4)^2)+(cosd(p(6))^2)/(2*p(5)^2))*((coords(:,2)-p(3)).^2)... - )); -% 2D gauss without rotation -% z=(p(1)/(2*pi*p(4)*p(5)))*exp(-((((coords(:,1)-p(2)).^2)/(2*p(4)^2))+(((coords(:,2)-p(3)).^2)/(2*p(5)^2)))); +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html + +function [RFstring muX muY sigmaX sigmaY rotationAngle]=gauss2Dfit(Xcoords,Ycoords,meanResp) +x=Xcoords(1):-1:Xcoords(end); +y=Ycoords(1):Ycoords(end); +meanRespIntp=interp2(Xcoords,Ycoords,meanResp,x,y','linear'); +errorFunc=@(p) sum((meanRespIntp(:)-gauss2D(p,x,y)).^2); +peakResp=max(meanRespIntp(:)); +[peakYindex peakXindex]=find(meanRespIntp==peakResp); +peakX=x(round(mean(peakXindex))); +peakY=y(round(mean(peakYindex))); +halfPeakDiff=abs(meanRespIntp-0.6*peakResp); +[halfPeakDistYindex halfPeakDistXindex]=find(halfPeakDiff==min(halfPeakDiff(:))); +halfPeakDistX=abs(peakX-x(round(mean(halfPeakDistXindex)))); +halfPeakDistY=abs(peakY-y(round(mean(halfPeakDistYindex)))); +seedValues=[peakResp*2*pi*halfPeakDistX*halfPeakDistY,peakX,peakY,halfPeakDistX,halfPeakDistY,0]; +fitParams=fminsearch(errorFunc,seedValues,optimset('MaxFunEvals',1e5,'MaxIter',1e5)); +fitR=corrcoef(meanResp,gauss2D(fitParams,Xcoords,Ycoords)); +fitRsq=round((fitR(1,2)^2)*100)/100; +roundFitParams=round(fitParams*10)/10; +RFstring=['RF: center [' num2str(roundFitParams(2)) ',' num2str(roundFitParams(3)) '], sd [' num2str(roundFitParams(4)) ',' num2str(roundFitParams(5)) '], rotation ' num2str(roundFitParams(6)) ' deg, fit r sq = ' num2str(fitRsq)]; +rotationAngle=roundFitParams(6); +% convert mu and sigma from degrees to image pixel coordinates +pixPerDeg=(numel(Ycoords)-1)/(Ycoords(end)-Ycoords(1)); +muX=pixPerDeg*(x(1)-fitParams(2))+1; +muY=pixPerDeg*(y(end)-fitParams(3))+1; +sigmaX=fitParams(4)*pixPerDeg; +sigmaY=fitParams(5)*pixPerDeg; + + +function z=gauss2D(p,x,y) +coords=allcombs(x,y); +% p(1:6)=[V,muX,muY,sigmaX,sigmaY,theta] +% 2D gauss with rotation, http://en.wikipedia.org/wiki/Gaussian_function +z = (p(1)/(2*pi*p(4)*p(5)))*exp(-(... + ((cosd(p(6))^2)/(2*p(4)^2)+(sind(p(6))^2)/(2*p(5)^2))*((coords(:,1)-p(2)).^2) +... + 2*((sind(2*p(6)))/(4*p(4)^2)+(sind(2*p(6)))/(4*p(5)^2))*(coords(:,1)-p(2)).*(coords(:,2)-p(3)) +... + ((sind(p(6))^2)/(2*p(4)^2)+(cosd(p(6))^2)/(2*p(5)^2))*((coords(:,2)-p(3)).^2)... + )); +% 2D gauss without rotation +% z=(p(1)/(2*pi*p(4)*p(5)))*exp(-((((coords(:,1)-p(2)).^2)/(2*p(4)^2))+(((coords(:,2)-p(3)).^2)/(2*p(5)^2)))); diff --git a/Protocols/HotspotsDS/HotspotsDS.m b/Protocols_extra/HotspotsDS/HotspotsDS.m old mode 100755 new mode 100644 similarity index 100% rename from Protocols/HotspotsDS/HotspotsDS.m rename to Protocols_extra/HotspotsDS/HotspotsDS.m diff --git a/Protocols_extra/HotspotsDS/allcombs.m b/Protocols_extra/HotspotsDS/allcombs.m new file mode 100644 index 0000000..6bbe699 --- /dev/null +++ b/Protocols_extra/HotspotsDS/allcombs.m @@ -0,0 +1,37 @@ +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html + +function A = allcombs(varargin) + +% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange +% modified so it can take a scalar (or vector) as the first input + +% modified part1 +if numel(varargin{1})==1 + varargin{1} = [varargin{1} NaN]; +end + +% simplified version of allcomb function +q = ~cellfun('isempty',varargin); +ni = sum(q) ; +ii = ni:-1:1 ; +if ni==0, + A = [] ; +else + args = varargin(q) ; + + if ni==1, + A = args{1}(:) ; + else + % flip using ii if last column is changing fastest + [A{ii}] = ndgrid(args{ii}) ; + % concatenate + A = reshape(cat(ni+1,A{:}),[],ni) ; + end +end +% end of allcomb function + +% modified part2 +A(isnan(A(:,1)),:) = []; diff --git a/Protocols/LEDpulse/LEDpulse.m b/Protocols_extra/LEDpulse/LEDpulse.m similarity index 100% rename from Protocols/LEDpulse/LEDpulse.m rename to Protocols_extra/LEDpulse/LEDpulse.m diff --git a/Protocols/LoomingObjects/LoomingObjects.m b/Protocols_extra/LoomingObjects/LoomingObjects.m similarity index 100% rename from Protocols/LoomingObjects/LoomingObjects.m rename to Protocols_extra/LoomingObjects/LoomingObjects.m diff --git a/Protocols_extra/LoomingObjects/allcombs.m b/Protocols_extra/LoomingObjects/allcombs.m new file mode 100644 index 0000000..6bbe699 --- /dev/null +++ b/Protocols_extra/LoomingObjects/allcombs.m @@ -0,0 +1,37 @@ +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html + +function A = allcombs(varargin) + +% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange +% modified so it can take a scalar (or vector) as the first input + +% modified part1 +if numel(varargin{1})==1 + varargin{1} = [varargin{1} NaN]; +end + +% simplified version of allcomb function +q = ~cellfun('isempty',varargin); +ni = sum(q) ; +ii = ni:-1:1 ; +if ni==0, + A = [] ; +else + args = varargin(q) ; + + if ni==1, + A = args{1}(:) ; + else + % flip using ii if last column is changing fastest + [A{ii}] = ndgrid(args{ii}) ; + % concatenate + A = reshape(cat(ni+1,A{:}),[],ni) ; + end +end +% end of allcomb function + +% modified part2 +A(isnan(A(:,1)),:) = []; diff --git a/Protocols/MovingBar/MovingBar.m b/Protocols_extra/MovingBar/MovingBar.m similarity index 100% rename from Protocols/MovingBar/MovingBar.m rename to Protocols_extra/MovingBar/MovingBar.m diff --git a/Protocols_extra/MovingBar/allcombs.m b/Protocols_extra/MovingBar/allcombs.m new file mode 100644 index 0000000..6bbe699 --- /dev/null +++ b/Protocols_extra/MovingBar/allcombs.m @@ -0,0 +1,37 @@ +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html + +function A = allcombs(varargin) + +% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange +% modified so it can take a scalar (or vector) as the first input + +% modified part1 +if numel(varargin{1})==1 + varargin{1} = [varargin{1} NaN]; +end + +% simplified version of allcomb function +q = ~cellfun('isempty',varargin); +ni = sum(q) ; +ii = ni:-1:1 ; +if ni==0, + A = [] ; +else + args = varargin(q) ; + + if ni==1, + A = args{1}(:) ; + else + % flip using ii if last column is changing fastest + [A{ii}] = ndgrid(args{ii}) ; + % concatenate + A = reshape(cat(ni+1,A{:}),[],ni) ; + end +end +% end of allcomb function + +% modified part2 +A(isnan(A(:,1)),:) = []; diff --git a/Protocols/MovingGrid/MovingGrid.m b/Protocols_extra/MovingGrid/MovingGrid.m similarity index 100% rename from Protocols/MovingGrid/MovingGrid.m rename to Protocols_extra/MovingGrid/MovingGrid.m diff --git a/Protocols_extra/MovingGrid/allcombs.m b/Protocols_extra/MovingGrid/allcombs.m new file mode 100644 index 0000000..6bbe699 --- /dev/null +++ b/Protocols_extra/MovingGrid/allcombs.m @@ -0,0 +1,37 @@ +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html + +function A = allcombs(varargin) + +% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange +% modified so it can take a scalar (or vector) as the first input + +% modified part1 +if numel(varargin{1})==1 + varargin{1} = [varargin{1} NaN]; +end + +% simplified version of allcomb function +q = ~cellfun('isempty',varargin); +ni = sum(q) ; +ii = ni:-1:1 ; +if ni==0, + A = [] ; +else + args = varargin(q) ; + + if ni==1, + A = args{1}(:) ; + else + % flip using ii if last column is changing fastest + [A{ii}] = ndgrid(args{ii}) ; + % concatenate + A = reshape(cat(ni+1,A{:}),[],ni) ; + end +end +% end of allcomb function + +% modified part2 +A(isnan(A(:,1)),:) = []; diff --git a/Protocols/MovingObjects/MovingObjects.m b/Protocols_extra/MovingObjects/MovingObjects.m similarity index 100% rename from Protocols/MovingObjects/MovingObjects.m rename to Protocols_extra/MovingObjects/MovingObjects.m diff --git a/Protocols_extra/MovingObjects/allcombs.m b/Protocols_extra/MovingObjects/allcombs.m new file mode 100644 index 0000000..6bbe699 --- /dev/null +++ b/Protocols_extra/MovingObjects/allcombs.m @@ -0,0 +1,37 @@ +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html + +function A = allcombs(varargin) + +% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange +% modified so it can take a scalar (or vector) as the first input + +% modified part1 +if numel(varargin{1})==1 + varargin{1} = [varargin{1} NaN]; +end + +% simplified version of allcomb function +q = ~cellfun('isempty',varargin); +ni = sum(q) ; +ii = ni:-1:1 ; +if ni==0, + A = [] ; +else + args = varargin(q) ; + + if ni==1, + A = args{1}(:) ; + else + % flip using ii if last column is changing fastest + [A{ii}] = ndgrid(args{ii}) ; + % concatenate + A = reshape(cat(ni+1,A{:}),[],ni) ; + end +end +% end of allcomb function + +% modified part2 +A(isnan(A(:,1)),:) = []; diff --git a/Protocols/MovingObjectsProtocol/MovingObjectsProtocol.m b/Protocols_extra/MovingObjectsProtocol/MovingObjectsProtocol.m similarity index 100% rename from Protocols/MovingObjectsProtocol/MovingObjectsProtocol.m rename to Protocols_extra/MovingObjectsProtocol/MovingObjectsProtocol.m diff --git a/Protocols/RFcircleMapping/RFcircleMapping.m b/Protocols_extra/RFcircleMapping/RFcircleMapping.m similarity index 100% rename from Protocols/RFcircleMapping/RFcircleMapping.m rename to Protocols_extra/RFcircleMapping/RFcircleMapping.m diff --git a/Protocols_extra/RFcircleMapping/allcombs.m b/Protocols_extra/RFcircleMapping/allcombs.m new file mode 100644 index 0000000..6bbe699 --- /dev/null +++ b/Protocols_extra/RFcircleMapping/allcombs.m @@ -0,0 +1,37 @@ +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html + +function A = allcombs(varargin) + +% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange +% modified so it can take a scalar (or vector) as the first input + +% modified part1 +if numel(varargin{1})==1 + varargin{1} = [varargin{1} NaN]; +end + +% simplified version of allcomb function +q = ~cellfun('isempty',varargin); +ni = sum(q) ; +ii = ni:-1:1 ; +if ni==0, + A = [] ; +else + args = varargin(q) ; + + if ni==1, + A = args{1}(:) ; + else + % flip using ii if last column is changing fastest + [A{ii}] = ndgrid(args{ii}) ; + % concatenate + A = reshape(cat(ni+1,A{:}),[],ni) ; + end +end +% end of allcomb function + +% modified part2 +A(isnan(A(:,1)),:) = []; diff --git a/Protocols/RFgridMapping/RFgridMapping.m b/Protocols_extra/RFgridMapping/RFgridMapping.m similarity index 100% rename from Protocols/RFgridMapping/RFgridMapping.m rename to Protocols_extra/RFgridMapping/RFgridMapping.m diff --git a/Protocols_extra/RFgridMapping/allcombs.m b/Protocols_extra/RFgridMapping/allcombs.m new file mode 100644 index 0000000..6bbe699 --- /dev/null +++ b/Protocols_extra/RFgridMapping/allcombs.m @@ -0,0 +1,37 @@ +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html + +function A = allcombs(varargin) + +% simplified version of Jos van der Geest's allcomb.m function from the matlab file exchange +% modified so it can take a scalar (or vector) as the first input + +% modified part1 +if numel(varargin{1})==1 + varargin{1} = [varargin{1} NaN]; +end + +% simplified version of allcomb function +q = ~cellfun('isempty',varargin); +ni = sum(q) ; +ii = ni:-1:1 ; +if ni==0, + A = [] ; +else + args = varargin(q) ; + + if ni==1, + A = args{1}(:) ; + else + % flip using ii if last column is changing fastest + [A{ii}] = ndgrid(args{ii}) ; + % concatenate + A = reshape(cat(ni+1,A{:}),[],ni) ; + end +end +% end of allcomb function + +% modified part2 +A(isnan(A(:,1)),:) = []; diff --git a/Protocols/TempInt/TempInt.m b/Protocols_extra/TempInt/TempInt.m similarity index 100% rename from Protocols/TempInt/TempInt.m rename to Protocols_extra/TempInt/TempInt.m diff --git a/ReadMe.txt b/ReadMe.txt index ae7e1af..63392bc 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -1,5 +1,5 @@ See Overview.txt in the Documentation folder to get started with Symphony. - +Hello Matthew **************************************************************************** The Janelia Farm Research Campus Software Copyright 1.1 diff --git a/Rig Configurations/PALPatchRig.m b/Rig Configurations/PALPatchRig.m new file mode 100644 index 0000000..9fbcfe6 --- /dev/null +++ b/Rig Configurations/PALPatchRig.m @@ -0,0 +1,25 @@ +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html +% +% Modified 27-Aug-2012 TWA to create new Color Rig + +classdef PALPatchRig < RigConfiguration + + properties (Constant) + displayName = 'Retina Electrophysiology' + end + + + methods + + function createDevices(obj) + obj.addMultiClampDevice('Amplifier_Ch1', 1, 'ANALOG_OUT.0', 'ANALOG_IN.0'); + obj.addDevice('Red_LED', 'ANALOG_OUT.1', ''); % output only + obj.addDevice('Green_LED', 'ANALOG_OUT.2', ''); % output only + obj.addDevice('Blue_LED', 'ANALOG_OUT.3', ''); % output only + end + + end +end \ No newline at end of file diff --git a/RigConfiguration.m b/RigConfiguration.m index 07dd46c..8a1489b 100644 --- a/RigConfiguration.m +++ b/RigConfiguration.m @@ -86,7 +86,7 @@ elseif strcmp(answer, 'PCI') hekaID = 1; else % USB - hekaID = 5; + hekaID = double(NativeInterop.ITCMM.USB18_ID); end setpref('Symphony', 'HekaBusID', hekaID); end diff --git a/StartSymphony.m b/StartSymphony.m index 8cca717..90277e3 100644 --- a/StartSymphony.m +++ b/StartSymphony.m @@ -1,31 +1,49 @@ -% Copyright (c) 2012 Howard Hughes Medical Institute. -% All rights reserved. -% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. -% http://license.janelia.org/license/jfrc_copyright_1_1.html - -% Wrapper script (NOT a function) to load the Symphony .NET assemblies correctly. - -if verLessThan('matlab', '7.12') - error('Symphony requires MATLAB 7.12.0 (R2011a) or later'); -end - -% Add our utility and figure handler folders to the search path. -symphonyPath = mfilename('fullpath'); -parentDir = fileparts(symphonyPath); -addpath(fullfile(parentDir, 'Utility')); -addpath(fullfile(parentDir, 'Rig Configurations')); -addpath(fullfile(parentDir, 'Figure Handlers')); -addpath(fullfile(parentDir, 'StimGL')); -clear symphonyPath parentDir - -% Load the Symphony .NET framework -addSymphonyFramework(); - -% Launch the user interface -global symphonyInstance; - -if isempty(symphonyInstance) - symphonyInstance = Symphony(); -else - symphonyInstance.showMainWindow(); -end +% Copyright (c) 2012 Howard Hughes Medical Institute. +% All rights reserved. +% Use is subject to Janelia Farm Research Campus Software Copyright 1.1 license terms. +% http://license.janelia.org/license/jfrc_copyright_1_1.html + +% Wrapper script (NOT a function) to load the Symphony .NET assemblies correctly. + +if verLessThan('matlab', '7.12') + error('Symphony requires MATLAB 7.12.0 (R2011a) or later'); +end + +% Add our utility and figure handler folders to the search path. +symphonyPath = mfilename('fullpath'); +parentDir = fileparts(symphonyPath); +addpath(fullfile(parentDir, 'Utility')); +addpath(fullfile(parentDir, 'Rig Configurations')); +addpath(fullfile(parentDir, 'Figure Handlers')); +addpath(fullfile(parentDir, 'StimGL')); +clear symphonyPath parentDir + +% Load the Symphony .NET framework +%addSymphonyFramework(); + +if isempty(which('NET.convertArray')) + % Use the .NET stub classes instead of the real thing on non-PC platforms. + symphonyPath = mfilename('fullpath'); + parentDir = fileparts(symphonyPath); + addpath(fullfile(parentDir, filesep, 'Stubs')); +else + symphonyPath = 'C:\Program Files\Physion\Symphony\bin'; + + % Add Symphony.Core assemblies + NET.addAssembly(fullfile(symphonyPath, 'Symphony.Core.dll')); + NET.addAssembly(fullfile(symphonyPath, 'Symphony.ExternalDevices.dll')); + NET.addAssembly(fullfile(symphonyPath, 'HekaDAQInterface.dll')); + NET.addAssembly(fullfile(symphonyPath, 'Symphony.SimulationDAQController.dll')); + + NET.addAssembly('System.Windows.Forms'); +end + + +% Launch the user interface +global symphonyInstance; + +if isempty(symphonyInstance) + symphonyInstance = Symphony(); +else + symphonyInstance.showMainWindow(); +end diff --git a/Symphony.m b/Symphony.m index 179996f..67f6505 100644 --- a/Symphony.m +++ b/Symphony.m @@ -998,7 +998,7 @@ function createNewEpochGroup(obj, ~, ~) obj.metadataDoc = com.mathworks.xml.XMLUtils.createDocument('symphony-metadata'); obj.metadataNode = obj.metadataDoc.getDocumentElement(); - + if exist(obj.persistPath, 'file') % Make sure we have the same source UUID's as before. [pathstr, name, ~] = fileparts(obj.persistPath); @@ -1032,9 +1032,12 @@ function createNewEpochGroup(obj, ~, ~) if ismac obj.persistor = EpochXMLPersistor(obj.persistPath); - else - obj.persistor = EpochHDF5Persistor(obj.persistPath, '', 9); + else + obj.persistor = EpochHDF5Persistor(obj.persistPath,System.String(''), 9); end + + obj.saveMetadata(); + end obj.epochGroup = group; @@ -1064,8 +1067,11 @@ function closeEpochGroup(obj, ~, ~) else obj.epochGroup = obj.epochGroup.parentGroup; end + %obj.saveMetadata(); + else obj.persistor.CloseDocument(); + obj.persistor.Dispose(); obj.persistor = []; % Break the reference loop on the group hierarchy so they all get deleted.