Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
faq:discontinuous_neuralynx [2018/10/21 14:57]
42.49.180.224 1
faq:discontinuous_neuralynx [2017/08/17 11:21] (current)
127.0.0.1 external edit
Line 1: Line 1:
-{{tag>faq neuralynx corrupt preprocessing}} ​+{{tag>faq neuralynx corrupt preprocessing}} ​
  
 ===== How can I deal with a discontinuous Neuralynx recording ===== ===== How can I deal with a discontinuous Neuralynx recording =====
Line 16: Line 16:
  
  
-&lt;code&gt;+<code>
 % start with normal preprocessing of a single channel % start with normal preprocessing of a single channel
 cfg         = []; cfg         = [];
Line 23: Line 23:
  
 Warning: discontinuous recording, predicted number of timestamps and observed number of timestamps differ by 1693523717.00 Warning: discontinuous recording, predicted number of timestamps and observed number of timestamps differ by 1693523717.00
- ​Please consult the wiki on http://​fieldtrip.fcdonders.nl/​getting_started/​neuralynx?&​amp;#​discontinuous_recordings  + ​Please consult the wiki on http://​fieldtrip.fcdonders.nl/​getting_started/​neuralynx?&#​discontinuous_recordings  
-&​gt; ​In fileio/​private/​read_neuralynx_ncs at 94+In fileio/​private/​read_neuralynx_ncs at 94
   In ft_read_header at 1196   In ft_read_header at 1196
   In ft_preprocessing at 394    In ft_preprocessing at 394 
   ​   ​
-&​gt;&​gt; ​disp(data)+>> ​disp(data)
            hdr: [1x1 struct]            hdr: [1x1 struct]
          ​label:​ {'​CSC1'​}          ​label:​ {'​CSC1'​}
Line 41: Line 41:
 xlabel('​sample number'​) xlabel('​sample number'​)
 ylabel('​time (s)') ylabel('​time (s)')
-&lt;/code&gt;+</code>
  
 This shows the default time axis of the data, which FieldTrip assumes to be continuous. ​ This shows the default time axis of the data, which FieldTrip assumes to be continuous. ​
  
-Now we continue with reading the actual timestamps and performing interpolation and gap-filling with NaNs across multiple channels. Your multiple channels can happen to have different start or end timestamps (which is another ​&quot;feature&​quot; ​of the Cheetah software). This function then constructs a single timestamp-axis onto which all channels are represented.+Now we continue with reading the actual timestamps and performing interpolation and gap-filling with NaNs across multiple channels. Your multiple channels can happen to have different start or end timestamps (which is another ​"feature" ​of the Cheetah software). This function then constructs a single timestamp-axis onto which all channels are represented.
  
-&lt;code&gt;+<code>
 function [data_all] = ft_read_neuralynx_interp(fname) function [data_all] = ft_read_neuralynx_interp(fname)
  
Line 97: Line 97:
  
   % get the minimum and maximum across all channels   % get the minimum and maximum across all channels
-  if i&gt;1 &amp;&amp; mn(i)&lt;min_all+  if i>1 && mn(i)<min_all
     min_all = mn(i);     min_all = mn(i);
   else   else
Line 103: Line 103:
   end   end
   ​   ​
-  if i&gt;1 &amp;&amp; mx(i)&gt;max_all+  if i>1 && mx(i)>max_all
     max_all = mx(i);     max_all = mx(i);
   else   else
Line 141: Line 141:
   ​   ​
   % check if there are gaps to correct   % check if there are gaps to correct
-  gaps     = find(diff(ts)&gt;2*mode_dts);​ % skips at least a sample +  gaps     = find(diff(ts)>2*mode_dts);​ % skips at least a sample 
-  if isempty(gaps) &amp;&amp; startflag==0 &amp;&amp; endflag==0+  if isempty(gaps) && startflag==0 && endflag==0
     fprintf('​there are no gaps and all channels start and end at same time, no interpolation performed\n'​);​     fprintf('​there are no gaps and all channels start and end at same time, no interpolation performed\n'​);​
   else  ​   else  ​
Line 149: Line 149:
  
     % you can use NaN to replace the data in the gaps     % you can use NaN to replace the data in the gaps
-    gaps     = find(diff(ts)&gt;2*mode_dts);​ % skips at least a sample+    gaps     = find(diff(ts)>2*mode_dts);​ % skips at least a sample
     for igap = 1:​length(gaps)     for igap = 1:​length(gaps)
-      sel = tsinterp ​&​lt; ​ts(gaps(igap)+1) &amp; tsinterp ​&​gt; ​ts(gaps(igap));​+      sel = tsinterp ​ts(gaps(igap)+1) & tsinterp ​ts(gaps(igap));​
       datinterp(sel) = NaN;       datinterp(sel) = NaN;
     end     end
Line 158: Line 158:
     if startflag==1     if startflag==1
       n = floor(offset(i)/​mode_dts);​       n = floor(offset(i)/​mode_dts);​
-      if n&gt;0+      if n>0
         datinterp(1:​n) = NaN;         datinterp(1:​n) = NaN;
       end       end
Line 166: Line 166:
     if endflag==1     if endflag==1
       n = floor(offsetmx(i)/​mode_dts);​       n = floor(offsetmx(i)/​mode_dts);​
-      if n&gt;0+      if n>0
         datinterp(end-n+1:​end) = NaN;         datinterp(end-n+1:​end) = NaN;
       end       end
Line 193: Line 193:
 data_all.hdr.nSamples ​          = len; data_all.hdr.nSamples ​          = len;
 data_all.sampleinfo ​            = [1 len]; data_all.sampleinfo ​            = [1 len];
-&lt;/code&gt;+</code
 +