function [uniformSpot_output]=BC_uniformSpot3(loadData,filename,spotDuration,grayDuration,inputFrames,pathStimSignal) %[uniformSpot_output]=BC_uniformSpot3(loadData,filename,spotDuration,grayDuration,contrast) %this function shows the example analysis for the uniform spot stimulus with %different spot sizes for stimulus version 3. Here the black and white spot %are recorded in the same file %Inputs: % loadData = the folder path of the patterned spot files % filename = the filename of the BC of interest % spotDuration = duration of spot in ms, found in % the excel file LogInfo_PatternedSpot.xlsx % grayDuration = duration of gray screen in ms, found in % the excel file LogInfo_PatternedSpot.xlsx % inputFrames = start and end frames of the different % contrast spots, found in the excel file % LogInfo_PatternedSpot.xlsx % pathStimSignal = folder path to load the sequence of spot % sizes shown % % %Outpus: uniformSpot_output = structure containing the output % average membrane potential per spot size of the uniform % spot for both black and white contrast. % % code by HS last modiefied March 2021 %% Constants mircoMeter_proPixel=2.5; %one monitor pixel is 2.5 micrometers %------------------------------------------------------------------------------- %% 1. load the patterned spot file data=load([loadData,filename]); %load the file %------------------------------------------------------------------------------- %% 2. load the spot sizes %same as spot version 2 npatterns=11; %11 spot sizes were shown micro_meter=[2, 6, 8, 10, 12, 16, 24, 32, 50, 100, 200 ]'*2*mircoMeter_proPixel; %for plotting add the mircometer label micrometer_label=repmat(' \mum',size(micro_meter,1),1); micro_meter_withLabel=strcat (num2str(micro_meter),micrometer_label); load(pathStimSignal); %load the order of the presentation of the diameter sizes. See Documentation_Data_BCRecordings. It contains values from 10-1000 and the numbers refer to the spot size in micrometers. The same order was used for black and white spots %------------------------------------------------------------------------------------------ %% 3. extract the membrane potential data for the black spot, for each spot size and build the average %start of black spot start_blackSpot=inputFrames(1); %end of black spot end_blackSpot=inputFrames(2); %only get the frames where the gray screen was shown (that you have one %frame per trial) ttls_ms_forCond=data.ttls_ms(1:2:end_blackSpot); %extract the membrane potential per spot membPot_perTrialBlackSpot=cell(1,npatterns); for j=1:npatterns %loop over spot sizes spot_cond=find(stimulus==micro_meter(j));%get all the spots with same size ttls_forCond=ttls_ms_forCond(spot_cond);%get the ttls signals for this circle size if ~isempty(ttls_forCond) %get the membrane potenial for this ttls signal (start gray screen) and go until %the next spot (grayScreen 1000ms+500msSpot+1000gray) for jj=1:length(ttls_forCond) if length(data.membPot)>=(ttls_forCond(jj)+spotDuration-1+grayDuration*2)==1 %only if you have enought data membPot_perTrialBlackSpot{j}(jj,:)=data.membPot(ttls_forCond(jj): ... (ttls_forCond(jj)+spotDuration-1+2*grayDuration)); %duration-1 -> because the next trial would start there end end end clear spot_cond ttls_forCond end % baseline on trial by trial bases -> substract from the time series of each trial % the mean value of the 200 ms before the spot arrives membPot_trBasMeanBlackSpot=cell(1,npatterns); basValue=-200;%amount of baseline ->200ms for ww=1:length(membPot_perTrialBlackSpot)%nbr of spot sizes val_before=membPot_perTrialBlackSpot{ww}(:,grayDuration+basValue:grayDuration-1); byTrBas_perSpot=(mean(val_before,2)); trBas_repMAt=repmat(byTrBas_perSpot,1, ... size(membPot_perTrialBlackSpot{ww}(:,grayDuration+1:end),2)); %directly take the signal after gray screen membPot_trBasMeanBlackSpot{ww}=mean(membPot_perTrialBlackSpot{ww}(:,grayDuration+1:end)- ... trBas_repMAt,1);%mean for each trial, directly take the signal after gray screen clear trBas_perSpotrepMAt end %------------------------------------------------------------------------------------------ %% 3. extract the membrane potential data for the white spot, for each spot size and build the average %start of black spot start_whiteSpot=inputFrames(3); %end of black spot end_whiteSpot=inputFrames(4); %only get the frames where the gray screen was shown (that you have one %frame per trial) ttls_ms_forCond=data.ttls_ms(start_whiteSpot:2:end_whiteSpot); %extract the membrane potential per spot membPot_perTrialWhiteSpot=cell(1,npatterns); for j=1:npatterns %loop over spot sizes spot_cond=find(stimulus==micro_meter(j));%get all the spots with same size ttls_forCond=ttls_ms_forCond(spot_cond);%get the ttls signals for this circle size if ~isempty(ttls_forCond) %get the membrane potenial for this ttls signal (start gray screen) and go until %the next spot (grayScreen 1000ms+500msSpot+1000gray) for jj=1:length(ttls_forCond) if length(data.membPot)>=(ttls_forCond(jj)+spotDuration-1+grayDuration*2)==1 %only if you have enought data membPot_perTrialWhiteSpot{j}(jj,:)=data.membPot(ttls_forCond(jj): ... (ttls_forCond(jj)+spotDuration-1+2*grayDuration)); %duration-1 -> because the next trial would start there end end end clear spot_cond ttls_forCond end % baseline on trial by trial bases -> substract from the time series of each trial % the mean value of the 200 ms before the spot arrives membPot_trBasMeanWhiteSpot=cell(1,npatterns); basValue=-200;%amount of baseline ->200ms for ww=1:length(membPot_perTrialWhiteSpot)%nbr of spot sizes val_before=membPot_perTrialWhiteSpot{ww}(:,grayDuration+basValue:grayDuration-1); byTrBas_perSpot=(mean(val_before,2)); trBas_repMAt=repmat(byTrBas_perSpot,1, ... size(membPot_perTrialWhiteSpot{ww}(:,grayDuration+1:end),2)); %directly take the signal after gray screen membPot_trBasMeanWhiteSpot{ww}=mean(membPot_perTrialWhiteSpot{ww}(:,grayDuration+1:end)- ... trBas_repMAt,1);%mean for each trial, directly take the signal after gray screen clear trBas_perSpotrepMAt end %------------------------------------------------------------------------------------------ %% 4. Plot the data figure; %black spot subplot(1,2,1) %uniform spot, different sizes If you use earlier MATLAB versions you %might have to choose for each spot size a different color %50um micro50=find(micro_meter==50); plot(membPot_trBasMeanBlackSpot{micro50},'linewidth',3) hold on %80um micro80=find(micro_meter==80); plot(membPot_trBasMeanBlackSpot{micro80},'linewidth',3) %120um micro120=find(micro_meter==120); plot(membPot_trBasMeanBlackSpot{micro120},'linewidth',3) xlabel('time(ms)') ylabel('voltage(mV)') %legend legend({micro_meter_withLabel([micro50,micro80,micro120],:)}) title('black spot') YLIM=ylim; %white spot subplot(1,2,2) %uniform spot, different sizes %50um micro50=find(micro_meter==50); plot(membPot_trBasMeanWhiteSpot{micro50},'linewidth',3) hold on %80um micro80=find(micro_meter==80); plot(membPot_trBasMeanWhiteSpot{micro80},'linewidth',3) %120um micro120=find(micro_meter==120); plot(membPot_trBasMeanWhiteSpot{micro120},'linewidth',3) %legend legend({micro_meter_withLabel([micro50,micro80,micro120],:)}) title('white spot') xlabel('time(ms)') ylabel('voltage(mV)') YLIM2=ylim; %find max of the two ylims and adapt ylims to compare the two plots so that %they have the same ylims minY=min([YLIM,YLIM2])-0.5; maxY=max([YLIM,YLIM2])+0.5; subplot(1,2,1) ylim([minY maxY]) subplot(1,2,2) ylim([minY maxY]) %------------------------------------------------------------------------------- %% 5. add variables into the output uniformSpot_output.membPot_trBasMean=membPot_trBasMeanBlackSpot; uniformSpot_output.membPot_trBasMeanWhiteSpot=membPot_trBasMeanWhiteSpot; uniformSpot_output.micro_meter=micro_meter; end