123456789101112131415161718192021222324252627282930313233343536 |
- % The script calculates the Inter Spike Intervals (ISIs) and plots the
- % results in a histogram. The proportion of ISIs violating a threshold
- % is also calculated and indicated in the histogram.
- % authors: Francesco E. Vaccari
- % date: 10/2022
- clear all; clc; close all;
- addpath('supportFunctions')
- currentFolder = pwd;
- parentFolder = fileparts(fileparts(currentFolder));
- [filename,path_folder_data] = uigetfile('*.h5','Select a h5 dataset',[parentFolder '\data']);
- str = '/DATA'; %it can be either unit_XXX, unit_XXX/condition_YY or unit_XXX/condition_YY/trial_ZZ
- threshold = 1; %threshold for violations in ms
- [data, all_strings] = get_all_data_from_level_h5_rec([path_folder_data filename],str, {}, {}); %extract data
- spikes = data(:,2);
- ISIs = cellfun(@diff, spikes, 'UniformOutput', false);
- ISIs = cell2mat(ISIs');
- violations = length(find(ISIs<threshold)) / numel(ISIs) * 100; %percentage over the total number of ISIs
- figure
- time = 0:0.5:100;
- histogram(ISIs,time);
- hold on
- xline(threshold,'--')
- xLimits = get(gca,'XLim');
- yLimits = get(gca,'YLim');
- text(xLimits(2)/4, yLimits(2)*2/3, ['Violations (ISI below ' num2str(threshold) 'ms threshold) = ' num2str(violations) '%'])
- xlabel('ISI duration (ms)')
- ylabel('events num.')
- title('ISI')
|