Igor PSTH analysis
Hi!
I will try exemplify my question for a better understanding.
I have a continuos wave from fluorescence data, let's called it Wave A. In the other side, I have another wave with values 0 and 1 that indicate certain events: Wave B. My question is how I can analyse the data in order to extract segments from Wave A from a deterimed time window, and based on the events of the wave B.
For example, if I select a time window of 2 seconds, and I have an event at 15.5 s, how I can extract from the Wave A between 12.5s to 17.5s. Then I will have several wave segments from every event (+ and - 2 s). After that I plan to have an average from the different types of events.
Also, if this is feasible, there is a way to consider the initial part of the event, in this case when the value change from 0000 to 1. Then do the same in the middle of the event and also when the event is over, pass from 1111 to 0.
Some ideas?
Thanks a lot in advance!!
Best,
Pedro.
Pedro,
Are WaveA and WaveB one dimensional waves?
Do both WaveA and WaveB have time X-scaling? So that I can execute 'print WaveB(15.5)' and see a value of 1?
If so, you can find events using FindValue. Then use something like Duplicate /R=(V_value-2,V_value+2) WaveA, Wave1 to extract the data.
There are other operations similar to FindValue that could be useful to you - see the manual for info.
DisplayHelpTopic "FindValue"
October 2, 2019 at 04:29 am - Permalink
Thanks a lot for your answer Tony!. In this case, Wave A and B have the same total time, however, the sampling frequency is different, so they differ in the number of points. Also, I have several "markers" in Wave B that differ in length and frequency.
Here I include an example, just overlapping both waves. One signal is my acquisition data and the other one the "Marker Wave", basically is a group of 000 and 111 that "mark" specific events.
Thanks again,
Pedro.
October 2, 2019 at 02:51 pm - Permalink
you didn't mention whether the waves have x-scaling for time. do you have separate time waves? if so, is sampling frequency fixed?
IF the the waves are x-scaled, then you need only to use FindValue and Duplicate in a loop until FindValue doesn't find an event.
If you have separate waves for time stamps, then you must figure out how to turn an X value from waveB into a time value, then back into two X values for waveA. See help for FindLevel and FindLevels.
October 4, 2019 at 01:28 am - Permalink
Thanks Tony,
Both waves have different sampling frequency but I did x-scaling for the time and is ok. Then, I have obtained the values of x-time with FindValues and I store them in other wave. Now, my question is regarding Duplicate. How I can run automatically the duplicate function and include in the parameters the point 1, point 2, etc... of the x-values that I have extracted with FindValues.
Thanks in advance
October 15, 2019 at 04:21 am - Permalink
In reply to Thanks Tony, Both waves… by p_espinosa_
So does your new wave look like this?
{event1startTime,event1endTime,event2startTime,event2endTime,...}
Do you need to save a copy of each time interval, or is it sufficient to extract one segment, do some analysis, then overwrite the extracted data with the next segment of interest, etc?
October 15, 2019 at 09:06 am - Permalink
I actually just store the initial time of each event. These values are stored in a new wave 1D called W_FindLevels. Then, my Idea was to use "For" in order to make a loop to extract each time point from W_FindLevels (using a row index for example) and then use Duplicate in my target wave. That can be done in a specific time window, as you suggested before: Duplicate /R=(V_value-2,V_value+2) but in a way that every V_value is a different row of W_FindLevels, until the end. That part I'm struggling now.
The idea is analyse the duplicate waves, make averages, statistics, etc..
I don't know if that sound logic? I don't have much experience with coding in Igor but I'm trying to figure it out how I can solve this.
Thanks!!
Pedro.
October 15, 2019 at 10:48 am - Permalink
Okay, then it's something like
for(i=0;i<numpnts(W_FindLevels);i+=1) // step through rows of W_FindLevels
duplicate /O/R=(W_FindLevels[i]-2,W_FindLevels[i]+2) WaveA, Wave1 // overwrite wave1 with a new time interval from waveA
// do something with wave1
endfor
October 15, 2019 at 02:23 pm - Permalink
Thanks a lot Tony!
I modify a bit in order to have a copy of each event.
Now my question is how I can apply SetScale to all copied waves in order to align all the events at the same time in the x-axis.
wave Marker_Events
wave fluorescence2
Findlevels /EDGE=1, Marker_Events, 1
wave W_FindLevels
variable i
for(i=0;i<numpnts(W_FindLevels);i+=1) // step through rows of W_FindLevels
Make/O/N=(i) tempRows
String name
name=NameofWave(fluorescence2)+"_Event_"+num2str(1+i)
tempRows=fluorescence2[i][p]
duplicate /R=(W_FindLevels[i]-2,W_FindLevels[i]+2) Fluorescence2, $name
endfor
end
October 15, 2019 at 04:08 pm - Permalink
wave Marker_Events
wave fluorescence2
variable event, numEvents, eventTime
String name
Findlevels /EDGE=1, Marker_Events, 1
wave W_FindLevels // contains time for each event
numEvents=numpnts(W_FindLevels)
Make/O/N=(numEvents) tempRows // create the wave once, outside of loop
for(event=0;event<numEvents;event+=1) // step through rows of W_FindLevels
name=NameofWave(fluorescence2)+"_Event_"+num2str(1+event)
eventTime=W_FindLevels[event]
// not sure what this was supposed to do
// tempRows=fluorescence2[i][p]
// you can pull values from fluorescence2 using fluorescence2(eventTime)
duplicate /R=(eventTime-2,eventTime+2) Fluorescence2, $name
wave w_new=$name
setscale /p x, 0, dimdelta(w_new, 0), w_new // keep current delta but remove offset
// as an example, set tempRows[i] to the maxiumum fluorescence value for event i
wavestats /q w_new
tempRows[event]=v_max
endfor
end
October 16, 2019 at 01:31 am - Permalink
Thanks a lot. Actually works very well.
October 16, 2019 at 12:00 pm - Permalink