gsr_data_analysis
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| gsr_data_analysis [2010/06/17 20:40] – created jochen | gsr_data_analysis [2010/06/18 23:22] (current) – changed onsets to be in ms jochen | ||
|---|---|---|---|
| Line 22: | Line 22: | ||
| <code matlab GSR_data_readacq.m> | <code matlab GSR_data_readacq.m> | ||
| - | gsr = xff(' | + | gsr = xff(' |
| - | % the actual data will then either be in | + | To use a variable in a MAT file, simply use the '' |
| - | data = gsr.RawData(CHANNEL, | + | <code matlab GSR_data_loadmat.m>% load a mat file (e.g. an ACQ->MAT converted file) |
| - | + | load HPS1344_session1_GSR.mat; | |
| - | % or in | + | |
| - | data = gsr.Channel(CHANNEL).Data;</ | + | % create new NTT (used for methods on data!) |
| - | + | ntt = xff(' | |
| - | To use a variable in a MAT file, simply use the '' | + | |
| + | % store data from mat file in ntt | ||
| + | ntt.Data = data;</ | ||
| Or if you require to load the data from a text-based (e.g. log) file, you can use the following code: | Or if you require to load the data from a text-based (e.g. log) file, you can use the following code: | ||
| Line 52: | Line 54: | ||
| {{: | {{: | ||
| - | As you can see, the very small signal variations are normally quite uninteresting (as the skin response only very sluggishly follows the stimulation/ | + | As you can see, the very small signal variations are normally quite uninteresting (as the skin response only very sluggishly follows the stimulation/ |
| <code matlab GSR_resampledplot.m> | <code matlab GSR_resampledplot.m> | ||
| - | rdata = resampleaa(data, 5); | + | % the first channel is actual physiological |
| + | % resampling (cubic/ | ||
| + | % only need indexing into the correct temporal samples | ||
| + | gsr.Resample(100, | ||
| % plotting same time index with stronger line | % plotting same time index with stronger line | ||
| - | set(plot(rdata(50400: | + | data = gsr.ChannelData(1); |
| + | set(plot(data(50400: | ||
| {{: | {{: | ||
| ===== (Pre-) Filtering data ===== | ===== (Pre-) Filtering data ===== | ||
| - | While a lot of the very high-frequency noise is (naturally) gone after the resampling, there is still a lot of signal variation that is (very likely) unrelated to any task/ | + | While a lot of the very high-frequency noise is (naturally) gone after the resampling, there is still a lot of signal variation that is (very likely) unrelated to any task/ |
| - | <code matlab GSR_prefilter.m> | + | <code matlab GSR_prefilter.m> |
| - | fdata = prefilter(rdata); | + | gsr.Filter(1); |
| % plotting same time index with stronger line | % plotting same time index with stronger line | ||
| - | set(plot(fdata(50400: | + | data = gsr.ChannelData(1); |
| + | set(plot(data(50400: | ||
| {{: | {{: | ||
| Line 82: | Line 89: | ||
| <code matlab GSR_acq_stimonsets.m> | <code matlab GSR_acq_stimonsets.m> | ||
| % first value in diff rather codes the second sample in the data! | % first value in diff rather codes the second sample in the data! | ||
| - | all_onsets = 1 + find(diff(gsr.RawData(8, :)') > 0); | + | all_onsets = 1 + find(diff(gsr.ChannelData(8)) > 0); |
| % now split into three conditions | % now split into three conditions | ||
| - | neu = all_onsets(gsr.RawData(2, all_onsets) > 0); | + | neu = 0.01 * all_onsets(gsr.ChannelData(2, all_onsets) > 0); |
| - | neg = all_onsets(gsr.RawData(3, all_onsets) > 0); | + | neg = 0.01 * all_onsets(gsr.ChannelData(3, all_onsets) > 0); |
| - | rea = all_onsets(gsr.RawData(4, all_onsets) > 0); | + | rea = 0.01 * all_onsets(gsr.ChannelData(4, all_onsets) > 0);</ |
| - | + | ||
| - | % cope for resampling from 500Hz -> 100Hz !! | + | |
| - | neu = round(0.2 .* neu); | + | |
| - | neg = round(0.2 .* neg); | + | |
| - | rea = round(0.2 .* rea);</ | + | |
| As window length for the inspection of the GSR data, we choose 15 seconds, so in the resolution of the resampled data that means 1,500 samples. | As window length for the inspection of the GSR data, we choose 15 seconds, so in the resolution of the resampled data that means 1,500 samples. | ||
| + | |||
| + | In our second example, the data only contains the onsets (not the condition information). This has to be established separately (which can be even done **after** extracting the peak-to-peak values, thus allowing for a blind-analysis of data, as the examiner doesn' | ||
| + | |||
| + | <code matlab GSR_plain_onsets.m> | ||
| + | % (in this case a MAT file written by Acqknowledge for ACQ Version >= 4) | ||
| + | % which is in 200Hz sampling frequency with | ||
| + | % GSR = channel 1 and | ||
| + | % ECG = channel 2 | ||
| + | load 6701.acq.mat | ||
| + | |||
| + | % the stimulus channel in this example is channel 3, | ||
| + | % coded with 0 Volts for no stimulus and 5V for stimulus | ||
| + | % thus, to find the time points (samples) on which a | ||
| + | % stimulus occurs, we look for spots in this channel | ||
| + | % where the value changes from below 2.5V to above 2.5V | ||
| + | stimactive = (data(:, 3) > 2.5); | ||
| + | onsets = find(~stimactive(2: | ||
| + | |||
| + | % creating the necessary information for plotcurves | ||
| + | % the onset is shifted by 200 samples (1 second) to show | ||
| + | % a window of [-1 .. 14] (in seconds) | ||
| + | c = cell(numel(onsets), | ||
| + | for cc = 1: | ||
| + | c{cc,1} = sprintf(' | ||
| + | c{cc, 2} = [1, onsets(cc)-200, | ||
| + | end | ||
| + | |||
| + | % calling plotcurves | ||
| + | plotcurves(data, | ||
| ===== Peak-to-peak analysis ===== | ===== Peak-to-peak analysis ===== | ||
| Line 101: | Line 132: | ||
| <code GSR_peaktopeak.m> | <code GSR_peaktopeak.m> | ||
| gsrchannel = 1; | gsrchannel = 1; | ||
| - | neucurves = cell(numel(neu), | + | neucurves = cell(numel(neu), |
| - | negcurves = cell(numel(neg), | + | negcurves = cell(numel(neg), |
| - | reacurves = cell(numel(rea), | + | reacurves = cell(numel(rea), |
| for sc = 1: | for sc = 1: | ||
| - | neucurves{sc, | + | neucurves{sc, |
| - | neucurves{sc, | + | neucurves{sc, |
| end | end | ||
| for sc = 1: | for sc = 1: | ||
| - | negcurves{sc, | + | negcurves{sc, |
| - | negcurves{sc, | + | negcurves{sc, |
| end | end | ||
| for sc = 1: | for sc = 1: | ||
| - | reacurves{sc, | + | reacurves{sc, |
| - | reacurves{sc, | + | reacurves{sc, |
| end | end | ||
| + | |||
| + | % spots | ||
| + | spot = {[neu; neg; rea]}; | ||
| + | spotnames = {'Stim onset' | ||
| % combine curves | % combine curves | ||
| Line 127: | Line 162: | ||
| % use plot curves | % use plot curves | ||
| - | plotcurves(gsr, | + | plotcurves(gsr, |
| + | | ||
| + | | ||
| + | ' | ||
| + | ' | ||
gsr_data_analysis.1276807240.txt.gz · Last modified: 2010/06/17 20:40 by jochen
