Browse Source

Dateien hochladen nach 'ABR'

Ella Z. Lattenkamp 3 years ago
parent
commit
edd5d2a13a
4 changed files with 207 additions and 0 deletions
  1. 17 0
      ABR/READ_ME.txt
  2. 139 0
      ABR/abr_data_analysis.m
  3. 51 0
      ABR/abr_data_plot.m
  4. BIN
      ABR/abr_deafening_results.mat

+ 17 - 0
ABR/READ_ME.txt

@@ -0,0 +1,17 @@
+This READ_ME explains the variables in the 'abr_analysis_results.mat' file.
+
+allCONFI
+	structure with 3 matrices
+	frequencies = tested frequencies in kHz
+	levels = tested sound levels in dB
+	confidence results from bootstrap analysis for the corresponding frequency-level combination
+
+date
+	recording dates for the ABR measurements (format JJJJMMDD)
+
+
+resultTHRES
+	The left column gives the measured frequencies and the right column the corresponding
+	sound levels, which show the first >0.95 confidence in the bootstrap analysis (only if all
+	higher sound levels also show >0.95 confidence). Each row represents one Audiogram for one
+	individual (top to bottom: deafened 1-3 and then control 1-3).

+ 139 - 0
ABR/abr_data_analysis.m

@@ -0,0 +1,139 @@
+%% ABR analysis script: this script takes the raw recordings and extracts the results
+% raw recordings are available from last author upon request
+
+%% settings
+fs=19200;                   % sampling rate after 20-fold resampling
+bma200_input_gain=10000;    % value gained during calibration
+abr_scale_factor=1/(7e-5*bma200_input_gain);    % in mV
+nboot=500;                  % number of bootstraps for statistics
+
+% set if you want to save the results  and bootstrap options (1=on, 0=off)
+saveon=0;
+booton=1;
+
+% set abr analysis window
+ana_wind_start=0.001;       % offset of rms calculation window
+ana_wind_dur=0.007;         % duration of rms calculation window
+ana_wind_starts=round(ana_wind_start*fs);
+ana_wind_stops=round((ana_wind_start+ana_wind_dur)*fs);
+
+% define (internal) bat ID, recording date and recording number for analyses
+dates = {'20170207','20170210','20170817','20191204',...
+    '20170213','20170223','20170818','20191204',...
+    '20170217','20170220','20170821','20191205',...
+    '20170203','20170209','20170817','20191204',...
+    '20170208','20170216','20170818','20191203',...
+    '20170306','20170313','20170821','20191205'};
+
+reco = {'3','3','3','2','3','3','8','2','3','5','3','2',...
+        '5','3','7','2','3','3','3','3','3','7','4','2'};
+
+animalname = {'3','3','3','3','5','5','5','5','8','8','8','8',...
+    '2','2','2','2','4','4','4','4','7','7','7','7'};
+
+%% data extraction and bootstrap analysis
+for i=1:24
+    % choose current bat, date, record number
+    batid=char(animalname(i));
+    date=dates(i);
+    recn=reco(i);
+    
+    % location of folder with the raw recordings
+    rootpath=['D:\Documents\Manuskripte\Vocal_development\ABR_recordings\B' batid '\' char(date) '\'];
+    
+    % circumvent naming error of B2 files
+    if batid=='2'
+        recname=['abr_tonepips_ed_b' batid '_m' char(recn) '_'];
+    else
+        recname=['abr_tonepips_vpl_b' batid '_m' char(recn) '_'];
+    end
+    
+    % access the folder with the recordings
+    d=dir(rootpath);
+    filenames=char(d.name);     % read in the names of the files in this folder
+    recnum=0;                   % set recnum to zero
+    for fn=3:size(filenames,1)  % go through all files in this folder
+        filename=deblank(filenames(fn,:));
+        if 1-isempty(strfind(filename,recname))
+            % extract info from filename
+            li=strfind(filename,'_l');
+            fi=strfind(filename,'_fc');
+            xi=strfind(filename,'_');
+            xi=xi(min(find(xi>fi)));
+            if xi>fi+4          % if there is frequency information in the filename
+                xi=max(xi);
+                recnum=recnum+1;
+                lstring=filename(li+2:fi-1);
+                current_level=str2num(lstring);
+                fstring=filename(fi+3:xi-1);
+                current_freq=str2num(fstring);
+                load([rootpath filename]); % load the file to be analysed
+            end
+            
+            mrxin=squeeze(mean(rxin,2)).*abr_scale_factor;
+            levels(recnum)=current_level;
+            freqs(recnum)=current_freq/1e3;
+            rec(recnum,:)=mrxin;
+            
+            %%% BOOTSTRAPPING ANALYSIS STARTS HERE
+            if booton==1
+                data=rxin(ana_wind_starts:ana_wind_stops,:);
+                datalong=reshape(data,numel(data),1);
+                
+                % do a bootstrapping analysis
+                samplesize=size(data,1);
+                indices=1:(length(datalong)-samplesize);
+                samplenumber=size(data,2);
+                originalsignal=mean(data,2);
+                originalrms=std(originalsignal);
+                
+                for bn=1:nboot
+                    for rep=1:size(data,2)
+                        bsdata(:,rep)=circshift(data(:,rep),ceil(rand*size(data,1)));
+                    end
+                    bootrms(bn)=std(mean(bsdata,2));
+                end
+                
+                confidence=numel(find(originalrms>bootrms))/nboot;
+                confidences(recnum)=confidence;
+            end     %%% BOOTSTRAP ANALYSIS ENDS HERE
+        end
+    end
+    
+    % organise data for bootstrap plots
+    all_levels=sort(unique(levels));
+    all_freqs=sort(unique(freqs));
+    out=zeros(length(all_levels),length(all_freqs));
+    for sn=1:length(levels)
+        cl=levels(sn);
+        cf=freqs(sn);
+        li=find(all_levels==cl);
+        fi=find(all_freqs==cf);
+        out(li,fi)=std(rec(sn,ana_wind_starts:ana_wind_stops)); % calculate rms from sample 31 because of rec onset irregularities
+    end
+    in=[freqs' levels' confidences'];
+    sort_in=sortrows(in,[1 2]);
+    ufreqs=unique(freqs);
+    ulevels=unique(levels);
+    
+    for fn=1:length(ufreqs)
+        cfreq=ufreqs(fn);
+        fconf=sort_in(find(sort_in(:,1)==cfreq),3);
+        threshold_ind=max(find(fconf<0.95))+1;
+        if threshold_ind<=length(ulevels) & 1-isempty(threshold_ind)
+            bootstrap_thresholds(fn)=ulevels(threshold_ind);
+        else
+            bootstrap_thresholds(fn)=nan;
+        end
+    end
+    
+    % save results in structures
+    resultTHRES(i)=struct('uniqueFrequencies',ufreqs','bootstrapThresholds',bootstrap_thresholds');
+    allCONFI(i)=struct('frequencies',freqs,'levels',levels,'confidences',confidences);
+    heatRES(i)=struct('all_freqs',all_freqs,'all_levels',all_levels,'out',out);
+end
+
+%% saving of the variables
+if saveon==1
+    save('abr_deafening_results.mat','date','resultTHRES','allCONFI');
+end

+ 51 - 0
ABR/abr_data_plot.m

@@ -0,0 +1,51 @@
+%% This script loads the file "abr_analysis_results.mat" from the same folder and plots the data
+
+% load the data
+%load('abr_deafening_results.mat')
+
+% generate plot titles
+titles={'< 2 weeks of age';'< 3 weeks of age';'6 months of age';'3 years of age'};
+
+% plot bootstrap results and threshold
+figure, 
+
+% for 24 subplots (i.e. 4 measurements per individual)
+for k=1:24
+    subplot(6,4,k),
+    % plot all measurements that have a bootstrap results above 0.95
+    % confidence in green
+    ph=plot(allCONFI(k).frequencies(find(allCONFI(k).confidences>0.95)),allCONFI(k).levels(find(allCONFI(k).confidences>0.95)),'ko');
+    set(ph,'markerfacecolor','g')
+    hold on,
+    % plot all measurements that have a bootstrap results below 0.95
+    % confidence as empty
+    ph=plot(allCONFI(k).frequencies(find(allCONFI(k).confidences<=0.95)),allCONFI(k).levels(find(allCONFI(k).confidences<=0.95)),'ko');
+    % set plot limits
+    set(gca,'xlim',[5 90],'ylim',[40 120],'ytick',[40:40:120],'xscale','log','xtick',[5 10 20 40 90]);
+    hold on,
+    % plot the audiogram threshold line
+    plot(resultTHRES(k).uniqueFrequencies,resultTHRES(k).bootstrapThresholds,'-k','linewidth',2);
+    % set x- and y-axis labels
+    set(gca,'xtick',[5 10 20 50 90])
+    set(gca,'ytick',[40 80 120])
+    % add titles and axis labels to plot
+    if k == 1
+        title(char(titles(k)),'FontSize',13);
+        ylabel({['Deafened 1'] ; 'Level (dB SPL)' },'FontSize',11);
+    elseif k==2 ||k==3|| k==4
+        title(char(titles(k)),'FontSize',13);
+    elseif k == 5
+        ylabel({['Deafened 2'] ; 'Level (dB SPL)' },'FontSize',11);
+    elseif k==9
+        ylabel({['Deafened 3'] ; 'Level (dB SPL)' },'FontSize',11);
+    elseif k==13
+        ylabel({['Hearing 1'] ; 'Level (dB SPL)' },'FontSize',11);
+    elseif k==17
+        ylabel({['Hearing 2'] ; 'Level (dB SPL)' },'FontSize',11);
+    elseif k == 21
+        ylabel({['Hearing 3'] ; 'Level (dB SPL)' },'FontSize',11);
+        xlabel('Frequency (kHz)','FontSize',11)
+    elseif k == 22||k == 23||k == 24
+        xlabel('Frequency (kHz)','FontSize',11)
+    end
+end

BIN
ABR/abr_deafening_results.mat