Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Calibration Files/**
Data/**
Protocols/**
.gitmodules
*BpodUserPath.txt
*BpodUserPath.txt
*.asv
Binary file removed Calibration Files/SoundCalibration.mat
Binary file not shown.
16 changes: 16 additions & 0 deletions Functions/Plugins/ParameterGUI/BpodParameterGUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@
ThisPanelHeight = ThisPanelHeight + (htable.Position(4)-25);
BpodSystem.GUIHandles.ParameterGUI.Panels.(ThisTabPanelNames{p}).Position(4) = ThisPanelHeight;
BpodSystem.GUIData.ParameterGUI.LastParamValues{ParamNum} = htable.Data;
case 'popupmenutext' % popupmenu, but returns string of menu item rather than its numeric index FS MOD 4/2018
BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 9;
BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'popupmenu', 'String', ThisParamString, 'Value', find(strcmp(ThisParam, ThisParamString)), 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center');
otherwise
error('Invalid parameter style specified. Valid parameters are: ''edit'', ''text'', ''checkbox'', ''popupmenu'', ''togglebutton'', ''pushbutton''');
end
Expand Down Expand Up @@ -244,6 +247,15 @@
elseif Params.GUI.(ThisParamName) ~= ThisParamLastValue
set(ThisParamHandle, 'Value', GUIParam);
end
case 9 % popupmenu text, returns string FS MOD 4/2018
GUIParam = get(ThisParamHandle, 'Value');
GUIParamList = get(ThisParamHandle, 'String');
GUIParamString = GUIParamList{GUIParam};
if GUIParam ~= ThisParamLastValue
Params.GUI.(ThisParamName) = GUIParamString;
elseif find(strcmp(Params.GUI.(ThisParamName), GUIParamList)) ~= ThisParamLastValue
set(ThisParamHandle, 'Value', find(strcmp(Params.GUI.(ThisParamName), GUIParamList)));
end
case 6 %Pushbutton
GUIParam = get(ThisParamHandle, 'Value');
if GUIParam ~= ThisParamLastValue
Expand Down Expand Up @@ -301,6 +313,10 @@
for iColumn = 1:numel(columnNames)
Params.GUI.(ThisParamName).(columnNames{iColumn}) = GUIParam(:,iColumn);
end
case 9 % popupmenu text, returns string FS MOD 4/2018
GUIParam = get(ThisParamHandle, 'Value');
GUIParamList = get(ThisParamHandle, 'String');
Params.GUI.(ThisParamName) = GUIParamList{GUIParam};
end
end
otherwise
Expand Down
19 changes: 15 additions & 4 deletions Functions/Plugins/Plots/TrialTypeOutcomePlot.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,16 @@ function TrialTypeOutcomePlot(AxesHandle, Action, varargin)
end
axes(AxesHandle);
MaxTrialType = max(TrialTypeList);
if isnan(MaxTrialType)


% Fitz mod note- 2 ways to determine trial types on the fly, one is to preallocate
% trial types and outcomes with NaNs and then fill them in as you
% go, second is to build trial type and outcome lists by accretion
if isempty(MaxTrialType) || isnan(MaxTrialType)
MaxTrialType = 1; % for NaN filled TrialTypes, might occur if you determine trial type on the fly
end
%plot in specified axes
Xdata = 1:nTrialsToShow; Ydata = -TrialTypeList(Xdata);
Xdata = 1:min(nTrialsToShow, length(TrialTypeList)); Ydata = -TrialTypeList(Xdata);
BpodSystem.GUIHandles.FutureTrialLine = line([Xdata,Xdata],[Ydata,Ydata],'LineStyle','none','Marker','o','MarkerEdge','b','MarkerFace','b', 'MarkerSize',6);
BpodSystem.GUIHandles.CurrentTrialCircle = line([0,0],[0,0], 'LineStyle','none','Marker','o','MarkerEdge','k','MarkerFace',[1 1 1], 'MarkerSize',6);
BpodSystem.GUIHandles.CurrentTrialCross = line([0,0],[0,0], 'LineStyle','none','Marker','+','MarkerEdge','k','MarkerFace',[1 1 1], 'MarkerSize',6);
Expand All @@ -88,15 +93,21 @@ function TrialTypeOutcomePlot(AxesHandle, Action, varargin)
OutcomeRecord = varargin{3};
MaxTrialType = max(TrialTypeList);
if isnan(MaxTrialType)
MaxTrialType = 1; % for NaN filled TrialTypes, might occur if you determine trial type on the fly
MaxTrialType = 1; % for NaN filled TrialTypes, this if statement shouldn't in practice be reached when using 'update' as opposed to 'init'
end
set(AxesHandle,'YLim',[-MaxTrialType-.5, -.5], 'YTick', -MaxTrialType:1:-1,'YTickLabel', strsplit(num2str(MaxTrialType:-1:-1)));
if CurrentTrial<1
CurrentTrial = 1;
end
TrialTypeList = -TrialTypeList;
% recompute xlim
[mn, mx] = rescaleX(AxesHandle,CurrentTrial,nTrialsToShow);
if length(TrialTypeList) > CurrentTrial % trial types are pre-determined
[mn, mx] = rescaleX(AxesHandle,CurrentTrial,nTrialsToShow);
else % if trial types are not predetermined, have graph end at current trial
mn = max(1, CurrentTrial - nTrialsToShow + 1);
mx = CurrentTrial;
end


%axes(AxesHandle); %cla;
%plot future trials
Expand Down
21 changes: 15 additions & 6 deletions Functions/SoundCalibrator/SoundCalibrationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,20 @@ function SoundCalibrationManager_OpeningFcn(hObject, eventdata, handles, varargi
global BpodSystem
if ispc % Start the MCC board with PsychToolbox
BpodSystem.PluginObjects.USB1608G = struct;
warning off; BpodSystem.PluginObjects.USB1608G.Board = analoginput('mcc', 0); warning on;
BpodSystem.PluginObjects.USB1608G.Board.SampleRate = 200000;
BpodSystem.PluginObjects.USB1608G.Board.SamplesPerTrigger = 200000*.3;
BpodSystem.PluginObjects.USB1608G.Ch0 = addchannel(BpodSystem.PluginObjects.USB1608G.Board, 0);
BpodSystem.PluginObjects.USB1608G.Ch0.InputRange = [-10 10];
% warning off; BpodSystem.PluginObjects.USB1608G.Board = analoginput('mcc', 0); warning on;
warning off; BpodSystem.PluginObjects.USB1608G.Board = daq.createSession('mcc'); warning on;

% BpodSystem.PluginObjects.USB1608G.Board.SampleRate = 200000;
BpodSystem.PluginObjects.USB1608G.Board.Rate = 200000;

%BpodSystem.PluginObjects.USB1608G.Board.SamplesPerTrigger = 200000*.3;

% BpodSystem.PluginObjects.USB1608G.Ch0 = addchannel(BpodSystem.PluginObjects.USB1608G.Board, 0);
BpodSystem.PluginObjects.USB1608G.Ch0 = addAnalogInputChannel(BpodSystem.PluginObjects.USB1608G.Board,'Board0',0,'Voltage');

%BpodSystem.PluginObjects.USB1608G.Ch0.InputRange = [-10 10];
BpodSystem.PluginObjects.USB1608G.Ch0.Range = [-10 10];

end
% Choose default command line output for SoundCalibrationManager
handles.output = hObject;
Expand Down Expand Up @@ -350,4 +359,4 @@ function edit11_CreateFcn(hObject, eventdata, handles)
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
end
13 changes: 7 additions & 6 deletions Functions/SoundCalibrator/TestSoundManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,20 @@ function play_Callback(hObject, eventdata, handles)

CalFilePath = get(handles.filename_edit, 'String');
try
open(CalFilePath); % Creates local variable "SoundCal", a struct with the cal table and coefficients
load(CalFilePath); % Creates local variable "SoundCal", a struct with the cal table and coefficients
catch
error('Could not open calibration file');
end
frequency = str2double(get(handles.frequency_edit, 'String'));
speaker = get(handles.speaker1, 'Value');
if speaker == 0 % Other radio button is selected
speaker = 2;
handles.speaker = get(handles.speaker1, 'Value');
if handles.speaker == 0 % Other radio button is selected
handles.speaker = 2;
end
% Attenuation for this frequency at Target SPL
toneAtt = polyval(SoundCal(1,handles.speaker).Coefficient,frequency);

diffSPL = str2double(handles.volume_edit.String) - SoundCal(1,speaker).TargetSPL;

diffSPL = str2double(handles.volume_edit.String) - SoundCal(1,handles.speaker).TargetSPL;
attFactor = sqrt(10^(diffSPL/10));

amplitude = toneAtt*attFactor;
Expand Down Expand Up @@ -206,4 +207,4 @@ function frequency_edit_Callback(hObject, eventdata, handles)
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of frequency_edit as text
% str2double(get(hObject,'String')) returns contents of frequency_edit as a double
% str2double(get(hObject,'String')) returns contents of frequency_edit as a double
Loading