123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- function [patternedSpot_output]=BC_patternedSpot(loadData,filename,Hz,inputFrames)
- %[patternedSpot_output]=BC_patternedSpot(loadData,filename,Hz,inputFrames)
- %this function shows the analysis for the patterned spot stimulus. The
- %baseline average response per patterned spot stimulus is computed.
- %Inputs:
- % loadData = the folder path of the patterned spot files
- % filename = the filename of the BC of interest
- % Hz = reversing frequency of the patterned spot
- % inputFrames = the starting and ending frame times of the
- % patterned spots from the excel file LogInfo_PatternedSpot.xlsx
- %
- %Outpus: patternedSpot_output = structure containing the output
- % average membrane potential per patterned spot and fourier output
- %
- % code by HS last modiefied March 2021
- %% Constants
- %starting and end frame for the split-spot
- start_halfSpot=inputFrames(1);
- end_halfSpot=inputFrames(2);
- %starting and end frame for the spot divided into 4 quarters
- start_quarterSpot=inputFrames(3);
- end_quarterSpot=inputFrames(4);
- %starting and end frame for the spot with 25micron subfields
- start_25microSpot=inputFrames(5);
- end_25microSpot=inputFrames(6);
- %start and end frame for the spots recorded with version 2 (see excel file)
- if length(inputFrames) > 6
- %for 10 micron subfields
- start_10microSpot=inputFrames(7); end_10microSpot=inputFrames(8);
- %for the uniform spot
- start_UniformSpot=inputFrames(9); end_UniformSpot=inputFrames(10);
- end
- %-------------------------------------------------------------------------------
- %% 1. load the patterned spot file
- data=load([loadData,filename]); %load the file
- %------------------------------------------------------------------------------------------
- %% 2. build average response to split spot
- indx=start_halfSpot; %you start with the splitspot
- basValue=200;%get baseline (200ms) before the stimulus.
- %The index in the excel file gives
- %the start of the 2 trial already, one trial is 1000ms, therefore you
- %have to go 1200ms before the index to get the 200ms beseline
- oneperiod=1000/Hz; %time in ms of one period of the stimulus
- %get the average baselined response to the split spot
- memPotAVG_splitSpot=getAVGResponse(data,basValue,oneperiod,indx);
- %------------------------------------------------------------------------------------------
- %% 3. build average response to quarter spot
- indx=start_quarterSpot; %you start with the spot
- %get the average baselined response to the quarter spot
- memPotAVG_quarterSpot=getAVGResponse(data,basValue,oneperiod,indx);
- %------------------------------------------------------------------------------------------
- %% 4. build average response to 25micron spot
- indx=start_25microSpot; %you start with the spot
- %get the average baselined response to the 25micron spot
- memPotAVG_25microSpot=getAVGResponse(data,basValue,oneperiod,indx);
- %------------------------------------------------------------------------------------------
- %% 5. only for stimulus version 2 build average for 10micron spot and uniform spot
- if length(inputFrames) > 6
- %------------------------------------------------------------------------------------------
- %% 5.1 build average response to 15micron spot
- indx=start_10microSpot; %you start with the spot
- %get the average baselined response to the 10micron spot
- memPotAVG_10microSpot=getAVGResponse(data,basValue,oneperiod,indx);
-
- %------------------------------------------------------------------------------------------
- %% 5.2 build average response to uniform spot
- indx=start_UniformSpot; %you start with the spot
- %get the average baselined response to the uniform spot
- memPotAVG_uniformSpot=getAVGResponse(data,basValue,oneperiod,indx);
-
- else
- %get the response to the uniform spot from the loaded file
- memPotAVG_uniformSpot=data.uniformTraceAVG;
- end
- %------------------------------------------------------------------------------------------
- %% 6. Plot the data
- figure;
- %uniform spot
- subplot(2,2,1)
- %get max and min to set same axis for all the patterned
- %spot
- YLIM=[min([memPotAVG_uniformSpot,memPotAVG_splitSpot,memPotAVG_quarterSpot,memPotAVG_25microSpot])-0.5,...
- max([memPotAVG_uniformSpot,memPotAVG_splitSpot,memPotAVG_quarterSpot,memPotAVG_25microSpot])+0.5];
- plot(memPotAVG_uniformSpot,'k','linewidth',3) %original membrane potential
- title('uniform spot')
- xlabel('time(ms)')
- ylabel('voltage (mV)')
- ylim(YLIM);
- %split spot
- subplot(2,2,2)
- plot(memPotAVG_splitSpot,'k','linewidth',3) %original membrane potential
- title('split spot')
- xlabel('time(ms)')
- ylabel('voltage (mV)')
- ylim(YLIM);
- %1/4 spot
- subplot(2,2,3)
- plot(memPotAVG_quarterSpot,'k','linewidth',3) %original membrane potential
- title('quarter spot')
- xlabel('time(ms)')
- ylabel('voltage (mV)')
- ylim(YLIM);
- %25micron subfield spot
- subplot(2,2,4)
- plot(memPotAVG_25microSpot,'k','linewidth',3) %original membrane potential
- title('25micron subfields spot')
- xlabel('time(ms)')
- ylabel('voltage (mV)')
- ylim(YLIM);
- %-------------------------------------------------------------------------------
- %% 5. add variables into the output
- patternedSpot_output.memPotAVG_uniformSpot=memPotAVG_uniformSpot;
- patternedSpot_output.memPotAVG_splitSpot=memPotAVG_splitSpot;
- patternedSpot_output.memPotAVG_quarterSpot=memPotAVG_quarterSpot;
- patternedSpot_output.memPotAVG_25microSpot=memPotAVG_25microSpot;
- if length(inputFrames) > 6
- patternedSpot_output.memPotAVG_10microSpot=memPotAVG_10microSpot;
- end
- end
- function membPotAVG_trBas=getAVGResponse(data,basValue,oneperiod,indx)
- memPot_basTemp=data.membPot(data.ttls_ms(indx)-oneperiod-basValue: ...
- data.ttls_ms(indx)-oneperiod-1); %baseline 200ms before
- for jj=1:3 %amount of black spot start per size ->only analyse 3!
- membPot_perTrial(jj,:)=data.membPot(data.ttls_ms(indx): ...
- data.ttls_ms(indx)+oneperiod-1); %duration 1000 ms for black and white together
- indx=indx+2;
- end
- memPotAVG= mean(membPot_perTrial);
- membPotAVG_trBas= memPotAVG-mean(memPot_basTemp);
- end
|