User Tools

Site Tools


gsr_data_analysis

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
gsr_data_analysis [2010/06/18 18:30] – typo opts -> struct ! jochengsr_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>% use file selector of xff class <code matlab GSR_data_readacq.m>% use file selector of xff class
-gsr = xff('*.acq', 'Please select the GSR-ACQ file to work with...');+gsr = xff('*.acq', 'Please select the GSR-ACQ file to work with...');</code>
  
-% the actual data will then either be in +To use a variable in a MAT file, simply use the ''load MATFILE'' call in Matlab
-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;</code> +% create new NTT (used for methods on data!) 
- +ntt = xff('new:ntt'); 
-To use a variable in a MAT file, simply use the ''load MATFILE'' call in Matlab.+  
 +% store data from mat file in ntt 
 +ntt.Data = data;</code>
  
 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:
 {{:gsr_example_5secsraw.png|10 seconds of raw GSR data recording}} {{:gsr_example_5secsraw.png|10 seconds of raw GSR data recording}}
  
-As you can see, the very small signal variations are normally quite uninteresting (as the skin response only very sluggishly follows the stimulation/emotional state of the subject). Hence, it is usually a good idea to resample the signal to a more suitable resolution. To keep some of the finer details (and being able to determine latency values with a reasonable resolution), for this example I resampled the data to 100Hz using the [[resampleaa]] function (which works a little better than using just ''downsample''):+As you can see, the very small signal variations are normally quite uninteresting (as the skin response only very sluggishly follows the stimulation/emotional state of the subject). Hence, it is usually a good idea to resample the signal to a more suitable resolution. To keep some of the finer details (and being able to determine latency values with a reasonable resolution), for this example I resampled the data to 100Hz using the [[acq.Resample|ACQ::Resample]] or [[ntt.Resample|NTT::Resample]] method (internally using the [[resampleaa]] function which works a little better than using just ''downsample''):
  
 <code matlab GSR_resampledplot.m>% resampling the data <code matlab GSR_resampledplot.m>% resampling the data
-rdata = resampleaa(data, 5);+% the first channel is actual physiological data and needs hi-quality 
 +% resampling (cubic/gaussian average), the stim channels 2:9 
 +% only need indexing into the correct temporal samples 
 +gsr.Resample(100, struct('cubic', [true, false(18)]));
  
 % plotting same time index with stronger line % plotting same time index with stronger line
-set(plot(rdata(50400:51399)), 'LineWidth', 2);</code>+data = gsr.ChannelData(1); 
 +set(plot(data(50400:51399)), 'LineWidth', 2);</code>
  
 {{:gsr_example_5secsresampled.png|100Hz-resampled GSR data}} {{:gsr_example_5secsresampled.png|100Hz-resampled GSR data}}
  
 ===== (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/stimulation the subject could have reacted to. Further the signal pre-processing, I then applied a difference (first discreet derivative, ''diff'')-filter that removes artifacts in signals which are unlikely to be in the desired spectrum using the [[prefilter]] function:+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/stimulation the subject could have reacted to. Further the signal pre-processing, I then applied a difference (first discreet derivative, ''diff'')-filter that removes artifacts in signals which are unlikely to be in the desired spectrum using the [[acq.Filter|ACQ::Filter]]/[[ntt.Filter|NTT::Filter]] method (which makes use of the [[prefilter]] function):
  
-<code matlab GSR_prefilter.m>simply pass to prefilter +<code matlab GSR_prefilter.m>call obj.Filter with default parameters for first channel 
-fdata = prefilter(rdata);+gsr.Filter(1);
  
 % plotting same time index with stronger line % plotting same time index with stronger line
-set(plot(fdata(50400:51399)), 'LineWidth', 2);</code>+data = gsr.ChannelData(1); 
 +set(plot(data(50400:51399)), 'LineWidth', 2);</code>
  
 {{:gsr_example_5secsfiltered.png|filtered GSR data}} {{:gsr_example_5secsfiltered.png|filtered GSR data}}
Line 82: Line 89:
 <code matlab GSR_acq_stimonsets.m>% all stimuli onsets (use 1 + to cope for the fact that the <code matlab GSR_acq_stimonsets.m>% all stimuli onsets (use 1 + to cope for the fact that the
 % 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);</code>
- +
-% cope for resampling from 500Hz -> 100Hz !! +
-neu = round(0.2 .* neu); +
-neg = round(0.2 .* neg); +
-rea = round(0.2 .* rea);</code>+
  
 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.
Line 134: Line 136:
 reacurves = cell(numel(rea), 2); reacurves = cell(numel(rea), 2);
 for sc = 1:numel(neu) for sc = 1:numel(neu)
-    neucurves{sc, 1} = sprintf('LookNeu %02d at t=%.3fs', sc, 0.01 * neu(sc)); +    neucurves{sc, 1} = sprintf('LookNeu %02d at t=%.3fs', sc, neu(sc)); 
-    neucurves{sc, 2} = [gsrchannel, neu(sc), neu(sc) + 1499];+    neucurves{sc, 2} = [gsrchannel, neu(sc) - 2, neu(sc) + 14];
 end end
 for sc = 1:numel(neg) for sc = 1:numel(neg)
-    negcurves{sc, 1} = sprintf('LookNeg %02d at t=%.3fs', sc, 0.01 * neg(sc)); +    negcurves{sc, 1} = sprintf('LookNeg %02d at t=%.3fs', sc, neg(sc)); 
-    negcurves{sc, 2} = [gsrchannel, neg(sc), neg(sc) + 1499];+    negcurves{sc, 2} = [gsrchannel, neg(sc) - 2, neg(sc) + 14];
 end end
 for sc = 1:numel(rea) for sc = 1:numel(rea)
-    reacurves{sc, 1} = sprintf('ReaNeg %02d at t=%.3fs', sc, 0.01 * rea(sc)); +    reacurves{sc, 1} = sprintf('ReaNeg %02d at t=%.3fs', sc, rea(sc)); 
-    reacurves{sc, 2} = [gsrchannel, rea(sc), rea(sc) + 1499];+    reacurves{sc, 2} = [gsrchannel, rea(sc) - 2, rea(sc) + 14];
 end end
 +
 +% spots
 +spot = {[neu; neg; rea]};
 +spotnames = {'Stim onset'};
  
 % combine curves % combine curves
Line 156: Line 162:
  
 % use plot curves % use plot curves
-plotcurves(gsr, struct('curves', {curves}, 'sets', {sets}));</code>+plotcurves(gsr, struct( ... 
 +    'curves',    {curves}, ... 
 +    'sets',      {sets}, ... 
 +    'spot',      {spot}, ... 
 +    'spotnames', {spotnames}));</code>
  
gsr_data_analysis.1276885801.txt.gz · Last modified: 2010/06/18 18:30 by jochen