-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadRETevalOnOff.m
More file actions
36 lines (32 loc) · 1.05 KB
/
Copy pathloadRETevalOnOff.m
File metadata and controls
36 lines (32 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
%% Import RETeval sinusoidal responses from .csv file
% Imports csv data exprted with RFFextractor
% ERG data recorded with Phnr protacol
function [OnOffOD, OnOffOS, filename] = loadRETevalOnOff(filename)
%% Initialize variables.
if ~exist('filename', 'var')
[file,path] = uigetfile('*.csv');
if isequal(file,0)
disp('User selected Cancel');
else
filename = fullfile(path,file);
delimiter = ',';
end
else
delimiter = ',';
end
% For more information, see the TEXTSCAN documentation.
formatSpec = '%*q%*q%f%f%f%f%*s%*s%[^\n\r]';
fileID = fopen(filename,'r');
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'TextType', 'string', 'EmptyValue', NaN, 'HeaderLines', 2, 'ReturnOnError', false, 'EndOfLine', '\r\n');
fclose(fileID);
% Create output variable
OnOff = [dataArray{1:end-1}];
if size(OnOff, 2) > 2
OnOffOD = OnOff(:,1:2);
OnOffOS = OnOff(:,3:4);
else
OnOffOD = OnOff;
OnOffOS= [];
end
%% Clear temporary variables
clearvars delimiter startRow formatSpec fileID dataArray ans file path;