Hi, I was wondering if someone could help me out on this one:
I have a recording with 2 action potentials one after the other stimulated at different points. The thing is I only want the data for the first one but I cant seem to get my head around extracting the time window which includes the fEPSP I want from the whole plot.
num_samp = size(Data.S{1,1});
Interval = Data.t_interval
t= 0:Interval:(num_samp-1)*Interval;
t = t'*1000;
Record = plot(t, Data.S{1,1});
This is the code im currently using to plot the whole set of recordings but I would like to have the ones between 10ms and 45ms only.
Hope you can help me, if more information is needed I am happy to supply it.
Thanks in advance.

 Respuesta aceptada

Tarunbir Gambhir
Tarunbir Gambhir el 19 de Mzo. de 2021

0 votos

You could search for the start and end indices in the time vector and use that to plot the data within that interval.
You could try something like this:
data = Data.S{1,1};
num_samp = size(data);
Interval = Data.t_interval;
t= 0:Interval:(num_samp-1)*Interval;
t = t'*1000;
startI = find(t==10); % assuming the time is in ns
endI = find(t==45);
Record = plot(t(startI:endI), data(startI:endI));

5 comentarios

AMC3011
AMC3011 el 19 de Mzo. de 2021
Thanks for the answer!
I implemented this to my code:
clear
[file,folder]=uigetfile('*.xls;*.xlsx;*.csv');
filename=fullfile(folder,file);
Nbook = readtable(filename);
d = dir('*.wcp');
Num_files = length(d);
Names = cell(0);
for n = 1:Num_files
Fname = fullfile(d(n).name);
Names{n} = Fname;
Names = Names.';
end
Data = char(Names(1:1));
Data = import_wcp(Data);
data = Data.S{1,1};
num_samp = size(data);
Interval = Data.t_interval;
t= 0:Interval:(num_samp-1)*Interval;
t = t'*1000;
startI = find(t==10);
endI = find(t==45);
Record = plot(t(startI:endI), data(startI:endI));
When Matlab creates the Record plot it appears as a 0x1 line in the workshop and it does not show it in a figure window, what could be the problem?
Tarunbir Gambhir
Tarunbir Gambhir el 19 de Mzo. de 2021
Could you share the data file, so that I can reproduce it at my end?
AMC3011
AMC3011 el 19 de Mzo. de 2021
Editada: AMC3011 el 19 de Mzo. de 2021
Sure here are all the needed files:
I can not attach de .wcp thats why they are in a Google Drive. I am currently only working on the first .wcp file ending in B2, but will eventually end creating a for loop to batch all of them.
Thanks in advance!
Edit: Deleted the file link for privacy issues.
Tarunbir Gambhir
Tarunbir Gambhir el 19 de Mzo. de 2021
Thanks for sharing the data. I see that the problem arises because the time vector "t" would not necessarily have a value equal to 10 or 45 in this case.
I modified the last 3 lines of code and you should see the desired results with this:
[~,startI] = min(abs(t-10));
[~,endI] = min(abs(t-45));
Record = plot(t(startI:endI), data(startI:endI,:));
AMC3011
AMC3011 el 19 de Mzo. de 2021
Hugely appreciated, that does exactly the job!
Thanks and kind regards.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Productos

Versión

R2020b

Preguntada:

el 16 de Mzo. de 2021

Editada:

el 19 de Mzo. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by