Back to the main page.

Bug 1719 - ensure that the spike tutorial works on Neurosim data

Status CLOSED FIXED
Reported 2012-09-19 15:45:00 +0200
Modified 2019-08-10 11:56:23 +0200
Product: FieldTrip
Component: documentation
Version: unspecified
Hardware: PC
Operating System: Linux
Importance: P3 normal
Assigned to: Bart Gips
URL:
Tags:
Depends on:
Blocks: 998
See also:

Bart Gips - 2012-09-19 15:45:01 +0200

see http://fieldtrip.fcdonders.nl/tutorial/spike


Bart Gips - 2012-09-24 13:29:25 +0200

Created attachment 318 test script for Spike tutorial


Bart Gips - 2012-09-24 13:30:39 +0200

(In reply to comment #1) This script goes through all routines mentioned in the spike tutorial, and is therefore quite long. Is this the preferred way to create such a test script?


Bart Gips - 2012-09-24 13:33:45 +0200

fixed typo: Index: trialfun/ft_trialfun_general.m =================================================================== --- trialfun/ft_trialfun_general.m (revision 6487) +++ trialfun/ft_trialfun_general.m (working copy) @@ -33,7 +33,7 @@ if isfield(cfg.trialdef, 'ntrials') && isempty(cfg.trialdef.ntrials ), cfg.trialdef = rmfield(cfg.trialdef, 'ntrials' ); end if isfield(cfg.trialdef, 'triallength') - % reading all segments from a continuous fie is incompatible with any other option + % reading all segments from a continuous file is incompatible with any other option try, cfg.trialdef = rmfield(cfg.trialdef, 'eventvalue'); end try, cfg.trialdef = rmfield(cfg.trialdef, 'prestim' ); end try, cfg.trialdef = rmfield(cfg.trialdef, 'poststim' ); end


Bart Gips - 2012-09-24 13:34:38 +0200

added the neurosimfiletypes when it's not a folder: Index: fileio/ft_filetype.m =================================================================== --- fileio/ft_filetype.m (revision 6487) +++ fileio/ft_filetype.m (working copy) @@ -171,7 +171,9 @@ type = 'compressed'; manufacturer = 'undefined'; content = 'unknown, extract first'; + + % these are some streams for asynchronous BCI elseif filetype_check_uri(filename, 'fifo') type = 'fcdc_fifo'; @@ -329,7 +331,12 @@ type = 'neurosim'; manufacturer = 'Jan van der Eerden (DCCN)'; content = 'simulated spikes and continuous signals'; - + % if file does not have an extension and is called signals or spikes it is + % Neurosim data +elseif isempty(x) && (strcmp(filename,'signals') || strcmp(filename,'spikes')) + type = 'neurosim'; + manufacturer = 'Jan van der Eerden (DCCN)'; + content = 'simulated spikes and continuous signals'; % known 4D/BTI file types elseif filetype_check_extension(filename, '.pdf') && filetype_check_header(filename, 'E|lk') % I am not sure whether this header always applies


Bart Gips - 2012-09-24 13:35:58 +0200

(In reply to comment #4) I talked to Jan about this. But maybe it's a good idea to make up a file extension for neurosim data. This way it's easier to detect it. (instead of just looking for 'signals' and 'spikes' without an extension; these names might be too generic)


Bart Gips - 2012-09-24 13:37:30 +0200

Switched the columns and rows for the labels and timestamp fields (this is the way the experimental data does it. I.e. 1xM instead of Mx1) Index: fileio/private/read_neurosim_spikes.m =================================================================== --- fileio/private/read_neurosim_spikes.m (revision 6487) +++ fileio/private/read_neurosim_spikes.m (working copy) @@ -84,11 +84,12 @@ % it is more convenient to represent each neuron in its own channel number = unique(numeric(:,2)'); -spike.label = cell(length(number), 1); -spike.timestamp = cell(length(number), 1); +spike.label = cell(1,length(number)); +spike.timestamp = cell(1,length(number)); for i=1:length(number) sel = numeric(:,2)==number(i); spike.label{i} = sprintf('%d', number(i)); spike.timestamp{i} = numeric(sel,1)'; end


Bart Gips - 2012-09-24 13:42:24 +0200

changed the way the signals file is read (mainly for the header information). The time units used by neurosim are milliseconds. The FirstTimeStamp and TimeStampPerSample are needed by ft_spike_maketrials when selecting cfg.trlunit='samples'; This seemed the most obvious solution to the fact that the 'timestamps' read in by read_neurosim_spikes are in fact time values in milliseconds and are therefor generally not integers. Index: fileio/private/read_neurosim_signals.m =================================================================== --- fileio/private/read_neurosim_signals.m (revision 6487) +++ fileio/private/read_neurosim_signals.m (working copy) @@ -69,7 +69,7 @@ fclose(fid); % get the time axis, this is needed to determine the sampling frequency -time = dat(match_str(label, 'Time'), :); +time = dat(match_str(label, 'Time'), :)/1e3; %neurosim time is in ms, not seconds fsample = median(1./diff(time)); % convert the header into fieldtrip style @@ -86,5 +86,7 @@ hdr.nSamplesPre = 0; hdr.nTrials = 1; +hdr.FirstTimeStamp = min(time); +hdr.TimeStampPerSample = 1e3/fsample; %how many timestamps (ms) are in one sample % also store the original ascii header details hdr.orig = orig(:);


Bart Gips - 2012-09-24 14:33:24 +0200

Created attachment 319 test script for Spike tutorial - Neurosim


Bart Gips - 2012-09-24 14:35:11 +0200

Created attachment 320 'signals' file from Neurosim (used for extracting header information)


Bart Gips - 2012-09-24 14:36:07 +0200

Created attachment 321 'spikes' file from Neurosim (should be in one folder together with 'signals')


Bart Gips - 2012-09-24 14:38:46 +0200

(In reply to comment #8) This test script contains the same routines as the other, but is now performed on the attached neurosim data. It is not able to use ft_spike_waveform(cfg,spike), because the neurosim data does not contain waveform information. Is this something that could be useful? Or is the waveform mainly used for spike sorting? (not necessary with simulated spiketrains)


Bart Gips - 2012-09-25 13:26:45 +0200

Created attachment 324 test script for Spike tutorial - Neurosim Forgot to put the path to relative when defining trials.


Robert Oostenveld - 2012-09-25 14:38:21 +0200

(In reply to comment #1) I added it to FT manzana> svn commit test_tutorial_spike.m Adding test_tutorial_spike.m Transmitting file data . Committed revision 6534.


Robert Oostenveld - 2012-09-25 14:38:39 +0200

(In reply to comment #2) this is indeed the preferred way.


Robert Oostenveld - 2012-09-25 14:50:55 +0200

I have applied the suggested patches to the FT code manzana> svn commit trialfun/ft_trialfun_general.m fileio/ft_filetype.m fileio/private/read_neurosim_spikes.m fileio/private/read_neurosim_signals.m Sending fileio/ft_filetype.m Sending fileio/private/read_neurosim_signals.m Sending fileio/private/read_neurosim_spikes.m Sending trialfun/ft_trialfun_general.m


Bart Gips - 2012-10-23 10:48:58 +0200

Added test_tutorial_spike_Neurosim.m in the fieldtrip/test/ directory. This script reads the neurosim data from: /home/common/matlab/fieldtrip/data/test/neurosim


Robert Oostenveld - 2019-08-10 11:56:23 +0200

This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue describing the issue on https://github.com/fieldtrip/fieldtrip/issues.