I need data points from Labchart file according to stimulus time points in a other channel , how can i get it?

2 vues (au cours des 30 derniers jours)
I am studying the auditory brainstem response using a labchart software. For that we have made a matlab code that can extract the data from text file according to the stimulus threshold. The stimulus being represented in channel 1 of the file and response to that stimuli is in channel three of the dataset. We need the excel sheet for the actual time points that matlab code is taking for the averaging purpose. We wanted to confirm whether the code is taking 10ms data after the stimulus representation or not? Its so difficult to do it mannually. So i need a help how easily i can have those 10ms data points for averaging purpose.
Please this is an request I am not from this field.
Please help.
Thank you.....
  2 commentaires
Cris LaPierre
Cris LaPierre le 11 Mai 2023
It is very hard for us to help without
  1. Your data
  2. Your code
Avinash
Avinash le 12 Mai 2023
Thank you.
I have shared the code that we are using and a sample text file that has been exported from labchart file.
I am also sharing you the screenshort of the labchart data window how does it looks like.
Please check. Thank you....

Connectez-vous pour commenter.

Réponses (2)

Peter Perkins
Peter Perkins le 5 Juin 2023
Avinash, I'm not really sure what you are trying to do, but this should get you started:
>> t = readtable("90.txt",HeaderLines=6);
>> t.Properties.VariableNames = ["Time" "Channel_1" "Channel_3"];
>> t.Time = seconds(t.Time);
>> tt = table2timetable(t)
tt =
67398×2 timetable
Time Channel_1 Channel_3
___________ __________ _________
0 sec 0.0175 -0.00125
5e-05 sec 0.018125 -0.0025
0.0001 sec 0.018437 -0.00625
0.00015 sec 0.01875 -0.010625
0.0002 sec 0.020625 -0.01375
0.00025 sec 0.014375 -0.016875
0.0003 sec -0.001875 -0.01875
0.00035 sec 0.040625 -0.019375
0.0004 sec 0.1025 -0.01875
0.00045 sec 0.047188 -0.019375
0.0005 sec -0.082812 -0.01875
0.00055 sec -0.10531 -0.018125
0.0006 sec 0.025937 -0.01875
0.00065 sec 0.14188 -0.018125
0.0007 sec 0.10562 -0.01875
0.00075 sec 0.0009375 -0.018125
0.0008 sec -0.0375 -0.0175
0.00085 sec -0.0075 -0.0175
0.0009 sec 0.021875 -0.016875
0.00095 sec 0.014063 -0.0175
: : :
0.011 sec -0.0034375 0.0075
0.01105 sec -0.0034375 0.006875
0.0111 sec -0.0034375 0.00625
0.01115 sec -0.0034375 0.005
0.0112 sec -0.0034375 0.004375
0.01125 sec -0.003125 0.00375
0.0113 sec -0.0034375 0.00375
0.01135 sec -0.0034375 0.003125
0.0114 sec -0.0034375 0.003125
0.01145 sec -0.003125 0.00375
0.0115 sec -0.003125 0.003125
0.01155 sec -0.003125 0.001875
0.0116 sec -0.003125 0.0025
0.01165 sec -0.003125 0.001875
0.0117 sec -0.003125 0.00125
0.01175 sec -0.003125 0.000625
0.0118 sec -0.003125 0
0.01185 sec -0.003125 -0.000625
0.0119 sec -0.003125 0
0.01195 sec -0.003125 0.00125
Display all 67398 rows.

Star Strider
Star Strider le 5 Juin 2023
Your data initially appeared to be chaotic when I plotted them, so I took a closer look and found that most of them aere arranged in similarly-sized individual ensembles. They were relatively straightforward to determine after that, however while all have three columns, sevral have only one row. This code selects only the ‘complete’ ensembles, ignoring the others, so out of the original 1878, 240 are ‘complete’.and end up in the analysis.
T1 = readtable('90.txt', 'VariableNamingRule','preserve')
T1 = 67398×3 table
ChannelTitle= Channel 1 Channel 3 _____________ _________ _________ 0 0.0175 -0.00125 5e-05 0.018125 -0.0025 0.0001 0.018437 -0.00625 0.00015 0.01875 -0.010625 0.0002 0.020625 -0.01375 0.00025 0.014375 -0.016875 0.0003 -0.001875 -0.01875 0.00035 0.040625 -0.019375 0.0004 0.1025 -0.01875 0.00045 0.047188 -0.019375 0.0005 -0.082812 -0.01875 0.00055 -0.10531 -0.018125 0.0006 0.025937 -0.01875 0.00065 0.14188 -0.018125 0.0007 0.10562 -0.01875 0.00075 0.0009375 -0.018125
figure
plot(T1{:,1}, T1{:,[2 3]})
grid
xlabel('Time')
ylabel('Signals')
legend('Stimulus','Response', 'Location','best')
figure
plot(T1{:,1}, T1{:,[2 3]})
grid
xlabel('Time')
ylabel('Signals')
legend('Stimulus','Response', 'Location','best')
xlim([0.0020 0.0022])
[Ut11,ia,ib] = unique(T1{:,1});
Ensembles = accumarray(ib, (1:numel(ib)).', [], @(x){T1{x,:}}) % Collect Ensembles
Ensembles = 1878×1 cell array
{274×3 double} {274×3 double} {274×3 double} {274×3 double} {274×3 double} {274×3 double} {274×3 double} {274×3 double} {274×3 double} {274×3 double} {274×3 double} {274×3 double} {274×3 double} {274×3 double} {274×3 double} {274×3 double}
EnsemblesRowSize = cellfun(@(x)size(x,1), Ensembles); % Determine Row Sized
EnsemblesColSize = cellfun(@(x)size(x,2), Ensembles); % Determine Column Sizes
URows = unique(EnsemblesRowSize,'stable') % Row Size Determination
URows = 2×1
274 1
Lv = EnsemblesRowSize == max(URows); % Logical Vector Of Ensembles With Complete Row Sizes
Matching = nnz(Lv) % Number With Complete Row Sizes
Matching = 240
Ensembles = Ensembles(Lv); % Select Full Ensmebles For Analysis
UCols = unique(EnsemblesColSize,'stable'); % All Have Three Columns
Ensembles3 = cat(3,Ensembles{:}); % Concatenate Ensembles
SzEns3 = size(Ensembles3)
SzEns3 = 1×3
274 3 240
EnsPer = permute(Ensembles3, [3 2 1]); % Permute Array (To Make It Easier To Work With)
SzEnsPer = size(EnsPer)
SzEnsPer = 1×3
240 3 274
Ens = EnsPer(:,:,1) % Check The First Ensemble
Ens = 240×3
0 0.0175 -0.0013 0.0001 0.0181 -0.0025 0.0001 0.0184 -0.0063 0.0001 0.0187 -0.0106 0.0002 0.0206 -0.0138 0.0003 0.0144 -0.0169 0.0003 -0.0019 -0.0187 0.0003 0.0406 -0.0194 0.0004 0.1025 -0.0187 0.0004 0.0472 -0.0194
% figure
% plot(Ens(:,1), Ens(:,[2 3]))
% grid
% xlabel('Time')
% ylabel('Signals')
% title('Ensemble #1')
% legend('Stimulus','Response', 'Location','best')
figure
plot(EnsPer(:,1,1), EnsPer(:,[2 3],1))
grid
xlabel('Time')
ylabel('Signals')
title('Ensemble #1')
legend('Stimulus','Response', 'Location','best')
figure
plot(EnsPer(:,1,end), EnsPer(:,[2 3],end))
grid
xlabel('Time')
ylabel('Signals')
title('Ensemble #274')
legend('Stimulus','Response', 'Location','best')
figure
tiledlayout(3,3)
for k = 1:fix(274/8):274
nexttile
plot(EnsPer(:,1,k), EnsPer(:,[2 3],k))
grid
xlabel('Time')
ylabel('Amplitude')
title("Ensemble "+k)
end
EnsAvg = mean(EnsPer,3)
EnsAvg = 240×3
0 -0.0010 -0.0011 0.0000 -0.0009 -0.0011 0.0001 -0.0008 -0.0011 0.0001 -0.0006 -0.0012 0.0002 -0.0005 -0.0011 0.0003 -0.0003 -0.0012 0.0003 -0.0004 -0.0011 0.0004 -0.0002 -0.0012 0.0004 0.0006 -0.0012 0.0005 0.0014 -0.0011
EnsStd = std(EnsPer, [], 3);
EnsSEM = EnsStd/sqrt(size(EnsPer,3));
EnsSEM = 240×3
1.0e+00 * 0 0.0005 0.0005 0.0000 0.0005 0.0006 0.0000 0.0005 0.0006 0.0000 0.0005 0.0006 0.0000 0.0005 0.0006 0.0000 0.0006 0.0006 0.0000 0.0006 0.0006 0.0000 0.0006 0.0006 0.0000 0.0008 0.0006 0.0000 0.0009 0.0006
CI2 = 1.96*EnsSEM(:,2)*[-1 1];
CI3 = 1.96*EnsSEM(:,3)*[-1 1];
figure
hp1 = plot(EnsAvg(:,1), EnsAvg(:,2),'-b', 'DisplayName','Stimulus Ensemble Average');
hold on
hp2 = plot(EnsAvg(:,1), EnsAvg(:,3),'-r', 'DisplayName','Response Ensemble Average');
hp3 = plot(EnsAvg(:,1), CI2+EnsAvg(:,2), '--b', 'DisplayName','Stimulus 95% Confidence Interval');
hp4 = plot(EnsAvg(:,1), CI3+EnsAvg(:,3), '--r', 'DisplayName','Response 95% Confidence Interval');
hold off
grid
xlabel('Time')
ylabel('Signals')
title('Ensemble Average')
legend([hp1 hp2 hp3(1) hp4(1)],'Location','best')
I am not certain what you want to do with these at this point, however my code finds the individual ensembles, isolates them, and presents them, and illustrates how to recover them from the ‘EnsPer’ (‘Ensemble Permuted’) matrix to work with them.
I leave all further analyses to you, since I know nothing more about your study than you shared in your initial post.
.

Catégories

En savoir plus sur Predictive Maintenance Toolbox dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by