labchart in matlab - Autoregressive spectral analysis - biomedical
Show older comments
hai.. i new to matlab.. i'm working with labchart., with the help of instructions given, i export labchart signal to matlab.. now i want to analyse autoregressive spectral estimation for labchart signal.. help me plz.. the following code exports labchart to matlab., i want to insert AR spectral analysis in it.. plz show me the way.. %LABCHART Plots the output of ADInstruments LabChart Export MATLAB % extension 3.0 of LabChart 7.2 or later % This is version 1.1 % For more information visit http://www.adinstruments.com/
clear all, close all
% Load .mat file [fname, pathname] = uigetfile('.mat', 'Select a MAT-file'); if fname==0, return end load([pathname fname])
if ~exist('data','var'), error('No data! Select a mat file that contains data and was created with Export Matlab 3.0 or later (LabChart for Windows 7.2 or later)') return end
[numchannels numblocks] = size(datastart);
%Set up figure, size, position figure(1) clf FigName = ['LabChart - All Channels, all Blocks of ' fname ]; scrsz = get(0,'ScreenSize'); set(gcf,'Name',FigName, 'Position', scrsz([3 4 3 4]).*[1 1 6 6]/8);
% For all channels and all blocks... for ch = 1:numchannels, for bl = 1:numblocks pdata = []; ptime = []; temp2 = [];
if (datastart(ch,bl) ~= -1)%empty blocks excluded
pdata = data(datastart(ch,bl):dataend(ch,bl));
if exist('scaleunits','var')%16-bit data
pdata = (pdata + scaleoffset(ch,bl)).* scaleunits(ch,bl);
end
ptime = [0:size(pdata,2)-1]/samplerate(ch,bl);
subplot(numchannels,numblocks,(ch-1)*numblocks+bl)
plot(ptime,pdata), hold on
% Titles
% shown on first block of each channel. If first block of a
% channel is empty, no title will be shown
if bl == 1
title(titles(ch,:));
end
% Ranges and units
% x-axis: always in seconds
xlabel('Time (s)');
if (length(ptime) ~= 1)%exclude blocks with only one data point
xlim([0 max(ptime)])
end
% y-axis labels / units: always in base units
if (unittextmap(ch,bl) ~= -1)
unit = unittext(unittextmap(ch,bl),:);
ylabel(unit);
end
if exist('scaleunits','var')%16-bit data
pmax = (rangemax(ch,bl) + scaleoffset(ch,bl)) .* scaleunits(ch,bl);
pmin = (rangemin(ch,bl) + scaleoffset(ch,bl)) .* scaleunits(ch,bl);
else
pmax = rangemax(ch,bl);%32-bit data
pmin = rangemin(ch,bl);
end
ylim([pmin pmax]);
if exist('com','var'),
% Comments
% Content of matrix com:
% column 1: comchan (channel comment was made in, can be
% -1 for all ch)
% column 2: comblock (block comment was made in)
% column 3: comtickpos (position of comment referring to
% tickrate of that block)
% column 4: comtype (comment type 1=user, 2=event marker)
% column 5: comtextmap (contains index that refers to
% column vector comtext)
% Find out if there is a comment for this block. There are two types:
% 1. This channel only comments, (com(:,1) == ch)
% 2. Comments across all channels (com(:,1) == -1)
if (isfinite(find(com(:,2) == bl & (com(:,1) == ch | com(:,1) == -1))))
temp = find((com(:,2) == bl & (com(:,1) == ch | com(:,1) ==-1)));
comtickpos = com(:,3);
comtextmap = com(:,5);
for m = 1:size(temp)
temp2 = temp(m);
x = round(comtickpos(temp2)* ... %convert from tick rate position
(samplerate(ch,bl)/tickrate(bl))); %to sample rate position
t = x/samplerate(ch,bl);
plot([t t],[pmin pmax],'r:');
text(t, (pmin + 0.1*(pmax - pmin)),comtext(comtextmap(temp2),:), ...
'Rotation',90);
end
end
end
end
end
end
this code exports signal from labchart to matlab.. how can i insert AR (pyulear()) spectral estimation in this..
Answers (1)
Ina
on 10 Sep 2013
0 votes
Hi there,
the code you have posted here is the standard way of getting *.mat files created by LabChart read into MATLAB. This LabChart.m is supplied with LabChart, available from the Welcome Centre.
Your question is hidden at the very end of your post:
how can i insert AR (pyulear()) spectral estimation in this?
Once you load the *.mat LabChart has created all your x-axis values are contained in the row vector 'data', which you can do further analysis on.
The LabChart Help describes the Standard File Format in detail, in case you want, for example, extract only a certain data block from your recording. The LabChart.m file shows how that's done using the indices in datastart and dataend.
I'd also recommend having a look at LabChart's Spectrum view, you can plot the PSD for your data directly there.
Hope this helps!
Categories
Find more on Spectral Estimation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!