Cerebral Haemodynamic Autoregulatory Information System GUI 1.0.0
(2,228 bytes)
function [data] = CHARISGUIcollectData(indBot,indTop,column,dirName)
%Collects raw data from lvm files within a certain column
%Move to dir
oldFolder = cd(dirName);
%Count lvm files
lvmFiles = dir('*.lvm');
numfiles = length(lvmFiles);
%Make sure correct column
tempMatrix = importLVMfile(lvmFiles(1).name, 25, 180024);
isOkay=1;
if(isOkay==1)
isOkay = true;
else
isOkay = false;
end
a=length(indBot:indTop);
%Proceed if okay
if(isOkay == true)
data = cell(a,1);
for file = indBot:indTop
tempMatrix = importLVMfile(lvmFiles(file).name, 25, 180024);
data{file}=tempMatrix(:,column);
end
end
%return to original folder
cd(oldFolder);
end
function SICUNI62101405051824 = importLVMfile(filename, startRow, endRow)
%% Initialize variables.
delimiter = '\t';
if nargin<=2
startRow = 25;
endRow = inf;
end
%% Format string for each line of text:
% column1: double (%f)
% column2: double (%f)
% column3: double (%f)
% column4: double (%f)
% column5: double (%f)
% column6: double (%f)
% column7: double (%f)
% column8: double (%f)
% column9: double (%f)
% For more information, see the TEXTSCAN documentation.
formatSpec = '%f%f%f%f%f%f%f%f%f%*s%*s%*s%*s%[^\n\r]';
%% Open the text file.
fileID = fopen(filename,'r');
%% Read columns of data according to format string.
% This call is based on the structure of the file used to generate this
% code. If an error occurs for a different file, try regenerating the code
% from the Import Tool.
dataArray = textscan(fileID, formatSpec, endRow(1)-startRow(1)+1, 'Delimiter', delimiter, 'EmptyValue' ,NaN,'HeaderLines', startRow(1)-1, 'ReturnOnError', false);
for block=2:length(startRow)
frewind(fileID);
dataArrayBlock = textscan(fileID, formatSpec, endRow(block)-startRow(block)+1, 'Delimiter', delimiter, 'EmptyValue' ,NaN,'HeaderLines', startRow(block)-1, 'ReturnOnError', false);
for col=1:length(dataArray)
dataArray{col} = [dataArray{col};dataArrayBlock{col}];
end
end
%% Close the text file.
fclose(fileID);
%% Create output variable
SICUNI62101405051824 = [dataArray{1:end-1}];
end