Giter Club home page Giter Club logo

fieldtrip / fieldtrip Goto Github PK

View Code? Open in Web Editor NEW
806.0 49.0 709.0 993.78 MB

The MATLAB toolbox for MEG, EEG and iEEG analysis

Home Page: http://www.fieldtriptoolbox.org

License: GNU General Public License v3.0

MATLAB 87.62% C 5.81% Makefile 0.46% C++ 3.08% HTML 0.01% Shell 0.79% Python 0.12% Java 1.25% QMake 0.04% Batchfile 0.01% Processing 0.55% Emacs Lisp 0.01% Mathematica 0.25% Limbo 0.01% Prolog 0.01%
meg eeg ecog analysis matlab dipole beamformer statistics time-frequency connectivity

fieldtrip's Introduction

Open in MATLAB Online GitHub contributors Last commit GitHub commit activity (branch) GitHub Repo stars License: GPL-3.0

FieldTrip

FieldTrip is the MATLAB software toolbox for MEG and EEG analysis that is being developed at the Donders Institute for Brain, Cognition and Behaviour in Nijmegen, the Netherlands together with collaborating institutes.

The toolbox offers advanced analysis methods of MEG, EEG, and invasive electrophysiological data, such as time-frequency analysis, source reconstruction using dipoles, distributed sources and beamformers and non-parametric statistical testing. It supports the data formats of all major MEG systems (CTF, Neuromag/Elekta/Megin, BTi/4D, Yokogawa/Ricoh, FieldLine) and of most popular EEG systems, and new formats can be added easily. FieldTrip contains high-level functions that you can use to construct your own analysis protocols in MATLAB. Furthermore, it easily allows methods researchers to incorporate new methods for EEG/MEG analysis.

For more information, documentation, and tutorials, please visit http://www.fieldtriptoolbox.org

Installation

To install the FieldTrip toolbox on your computer, you can clone this repository or download the zip file, unzip it, and add it to your MATLAB path. Subsequently you call the ft_defaults function, which will add the required subdirectories to the path.

We recommend that you add the addpath(...) and the ft_defaults command to your startup.m file. See also https://www.fieldtriptoolbox.org/faq/installation/

Note that you should not use addpath(genpath(...)) and we recommend not to use the "add with subdirectories" button in the graphical path setup tool, as there are a number of external toolboxes and backward compatibility directories that you should not add to your path. If those directories are needed, then ft_defaults and ft_hastoolbox will take care of them.

Copyright

The FieldTrip software is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. See the file COPYING for more details.

The functions in the FieldTrip toolbox are copyrighted by their respective authors:

  • Robert Oostenveld, DCCN, FCDC, SMI, MBFYS
  • Jan-Mathijs Schoffelen, DCCN, MPI, CCNi, FCDC
  • Pascal Fries, FCDC
  • Eric Maris, DCC, FCDC
  • Arjen Stolk, DCCN
  • Eelke Spaak, DCCN
  • Ingrid Nieuwenhuis, DCCN, FCDC
  • Jens Schwarzbach, FCDC
  • Jorn Horschig, DCCN
  • Lilla Magyari, MPI, DCCN
  • Markus Siegel, FCDC, UKE
  • Martin Vinck, DCCN, SILS
  • Ole Jensen, FCDC
  • Roemer van der Meij, DCC
  • Saskia Haegens, DCCN, FCDC
  • Vladimir Litvak, UCL
  • and many other contributors

The authors are or were working at a range of academic institutions:

  • Copyright (C) 2008-2024, Donders Institute for Brain, Cognition and Behaviour, Radboud University, The Netherlands (DCCN, DCC, DCN)
  • Copyright (C) 2014-2024, Karolinska Institute, Stockholm, Sweden (NatMEG)
  • Copyright (C) 2012-2018, Max Planck Institute for Psycholinguistics, The Netherlands (MPI)
  • Copyright (C) 2008-2017, The Wellcome Trust Centre for Neuroimaging, University College London, UK (UCL)
  • Copyright (C) 2010-2013, Swammerdam Institute for Life Sciences, University of Amsterdam (SILS)
  • Copyright (C) 2008-2009, Centre for Cognitive Neuroimaging in Glasgow, United Kingdom (CCNi)
  • Copyright (C) 2009-2009, Netherlands Institute for Neuroscience (NIN)
  • Copyright (C) 2003-2008, F.C. Donders Centre, Radboud University Nijmegen, The Netherlands (FCDC)
  • Copyright (C) 2004-2007, Nijmegen Institute for Cognition and Information, The Netherlands (NICI)
  • Copyright (C) 2004-2005, Universitatsklinikum Hamburg-Eppendorf, Germany (UKE)
  • Copyright (C) 2003-2004, Center for Sensory Motor Interaction, University Aalborg, Denmark (SMI)
  • Copyright (C) 1999-2003, Department of Medical Physics, Radboud University Nijmegen, The Netherlands (MBFYS)

The FieldTrip software is a toolbox, i.e. a library with functions, which in turn an depend on other functions. The release of this toolbox includes functions from other toolboxes that are covered under their respective licenses. See fieldtrip/external for details. Unauthorised copying and distribution of functions that are not explicitly covered by the GPL is not allowed.

fieldtrip's People

Contributors

abastos avatar agramfort avatar breuderink avatar contsili avatar dmatthes1982 avatar haegens avatar helenacockx avatar horschig avatar ingridnieuwenhuis avatar jdien07 avatar jens-k avatar jimher avatar marcelvangerven avatar martinvinck avatar mcvinding avatar nirofir avatar nno avatar richter2552 avatar robertoostenveld avatar roemervandermeij avatar sappelhoff avatar sarangnemo avatar schoffelen avatar simonhomoelle avatar sjeung avatar smg211 avatar spaak avatar stolkarjen avatar tsanderptb avatar vlitvak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fieldtrip's Issues

FieldTrip code returning NaNs in powspctrm/crsspctrm matrix (EEG Analysis)

Hi all,

I'm doing connectivity analysis on EEG signals, and my power analysis code is returning matrices that are partially filled with NaNs. There's also a singleton dimension that shouldn't exist (we expect a 3d matrix but get a 4D one).

Here's my code: https://pastebin.com/capjKex2

My error documentation is below:
This error was brought to my attention upon receiving the following error when trying to plot power correlations:

Index in position 1 exceeds array bounds 
(must not exceed 1).

Error in ft_connectivityplot (line 287)
    tmp = reshape(dat(m,k,:,:), [nfreq ntime]);

FieldTrip code problem:
PowCorr and subsequent functions return structure fields that contain a singleton dimension which generates NaN for all indices

Current hypothesis: Fieldtrip is treating time-segmented data as a continuous line.

When I load in data and then index ALLEEG or EEG, I see:

     	times: [1×900060 double]
            data: [71×900060 single]

So I don't think the .set is missing time data, since this would show 1 time point per data point for all 71 channels.

After conversion via eeglab2fieldtrip, the new structure E2F returns:

      trial: {[71×900060 single]}
   	      time: {[1×900060 double]}

So it doesn't really seem like anything is going wrong here.

When running ft_freqanalysis, I get 4 warnings:

  1. Warning: assuming that the units are "m"
  2. Warning: the data does not contain a trial definition
  3. Warning: reconstructing sampleinfo by assuming that the trials are consecutive segments of a continuous
    recording
  4. Warning: output time-bins are different from input time-bins

I see 2 and 4 in a lot of sample code so I'm assuming these are benign. I have no idea what the first means(what is m? meters?). 3 is the one I'm interested in. Reconstructing sampleinfo is normally benign(see here https://mailman.science.ru.nl/pipermail/fieldtrip/2012-March/004962.html), but does the assumption mean all channels are being merged into 1 mega-channel?

After running ft_freqanalysis, I begin to see the problems. Indexing the output structure Freq returns:

Freq =

struct with fields:

    label: {1×71 cell}
   dimord: 'rpt_chan_freq_time'
     freq: [4 4.5000 5 5.5000 6 6.5000 7 7.5000 8]
     time: [1×301 double]
powspctrm: [1×71×9×301 double]
 labelcmb: {2485×2 cell}
crsspctrm: [1×2485×9×301 double]
cumtapcnt: [1 1 1 1 1 1 1 1 1]
     elec: [1×1 struct]
      cfg: [1×1 struct]

The problem here is those singleton dimensions in Freq.powspctrm and Freq.crsspctrm--In either matrix, any 4th dimension less than 59 returns NaN.

Then, I think the problem is clearly in (or begins in) this particular function. What's going wrong?

Things I've tried:

  1. Squeezing out singleton dimension did not remove NaNs and just gave a different error

  2. Updating cfg structures didn't change anything

2.5) Changing ft_freqanalysis padding didn’t do anything

  1. Checking the data in EEGLab showed a really weird channel scroll

  2. ICA did not remove the error

  3. Try a new dataset (using cognit data). Same problem.

Next steps:

  1. Debug ft_freqanalysis

Any help is greatly appreciated!

Best,
Alex

qsubfeval uses a strange default matlab executable on DCCN cluster

In qsubfeval at line 193 getenv('MATLAB_BIN') is used. On the DCCN cluster this returns /opt/matlab/R2012b/bin/matlab, even when the Matlab version in which I'm running qsubfeval is R2017b. I realize that this is a DCCN-specific issue, but am wondering if we could not be doing something smarter to determine the appropriate Matlab version to run. (E.g. detect whether we are at the DCCN, then get current Matlab version, and construct /opt/matlab/RXXXXz/bin/matlab from that.)

ft_combineplanar fails on data recorded in multiple blocks

... where the blocks are in different fif files, preprocessed and then appended. The grad structure will be slightly different, and hence removed by ft_appenddata.

The reason why ft_combineplanar is not because it cannot work (it uses pre-defined channel lists, not the grad), but only because it cannot detect the sensor type. I.e. ft_checkdata gives the error that it cannot detect that it is planar channels.

mistake in ft_crossfrequencyanalysis.m ?

On lines 238 and 260 of ft_crossfrequencyanalysis.m - the computation section of the modulation index - the lines read:
mi(i,j) = nansum(P.* (log(P)-log2(Q)))/log(nbin);

Apologies if I'm missing something, but don't the log terms all need to be in the same base? A recent version of fieldtrip has them all as log2.

implement low-level functions for connectivity

following discussion with @schoffelen, I propose that we improve the code for some methods which are currently not easily available.

MIM is available in megconnectome but not in FT. The style of the function is already very similar to ft_connectivity_xxx functions

PCC (partial and/or canonical correlation/coherence) is available in ft_sourcedescriptives for source level CSDs, but not for channels.

ft_trackusage.m bug in -nojvm mode

Hi Robert,

I get an error running Fieldtrip code when in matlab -nojvm mode. The same code worked well with previous fieldtrip versions.

  File /Users/nicolas/Toolboxes/fieldtrip/utilities/ft_trackusage.m, line 142, in ft_trackusage
  File /Users/nicolas/Toolboxes/fieldtrip/ft_defaults.m, line 279, in ft_defaults
Undefined variable "java" or class "java.net.InetAddress.getLocalHost".

Disabling tracking with ft_default.trackusage = 'no' solves the issue, but I guess this is something that could be done automatically.

EDIT: actually ft_default.trackusage = 'no' doesn't solve the issue, but commenting out ft_trackusage('startup'); in ft_defaults.m does.

Plot of ft_freqanalysis differ if cfg.keeptrials were set to 'yes' versus 'no'

According to the tutorial, it seems that I need to add

cfg.keeptrials = 'yes';

when calling ft_freqanalysis if I want to perform some statistics using ft_freqstatistics.

But I found that before I set keeptrials to 'yes' and after, the figure plotted via ft_singleplotTFR have much differences. Is that OK? Which should I believe to be true?

ft_volumelookup test script fails

@smg211 or @StolkArjen can you please fix it? Please try out the test script.

=== test_ft_volumelookup FAILED in 29 seconds
Error using ft_volumelookup (line 362)
Reference to non-existent field 'querymethod'.
Error in test_ft_volumelookup (line 43)

Function call chokes if cfg.tpm is given as cell array of strings

opts.tpm = ft_getopt(opts, 'tpm', spm_load_priors8(cfg.tpm));

This line expects a tpm structure in cfg.tpm and can't handle a cell array of strings. Therefore, one can only provide 4D NiFTIs and not single tpms. The latter results in:

Struct contents reference from a non-struct array object.

Error in spm_check_orientations (line 24)
dims = cat(1,V.dim);

Error in spm_load_priors8 (line 22)
spm_check_orientations(V);

Error in ft_volumesegment (line 437)
        opts.tpm      = ft_getopt(opts, 'tpm', spm_load_priors8(cfg.tpm));

...when calling it with cfg.spmversion = 'spm12'; cfg.spmmethod = 'new'. For the old segmentation it's done in line 389: cfg.tpm = ft_getopt(cfg, 'tpm'), without a call to spm_load_priors8, so there it works.

Undefined function or variable 'ismatch'

Dear fieldtrip team,

it seems between 03.09.18 and 05.09.18 my script broke when calling ft_definetrial. Matlab throws:

Undefined function 'ismatch' for input arguments of type 'char'.

Error in ft_trialfun_general (line 142)
    sel(i) = sel(i) && ismatch(event(i).type, cfg.trialdef.eventtype);

Error in ft_definetrial (line 178)
    [trl, event] = feval(cfg.trialfun, cfg);

After i rolled back to commit b8b4a8d the error was gone.
It might be linked to commit 1fdf13c which apparently changed the ismatch function?

All the best

ft_realtime_headlocalizer does not give expected visualization for elekta data

The following code does not result in the expected visualization. This relates to test_bug3375.m and http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=3375.

It seems that not all data objects are expressed in the same coordinate system.

cd(dccnpath('/home/common/matlab/fieldtrip/data/test/bug3375'));

cfg = [];
cfg.dataset = 'elekta/jn_multimodal_chpi_raw_sss.fif';
cfg.bufferdata = 'first';
cfg.headshape = 'elekta/strio_jn.mat';
ft_realtime_headlocalizer(cfg);

@simonhomoelle can you have a look?

Why does ft_read_sens('xxx.ds') by default return the electrode definition and not the gradiometers?

I am certain that it used to be the other way around; the default was to return the gradiometers. I've now twice enountered people who were expecting to get a gradiometer definition but instead got the electrodes out, and were confused about how their superimposed sourcemodel/volume conductor/sensor array plots looked.

Should we change the default back to returning the gradiometers?

See:

ft_warning('both electrode and gradiometer information is present, returning the electrode information by default');
senstype = 'eeg';

ft_appendsens and unique in CTF datasets

Hi all,

I'm trying to merge two-to-three CTF 275ch datasets into a single dataset for subsequent source localization. Using ft_appenddata, the data is merged, but the .grad and .label substructs are not. Therefore subsequent operations, namely lead fields for beamforming, fail. My workaround plan was to use ft_appendsens, to create the new .grad substructs, and insert them into the appended data structs.

In ft_appendsens, the line 165 error is thrown, when trying to compare unique(sens.chanpos, 'rows', 'stable' ) and unique(sens.label, 'stable'). In the function these are saved to chanidx and labidx respectively. This error is thrown as well when trying to ft_appendsens(cfg, data1), with a single freshly imported dataset argument, so the error is before append operations. The function won't work because the way it is checking each dataset for internal consistency results in failure.

The relevant lines are 149-165 in ft_appendsens.m

Applying unique(chanidx, 'row', 'stable') to a CTF275 dataset reduces the size from (302,3) to (285,3), which now mismatches with the labels of size (302,1). I believe that unique is causing a conflict with the fact that the ~27 reference channels (BG1 to R23) contain unique labels at the same physical positions in the reference array of a CTF MEG.

I had a look around at the subfields (and concatenations of subfields) of .grad and checking unique, but none would match the number of unique labels.

Am I doing something wrong, and/or this error is working as intended?

Thanks,
Matt

Use of isfolder before /compat/R2017b is added to path

if ~status && isfolder(prefix)

At the time when the /compat/* folders are added in ft_default lines 179-207, ft_hastoolbox may be called before /compat/R2017b/ had a chance to be added, such that isfolder is not yet known.

This happens for 2015b on Windows in ft_defaults line 196.
This happens for 2016b on Linux in ft_defaults line 198.

This leads to a silent error in ft_defaults (because it occurs in a try block) and isfolder remains unknown (leading to an error e.g. if you use ft_read_header).

[minor bug] private/rollback_provenance.m

Hello, I'm one of the fiedtrip user.

First, I would like to thank you for developing this open source.

I think it's a bug while using open source and I report it here.

When using the ft_prepare_mesh function with the downsample option, the function did not work.
I traced the reason and confirmed that smooth option is not rolled back properly after downsampling the data(In rollback_provenance.m at line 82).
In ft_prepare_mesh function, it is judged whether the smooth option is empty or not. In the rollback_provenance function, the smooth option is recorded as 'yes' or 'no'. This causes an error.

Thanks

Getting the coil-channel .tra matrix for the HCP-MEG preprocessed files

Moving a bugzilla item here for easier management:
http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=3298

We want to reconstruct separate matrices from the .tra matrix, with the help of the .balance field:

  • the sparse coil-channel correspondance matrix
  • the noise-compensation matrix applied by 4D acquisition system
  • the PCA/ICA cleaning procedures

In theory, this is possible with successive calls to ft_apply_montage(grad, grad.balance.(i), 'inverse', 'yes', 'keepunused', 'yes').

But in practice, it doesn't work because of multiple irregularities in the .grad.balance matrices:

  • The output channel units and types in transformation "pca" are set to "unknown"
  • Random naming chanunitorg/chanunitold fields
  • Channel types change randomly between "meg" (eg. pca) and "megmag" (eg. invcomp)

We would like to get clean code to import properly these HCP pre-processed files.

Attached: An example, based on subject 891667, script+data:
ft_hcp_issue.zip

ft_plot_slice shifts the volume a little bit

try this

mri.unit = 'cm';
mri.dim = [2 2 2];
mri.anatomy = ones(2,2,2);
mri.transform = eye(4);
mri.transform(1,4) = -1;
mri.transform(2,4) = -1;
mri.transform(3,4) = -1;

ft_determine_coordsys(mri);

ft_regressconfound does not deal with dimords correctly

source = [];
source.pos = randn(1000,1);
source.inside = true(1000,1);
source.pow = randn(1000,25);
source.dimord = 'pos_rpt';

cfg = [];
cfg.confound = randn(25,1);
source_cleaned = ft_regressconfound(cfg, source);

disp(source_cleaned);

yields:

       pos: [1000×1 double]
    inside: [1000×1 logical]
    dimord: 'pos_rpt'
       pow: [25×1000 double]
       cfg: [1×1 struct]

So clearly dimensions of pow have been swapped. I'll investigate whether a simple transpose or permute will do the trick, or whether actually the regression under the hood is faulty. Will also update test_ft_regressconfound accordingly.

new "isfolder" function not found when using Octave

When using Octave, running ft_version gives an error:

ft_version
error: 'isfolder' undefined near line 66 column 11
error: called from
    ft_version at line 66 column 9

This is the case even after running ft_defaults was run. Can it be that ft_defaults does not properly add the required directories from compat/ to the search path when using Octave?

See also https://travis-ci.org/nno/fieldtrip/jobs/393283620 with relevant snippet:

The command "TEST_TEST_CMD="ft_defaults;[unused,ft_path]=ft_version();mo_ft_path=fullfile(ft_path,'contrib','MOxUnit_fieldtrip');addpath(mo_ft_path);success=moxunit_runtests(fullfile(mo_ft_path,'tests'));exit(~success);";" exited with 0.
0.64s$ octave --eval "${TEST_TEST_CMD}"
octave: X11 DISPLAY environment variable not set
octave: disabling GUI features
warning: FieldTrip is not yet on your MATLAB path, adding /home/travis/build/nno/fieldtrip
warning: called from
    ft_defaults at line 109 column 3
warning: function /home/travis/build/nno/fieldtrip/external/signal/hanning.m shadows a core library function
warning: function /home/travis/build/nno/fieldtrip/external/stats/tinv.m shadows a core library function
warning: function /home/travis/build/nno/fieldtrip/external/stats/tcdf.m shadows a core library function
warning: function /home/travis/build/nno/fieldtrip/external/stats/finv.m shadows a core library function
warning: function /home/travis/build/nno/fieldtrip/external/stats/common_size.m shadows a core library function
warning: function /home/travis/build/nno/fieldtrip/external/stats/betainv.m shadows a core library function
warning: function /home/travis/build/nno/fieldtrip/external/stats/betapdf.m shadows a core library function
warning: function /home/travis/build/nno/fieldtrip/external/stats/binocdf.m shadows a core library function
warning: function /home/travis/build/nno/fieldtrip/external/stats/range.m shadows a core library function
warning: function /home/travis/build/nno/fieldtrip/external/stats/betacdf.m shadows a core library function
warning: function /home/travis/build/nno/fieldtrip/external/stats/binopdf.m shadows a core library function
warning: function /home/travis/build/nno/fieldtrip/external/images/rgb2hsv.m shadows a core library function
error: 'isfolder' undefined near line 66 column 11

ft_prepare_headmodel missing symbol

Hello all! I am running fieldtrip on a MacBook Pro Retina (2015) with El Capitan on Matlab R2017a. I installed Fieldtrip today (20/Sept/2018) and was going through the Beamformer tutorial (http://www.fieldtriptoolbox.org/tutorial/beamformer). When running ft_prepare_headmodel, I first got an error telling me to specify a tissue type. I did so by adding cfg.tissue = {'gray', 'white', 'csf'}; to my code. Then it ran for a bit before crashing with a message down the lines of... "Missing symbol '__Block_copy' required by" followed by lines and lines and lines of red MATLAB code that are similar to this:

'/System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio->/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis->/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices->/System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC->/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata->/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices->/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation->/Applications/MATLAB_R2017a.app/bin/maci64/libmwnativestrings.dylib->/Applications/MATLAB_R2017a.app/bin/maci64/libmwsettingscore.dylib->/Applications/MATLAB_R2017a.app/bin/maci64/libmwservices.dylib->/Applications/MATLAB_R2017a.app/bin/maci64/libmex.dylib->/Users/hectorOrozco/Documents/MATLAB/fieldtrip-20180919/external/spm8/spm_bwlabel.mexmaci64'
Missing symbol '__Unwind_Resume' required by

After this, the error output was: Error in volumethreshold (line 34)
[cluster, n] = spm_bwlabel(output, 6);

Error in prepare_mesh_segmentation (line 143)
seg = volumethreshold(seg, 0.5, tissue);

Error in ft_prepare_mesh (line 149)
bnd = prepare_mesh_segmentation(cfg, mri);

Error in ft_prepare_headmodel (line 341)
geometry = ft_prepare_mesh(tmpcfg, data);

Is there anything I can do about this? Did I miss any step on the tutorial? Let me know!

issue in multi-channel NIRS data tutorial

FieldTrip user "Sunny" reported this email:

Thanks a lot for providing us with fieldtrip which is really useful to analyze fNIRS data. I have an issue in the "Preprocessing and averaging of multi-channel NIRS data" tutorial. As I am unable to send my question in the email list, can you please help me with this issue?

Issue: In the "Preprocessing and averaging of multi-channel NIRS data tutorial " http://www.fieldtriptoolbox.org/tutorial/nirs_multichannel

The "Epoch" section consists of a variable "data_flt" which is not defined. Can you please inform what is this variable related to? as this is needed to complete my analysis.

Inconsistent behavior of tutorial and code

It seems that the tutorials and examples here are not consistent with the newest code. For example, I've tried to plot some ERPs with:

cfg.parameter = 'avg';

Then ft_singleplotER will complain that:

selecting these fields that have repetitions: trial
removing these fields that do not have repetitions: avg, dof, var
error using getdimord (line 19)
field "avg" not present in data

Then I found that, although ft_timelockanalysis returns the avg et al., if I need to perform baseline correction using ft_timelockbaseline, these fields will be removed. What's more, ft_singleplotER will remove them too. So why did ft_timelockanalysis calculate such useless fields?

I'm so confused about this, it seems that the order should be (according to tutorial):

  1. ft_preprocessing, segmentation,
  2. ft_timelockanalysis, calculate average et al.
  3. ft_timelockbaseline, remove average et al., without calculate average,
  4. ft_singleplotER, remove average et al. if exist, re-calculate and plot.

But results from ft_timelockanalysis were removed and never be used again; ft_timelockbaseline's result differs from result of ft_timelockanalysis, none of a final result were used in ft_singleplotER...
If I need the average and variance, I'll have to calculate them myself (because ft_timelockbaseline do not have them)...

I though it should be:

  1. preprocessing and segmentation;
  2. baseline correction;
  3. averaging;
  4. plot

But perhaps I made some mistake or misunderstand fieldtrip, I don't know how to do this correctly. Can anybody show me the correct way to do this?

ft_read_cifti fails in MATLAB R2017b & R2015b

Hi,

I found the ft_read_cifti would fail in both matlab R2017b and R2015b.
I have tried your newest release (by copy the newest ft_read_cifti and all its dependency to my project folder), it also has the same problem.
Here is the error message:

Cell contents indices must be greater than 0

Error in xml_parser>tag_element (line 227)
       xtree{Xparse_count} = element;

Error in xml_parser>compile (line 199)
                           frag = tag_element(frag);

Error in xml_parser (line 134)
tree = compile(tree);

Error in xmltree (line 41)
               tree.tree = xml_parser(varargin{1});

Error in ft_read_cifti (line 149)
tree = xmltree(xmldata);

Error in extract_signal (line 26)
x = ft_read_cifti('example.dlabel.nii', 'mapname', 'array');

Can anyone help?
Thank you very much!

Inaccuracy in comments in fieldtrip/realtime/src/acquisition/ctf/ctf.h

In fieldtrip/realtime/src/acquisition/ctf/ctf.h it says that the buffer size to use depends on the ctf software version:

"The ACQ_BUFFER_SIZE should be set to 28160 for older acquisition software and to 40000
for newer (beta) versions of the acquisition software from approximately 2016 onwards.
See also http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=3185"

In contrast, in the comment 7 of Bugzilla – Bug 3185 it says that: " I have some updates on the situation. CTF have pointed out that the size of the buffer has changed with the 3000 series electronics."

Thus, sites with the old series 2000 electronics but the new software should use the old buffer size, contrary to what the comment in the code implies. IMHO "acquistion software" should be replaced by "acquisition electronics", shouldn't it?

Michael

small bug in eLoreta

On 14 Aug 2018, at 16:42, Guido Nolte wrote:

... there is a bug in the code for eLoreta (which he downloaded from fieldtrip). The effect is extremely tiny (new and old solutions are identical by about 11 digits) but I still decided to correct it. The issue was the stopping criterion: rather than checking whether the solution converged for all voxels, I only looked at the last voxel. (That was not intended, just a mistake). In any event, I attached the new code if you want to replace it.

qsubfeval extremely slow

I have tracked down an issue with qsubfeval I have been experiencing on our torque cluster for a while now. The 'problem' is, that if I call qsubfeval in a for-loop, each of the iterations sometimes takes about 5 seconds to run, making this a very impractical strategy to deploy many jobs from within an interactive matlab session.

I found out that virtually all time is spent in MATLAB's built-in system() function, while all that this intends to do is to echo a long string to the command line.

I found an overloaded version of system(), called jsystem on github. This function is released under the MIT license.

https://github.com/avivrosenberg/matlab-jsystem/

Would it be an idea to replace the system()-calls with this >10 fold faster version (at least this was the speed up that I got in my interactive matlab session on c012)

incorrect link in warning message

using ft_readheader on neuralynx data I got the warning:
Warning: the NEURALYNX_V3 toolbox is not installed, see
http://neuralynx.com/research_software/file_converters_and_utilities/ and take the version from
Ueli Rutishauser

The provided address did not work, the software is now found at:
https://neuralynx.com/software/nlx-to-matlab-import-export-mex-files-for-linux-and-mac-os-x

Downloading this and adding a path the the precompiled resolved the warning. I didn't need to compile my own running matlab R2018a on red hat.

ft_freqstatistics for EEG data (cluster correction)

Hi,
I would like to use the Fieldtrip function ft_freqstatistics to perform cluster statistics at the channel level on frequency-resolved (but not time-resolved) EEG data (63 channels), comparing 2 conditions. For each participant and condition the data have the following size: 63x2x20 (channels/time/frequency). When I run the process, even with only 2 participants (and 100 permutations), I obtain after 2 minutes a Java exception (OutOfMemoryError).
I run the process on a mac book pro 2016 (3,1 GHz Intel Core i7). I have a java heap size of 4,096MB on MATLAB.
This exception does not occur if I use another type of correction (bonferroni, fdr...).

Might you please help me to resolve this issue ?
Please find enclosed the input data (cfg = statcfg, and the 2*2 (2 participants * 2 conditions) data = ftAllFiles): thedata.mat.zip

thank you,
Benjamin Morillon

ps: the info appearing on the Matlab screen when I run the process:
the call to "ft_selectdata" took 0 seconds and required the additional allocation of an estimated 9 MB
using "ft_statistics_montecarlo" for the statistical testing
using "ft_statfun_depsamplesT" for the single-sample statistics
constructing randomized design
total number of measurements = 4
total number of variables = 2
number of independent variables = 1
number of unit variables = 1
number of within-cell variables = 0
number of control variables = 0
using a permutation resampling approach
repeated measurement in variable 2 over 2 levels
number of repeated measurements in each level is 2 2
computing a parametric threshold for clustering
computing statistic
estimated time per randomization is 0.07 seconds
computing statistic 100 from 100

Conversion from source to volume representation depends on order of .pos field

Whereas I think the documentation suggests that the source representation can be anything irregular. The following demonstrates this forcefully:

load(fullfile('~/repos/fieldtrip/template/sourcemodel/standard_sourcemodel3d8mm.mat'),...
  'sourcemodel');

source = sourcemodel;
source.data = 1:size(source.pos, 1);

vol1 = ft_checkdata(source, 'datatype', 'volume');

inds = randperm(numel(source.inside));
source.data = source.data(inds);
source.pos = source.pos(inds,:);
source.inside = source.inside(inds);

vol2 = ft_checkdata(source, 'datatype', 'volume');

isequaln(vol1.data, vol2.data)

Should we either (1) fix the code such that the order of .pos does not matter; or (2) document this somewhere, and perhaps check various places in the code to make sure that toggling between source and volume nowhere violates the conditions required for a consistent switch (not sure what those conditions are yet)?

eyelink import with '.' values

Hi

i looked at your code for the eyelink import to improve my own eyelink function. I think I may have found a bug.

If a data line in the .asc file looks like this:

4491234 . . 0.0 736.0 482.0 5990.0 32768.0 .C...

sscanf will produce a vector like this:

[4491234]

Therefore i suggest to replace the line from

tmp = sscanf(tline, '%f');
with something like this:

tmp = sscanf(strrep(tline, ' . ', ' NaN '), '%f');

This would then produce a vector like this:

[4491234 NaN NaN 0 736 482 5990 32768]

(haven't tested it)

best
Tobias

tal2mni.m outputs odd MNI coordinates

Hello,

I tried running tal2mni on a single set of Talairach coordinates, using the following command:
tal2mni([-1 -32 58]) and got the following output:
-1.0101 -35.9369 61.2263, which seem like improper MNI coordinates (in the sense that I was expecting integers rather than decimals). Is there something wrong in how I'm passing the Talairach coordinates into the function?

If it's the case that this is correct (i.e. the best approximation) would it make sense to round these numbers (i.e. -1 -36 61)?

Thank you.

Dan

Using ft_read_mri to read .mnc (minc) files requires SPM2 or SPM5 toolbox

When using ft_read_mri to read .mnc (minc) files, error in MATLAB pops up saying that it requires SPM2 or SPM5 toolbox. But, in the latest fieldtrip toolbox, only SPM8 and SPM12 toolboxes are installed. Could you please fix this bug and let me know at [email protected]?

Installing SPM2 does not solve the problem since one program is compatible for SPM2 and another is compatible for SPM12. So it just gives errors even after downloading SPM2. The following error shows in MATLAB after downloading SPM2.

"Dot indexing is not supported for variables of
this type.

Error in spm_read_vols (line 26)
if any(any(any(diff(cat(3,V.mat),1,3),3)))

Error in ft_read_mri (line 147)
img = spm_read_vols(hdr);"

Thanks.

Anup

Computing 1020 electrode positions on unit sphere.

Since reading @robertoostenveld's article on the 5% system for electrode positioning in EEG, I was a bit curious how the xyz coordinates on the unit sphere (for plotting) supplied with the blog post were actually computed. I have found the code here and the main functions seem to be (please correct me if I am wrong):

  • elec1020_locate, which locates the positions of electrodes on contours (arcs drawn across the surface of a unit sphere) ... crucially, elec_1020 calls the following two functions:
  • elec1020_follow, which draws the contour between two points
  • elec1020_fraction, which finds a point on the countour at a fraction of the complete distance of the contour/arc

The code is a bit hard for me to understand and I would be very glad to receive a pointer to literature about the method/procedure to find these contours and compute positions along fractions of the contour.

What I have found so far are the "Great Circle Distance" and a brief reference to a method, to compute points at fractions of the Great Circle Distance. However my initial attempts at this were not fruitful, and the methods are often rather working with latitude and longitude (and geolocation) ... so I hope to receive some further hints here.

Thanks!

Allow plotting of multiple channels using ft_singleplotER

As it came up in the NIRS hackathon, hereby a request to have the channel averaging in ft_singleplotER optional, i.e. as a cfg-field (could e.g. be done analogue to ft_databrowser with cfg.viewmode = 'butterfly' or 'average' or 'vertical', where 'average' is the default). I see several ways this could be implemented, but all of them require a substantial amount of work (given the small added feature), and would therefore categorize this as a 'mid effort, low priority' (for NIRS users it is probably high priority). Note that someone of us here might pick this up in future if not being worked on from your side (over the next 2 years I have to say).

ft_nirs_scalpcouplingindex should output SCI values

This issue was identified and dicussed at the NIRS hackathon.

We (i.e. @robertoostenveld @jooweg, @marcvanwanrooij, @jannystapel) think that it is better to have ft_nirs_scalpcouplingindex output the SCI, then have the user make an explicit decision (e.g. after plotting) and then use ft_rejectartifact to remove the channels - or to replace the value in the channels with nans.

The nan filling would be useful for subsequent group statistics, where each subject may have different bad channels. The range of SCI values themselves would be interesting to report in papers.

Error running ft_qualitycheck

Running the following code will lead to an error

cfg = [];
cfg.dataset = 'task1.vhdr';
[info, timelock, freq, summary] = ft_qualitycheck(cfg);

After several minutes, matlab complained

Undefined function or variable 'headpos'

Then I looked into the source code, and found that this error is due to

Reference to non-exist field 'dataset'

at line 421 of ft_qualitycheck

I manually add this field to timelock.cfg, the code can run without error, but with a strange report:

task1

Did I mess up something?

Wrong leadfields with OpenMEEG 2.4

I ran into an issue recently when I set up a new computer to enlarge my database:
The EEG-leadfields fieldtrip produces with OpenMEEG 2.4 are different and wrong. I exchanged the binaries on 2 laptops to invesitagte this and found out, that 2.2. and 2.1 produce matching leadfields on both, but not with 2.4. Together with Maureen Clerc from OpenMEEG we found out that the sensor interpolations within forward/ft_prepare_vol_sens.m are the problem: openmeeg/openmeeg#264.
I also added a pull request (Adopt to OpenMEEG 2.4 #673) that solved this issue for me.

missing accurate coil defs for Elekta T3-magnetometers

The mne matlab toolbox bundled with FT is missing the 'accurate' integration points for Elekta type T3 magnetometers. Compare this

1 3024 2 4 2.100e-02 0.000e+00 "Vectorview magnetometer T3 size = 21.00 mm"

to mne-python and brainstorm3 (FYI: @ftadel)

What started me off down this route was coming across the function fix_mag_coil_types (see docstring for more context). We've had a Triux since 2010, and several DACQ updates since: our magnetometers are still defined as type T1 (3022) instead of T3 (3024). I believe this is the case at all Elekta sites, unless the local admin has changed collector.pos to reflect reality. I've been in touch with Elekta, and they've started an internal process to change the header definitions for the next DACQ release. They also ran some tests, and found the potential errors in forward modeling to be insignificant at realistic source-to-sensor distances. This is consistent with both @agramfort @larsoner et al.'s comments in their code, and @sarangnemo 's beamformer testing (CC: @britta-wstnr). FYI Elekta software does a hack by checking the magnetometer calibration values, and 'fixes' T1 to T3 if the value is above a (heuristic) threshold.

In conclusion, fixing coil_def.dat in FT will bring the three packages mentioned above to parity. Dealing with data files with potentially erroneous coil type defs is another matter, but nothing to get too worked up about, it seems.

ft_version fails and goes into infinite loop

this is a pretty specific problem but figured it might be helpful to share:

I clone FT from github some time ago, and I recently updated osx and it somehow erased command line tools, including git. As such, when ft_defaults is executed, ft_version is called, which triggers a warning at line 105 here (in ft_version):

image

ft_warning, in turn, triggers the start of another loop which calls ft_version, and so on and so forth, creating an infinite loop with no user feedback.

This is a rare and specific edge case where git should be there but is not, and is easy to fix as the user (once the problem is tracked down). But perhaps ft_warning should not be able to trigger an infinite loop?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.