[FieldTrip] Errors with downsampling and artifact rejection

Gaëlle Leys gaelle.leys at kuleuven.be
Mon Jun 29 10:58:48 CEST 2020


Dear Stephen, 

The downsampling works with 200 or 250Hz!
As for the artifact rejection, changing the settings to what you suggested and working with the downsampled data solved all the errors that I was getting. 

Thanks for the help!

Kind regards, 
Gaëlle Leys


-----Original Message-----
From: fieldtrip <fieldtrip-bounces at science.ru.nl> On Behalf Of fieldtrip-request at science.ru.nl
Sent: dinsdag 23 juni 2020 12:00
To: fieldtrip at science.ru.nl
Subject: fieldtrip Digest, Vol 115, Issue 24

Send fieldtrip mailing list submissions to
	fieldtrip at science.ru.nl

To subscribe or unsubscribe via the World Wide Web, visit
	https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
or, via email, send a message with subject or body 'help' to
	fieldtrip-request at science.ru.nl

You can reach the person managing the list at
	fieldtrip-owner at science.ru.nl

When replying, please edit your Subject line so it is more specific
than "Re: Contents of fieldtrip digest..."


Today's Topics:

   1. Re: Running out of memory (RAM) (Eelke Spaak)
   2. Connectivity Dimensions (Michael Glassen  -  Biomedical Engineer)
   3. Re: Connectivity Dimensions (Schoffelen, J.M. (Jan Mathijs))
   4. Re: Errors with downsampling and artifact rejection (Gaëlle Leys)
   5. Re: Errors with downsampling and artifact rejection
      (Stephen Whitmarsh)
   6. Re: fieldtrip Digest, Vol 115, Issue 23 (Andrade Rey René)
   7. Re: Errors with downsampling and artifact rejection
      (Schoffelen, J.M. (Jan Mathijs))


----------------------------------------------------------------------

Message: 1
Date: Mon, 22 Jun 2020 15:27:19 +0200
From: Eelke Spaak <e.spaak at donders.ru.nl>
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] Running out of memory (RAM)
Message-ID:
	<CABPNLUqmPjmyXR4gbRG3y-MLf97-SPGnRA+zp=SA4TBkCOugzw at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Dear Andrade,

You could have a look here for some tips on memory efficiency:
http://www.fieldtriptoolbox.org/tutorial/memory/ Probably most relevant to
you: change the data precision to single, rather than double (saves ~50%).

Best,
Eelke

On Sun, 21 Jun 2020 at 22:34, Andrade Rey René <rene.andrade at edu.uah.es>
wrote:

> Dear experts:
> I am running this code
>
> cfg = [];cfg.headmodel = headmodel;cfg.sourcemodel = leadfield;cfg.method = 'lcmv';cfg.lcmv.projectmom = 'yes'; % project dipole time series in direction of maximal power (see below)cfg.lcmv.kurtosis = 'yes'; % compute kurtosis at each locationsource = ft_sourceanalysis(cfg, cov_matrix);
>
>
> Of http://www.fieldtriptoolbox.org/tutorial/epilepsy/. And I think  I run
> out of memory because with “top” I can see the computer stops responding
> when near 85% of RAM memory(16GB).
>
> I cannot report any error because the only problem seems to be that either
> wrong code or wrong data or I don’t know.
>
> Best,
> Andrade.
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200622/58106b35/attachment-0001.htm>

------------------------------

Message: 2
Date: Mon, 22 Jun 2020 13:47:14 +0000
From: "Michael Glassen  -  Biomedical Engineer"
	<MGlassen at kesslerfoundation.org>
To: "fieldtrip at science.ru.nl" <fieldtrip at science.ru.nl>
Subject: [FieldTrip] Connectivity Dimensions
Message-ID: <aae7aaea206143f3a87df61e1478a883 at kesslerfoundation.org>
Content-Type: text/plain; charset="iso-8859-1"

Hi all,


I was looking to make some plots of directional connectivity data obtained from ft_connectivityanalysis, and I just wanted to double check the dimensions of pdcspctrm and dtfspctrm.


The dimord is 'chan_chan_freq_time', but there isn't any indication of which chan dimension is the from direction and which is the to direction. I tried piecing it together by using ft_connectivityplot and comparing these to my own plots, and I'm pretty sure that the dimensions are 'fromchan_tochan_freq_time' but I wanted to get confirmation before I moved forward.


Best,

Michael Glassen

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200622/5abef647/attachment-0001.htm>

------------------------------

Message: 3
Date: Mon, 22 Jun 2020 13:52:32 +0000
From: "Schoffelen, J.M. (Jan Mathijs)" <jan.schoffelen at donders.ru.nl>
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] Connectivity Dimensions
Message-ID: <B6521FD0-2B75-4E0B-AF0C-68CDF3CB411B at donders.ru.nl>
Content-Type: text/plain; charset="utf-8"

Dear Michael,

Consider it confirmed!

Best wishes,
JM


On 22 Jun 2020, at 15:47, Michael Glassen - Biomedical Engineer <MGlassen at kesslerfoundation.org<mailto:MGlassen at kesslerfoundation.org>> wrote:

Hi all,

I was looking to make some plots of directional connectivity data obtained from ft_connectivityanalysis, and I just wanted to double check the dimensions of pdcspctrm and dtfspctrm.

The dimord is 'chan_chan_freq_time', but there isn't any indication of which chan dimension is the from direction and which is the to direction. I tried piecing it together by using ft_connectivityplot and comparing these to my own plots, and I'm pretty sure that the dimensions are 'fromchan_tochan_freq_time' but I wanted to get confirmation before I moved forward.

Best,
Michael Glassen

  ­­   _______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200622/f18ccfbb/attachment-0001.htm>

------------------------------

Message: 4
Date: Mon, 22 Jun 2020 14:47:00 +0000
From: Gaëlle Leys <gaelle.leys at kuleuven.be>
To: "fieldtrip at science.ru.nl" <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] Errors with downsampling and artifact
	rejection
Message-ID:
	<a967d7106acf41d182449785c9466db7 at ICTS-S-EXMBX17.luna.kuleuven.be>
Content-Type: text/plain; charset="utf-8"

Dear Stephen, 

I have included the data structures and cfg's involved in the functions.

1)	A. data structure for resampling data (raw data after reading it in):
data_eeg = 
  struct with fields:
hdr: [1×1 struct]
label: {129×1 cell}
time: {[1×245726 double]}
trial: {[129×245726 double]}
fsample: 1000
sampleinfo: [1 245726]
elec: [1×1 struct]
cfg: [1×1 struct]

1)	B. cfg for resampling data (I’m using all the default options for resampling):

Cfg=[];
[data_eeg] = ft_resampledata(cfg, data_eeg); % defaults are all OK

2)	A. data structure for artifact rejection (my data already epoched):
data_eeg = 
struct with fields:
hdr: [1×1 struct]
label: {129×1 cell}
 time: {1×108 cell}
 trial: {1×108 cell}
 fsample: 1000
 sampleinfo: [108×2 double]
 elec: [1×1 struct]
 cfg: [1×1 struct]


2)	B. cfg for artifact rejection (taken from the automatic artifact rejection example):
% jump
cfg = [];
cfg.trl = trl;
cfg.datafile = '100_1_20200305.mff';
cfg.headerfile = '100_1_20200305.mff';
cfg.continuous = 'yes';
 
% channel selection, cutoff and padding
cfg.artfctdef.zvalue.channel = 'EEG';
cfg.artfctdef.zvalue.cutoff = 20;
cfg.artfctdef.zvalue.trlpadding = 0;
cfg.artfctdef.zvalue.artpadding = 0;
cfg.artfctdef.zvalue.fltpadding = 0;
 
% algorithmic parameters
cfg.artfctdef.zvalue.cumulative = 'yes';
cfg.artfctdef.zvalue.medianfilter = 'yes';
cfg.artfctdef.zvalue.medianfiltord = 9;
cfg.artfctdef.zvalue.absdiff = 'yes';
 
% make the process interactive
cfg.artfctdef.zvalue.interactive = 'yes';
 
[cfg, artifact_jump] = ft_artifact_zvalue(cfg); %plot error and error using zeros
%[cfg, artifact_jump] = ft_artifact_zvalue(cfg, data_eeg); %no plot error, but each trial has the same graph, also error using zeros


Kind regards, 
Gaëlle Leys



-----Original Message-----
From: fieldtrip <fieldtrip-bounces at science.ru.nl> On Behalf Of fieldtrip-request at science.ru.nl
Sent: zaterdag 20 juni 2020 12:00
To: fieldtrip at science.ru.nl
Subject: fieldtrip Digest, Vol 115, Issue 22

Send fieldtrip mailing list submissions to
	fieldtrip at science.ru.nl

To subscribe or unsubscribe via the World Wide Web, visit
	https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
or, via email, send a message with subject or body 'help' to
	fieldtrip-request at science.ru.nl

You can reach the person managing the list at
	fieldtrip-owner at science.ru.nl

When replying, please edit your Subject line so it is more specific than "Re: Contents of fieldtrip digest..."


Today's Topics:

   1. Errors with downsampling and artifact rejection (Gaëlle Leys)
   2. Re: Errors with downsampling and artifact rejection
      (Stephen Whitmarsh)
   3. MNI coordinates for the EEG easycap-M1 layout
      (SILVA PEREIRA, SILVANA)


----------------------------------------------------------------------

Message: 1
Date: Fri, 19 Jun 2020 12:48:26 +0000
From: Gaëlle Leys <gaelle.leys at kuleuven.be>
To: "fieldtrip at science.ru.nl" <fieldtrip at science.ru.nl>
Subject: [FieldTrip] Errors with downsampling and artifact rejection
Message-ID:
	<ccb89b4d31af42d3b4cd22485438f4ef at ICTS-S-EXMBX17.luna.kuleuven.be>
Content-Type: text/plain; charset="iso-8859-1"

Dear Fieldtrip community,

I have recently started with Fieldtrip for my EEG data processing and I am encountering some problems which I can't seem to resolve.
I'm working with mff files from an EGI EEG system. I have no problem reading in and preprocessing the data. However, when trying to downsample and setup the automatic artifact removal, I'm getting some errors.


1)      When trying to downsample with the default options, these are the errors that I get:
Error using resample>getSamples (line 357) The number of elements of Tx must match the number of rows of X when X is a matrix

Error in resample>nonUniformResample (line 123) [x, tx] = getSamples(varargin{1:2});

Error in resample (line 116)
  [varargout{1:max(1,nargout)}] = nonUniformResample(method,varargin{:});

Error in ft_resampledata (line 228)
        newdat = transpose(resample(transpose(olddat),fsres,fsorig));

                I have tried downsampling before filtering, after filtering, on continuous data, or already segmented data. None of these things seem to resolve the error.


2)      When trying to set up the automatic artifact removal process and choosing yes for the interactive plot, I get a plotting error:

Error using plot

Vectors must be the same length.



Error in ft_artifact_zvalue>redraw_cb (line 973)

    plot(opt.h1, xval, yval, 'linestyle', '-', 'color', 'b', 'displayname', 'data');



Error in ft_artifact_zvalue (line 512)

  redraw_cb(h);

        I've noticed that the xval and yval are different numbers, which of course doesn't allow plotting. It seems like the xval changes according to the epoch length, however the yval remains the same and equals the amount of samples in my continuous data.


3)      When choosing no for the interactive plot, I also get an error:
Error using zeros
Size inputs must be integers.

Error in ft_artifact_zvalue (line 568)
dum = zeros(1,max(opt.trl(:,2)));

I've been looking into the functions and where it goes wrong, but I can't seem to pinpoint what exactly is causing these issues. Anyone here that can help or provide me some tips?

Thanks in advance!

Kind regards,

Gaëlle Leys

Research Associate
Brain & Cognition
Tiensestraat 102 box 3714
3000 Leuven
Room PSI 02.33
tel. +32 16 37 61 98

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200619/e7e1bde8/attachment-0001.htm>

------------------------------

Message: 2
Date: Fri, 19 Jun 2020 15:08:21 +0200
From: Stephen Whitmarsh <stephen.whitmarsh at gmail.com>
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] Errors with downsampling and artifact
	rejection
Message-ID:
	<CAFrxm=w44QZ0C7xB4cpsqdy0D0ou5UcpHNM-q3bjyaqwwJxRwg at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Dear Gaëlle,

To understand the problem it would be helpful to have 1) description of the data structures going in ft_resampledata (just type in command line and copy-paste the output) and the artefact detection function you are using, and 2) the configuration (cfg) you are using for those functions.

Cheers,
Stephen


Op vr 19 jun. 2020 om 14:56 schreef Gaëlle Leys <gaelle.leys at kuleuven.be>:

> Dear Fieldtrip community,
>
>
>
> I have recently started with Fieldtrip for my EEG data processing and 
> I am encountering some problems which I can’t seem to resolve.
>
> I’m working with mff files from an EGI EEG system. I have no problem 
> reading in and preprocessing the data. However, when trying to 
> downsample and setup the automatic artifact removal, I’m getting some errors.
>
>
>
> 1)      When trying to downsample with the default options, these are the
> errors that I get:
>
> Error using resample>getSamples (line 357)
>
> The number of elements of Tx must match the number of rows of X when X 
> is a matrix
>
>
>
> Error in resample>nonUniformResample (line 123)
>
> [x, tx] = getSamples(varargin{1:2});
>
>
>
> Error in resample (line 116)
>
>   [varargout{1:max(1,nargout)}] = 
> nonUniformResample(method,varargin{:});
>
>
>
> Error in ft_resampledata (line 228)
>
>         newdat = transpose(resample(transpose(olddat),fsres,fsorig));
>
>
>
>                 I have tried downsampling before filtering, after 
> filtering, on continuous data, or already segmented data. None of 
> these things seem to resolve the error.
>
>
>
> 2)      When trying to set up the automatic artifact removal process and
> choosing yes for the interactive plot, I get a plotting error:
>
> Error using plot
>
> Vectors must be the same length.
>
>
>
> Error in ft_artifact_zvalue>redraw_cb (line 973)
>
>     plot(opt.h1, xval, yval, 'linestyle', '-', 'color', 'b', 
> 'displayname', 'data');
>
>
>
> Error in ft_artifact_zvalue (line 512)
>
>   redraw_cb(h);
>
>
>
>         I’ve noticed that the xval and yval are different numbers, 
> which of course doesn’t allow plotting. It seems like the xval changes 
> according to the epoch length, however the yval remains the same and 
> equals the amount of samples in my continuous data.
>
>
>
> 3)      When choosing no for the interactive plot, I also get an error:
>
> Error using zeros
>
> Size inputs must be integers.
>
>
>
> Error in ft_artifact_zvalue (line 568)
>
> dum = zeros(1,max(opt.trl(:,2)));
>
>
>
> I’ve been looking into the functions and where it goes wrong, but I 
> can’t seem to pinpoint what exactly is causing these issues. Anyone 
> here that can help or provide me some tips?
>
>
>
> Thanks in advance!
>
>
>
> Kind regards,
>
>
>
> Gaëlle Leys
>
>
>
> Research Associate
> Brain & Cognition
> Tiensestraat 102 box 3714
> 3000 Leuven
>
> Room PSI 02.33
> tel. +32 16 37 61 98
>
>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200619/137e31b1/attachment-0001.htm>

------------------------------

Message: 3
Date: Fri, 19 Jun 2020 18:58:36 +0200
From: "SILVA PEREIRA, SILVANA" <silvana.silva at upf.edu>
To: fieldtrip at science.ru.nl
Subject: [FieldTrip] MNI coordinates for the EEG easycap-M1 layout
Message-ID:
	<CA+_MWm1NufDWa-fjR71OzQ5ab88ioyUT8OJ-QFYX9ABr7gNQrA at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Dear community,

I've been struggling to find the 3D positions (montages) for the
Acticap-64ch-standard2 on the web, which is a modified version of the easycap-M1, but I have not succeeded. In the Fieldtrip page http://www.fieldtriptoolbox.org/template/electrode/ you have the following:

You can find the template 3-D electrode sets included in FieldTrip here <https://github.com/fieldtrip/fieldtrip/tree/master/template/electrode>.

But in that link you only find a txt file with theta-phi coordinates (easycap-M1.txt). Is there any place where I could find these positions in MNI space?

Thank you and best regards,
Silvana
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200619/c0adf7df/attachment-0001.htm>

------------------------------

Subject: Digest Footer

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202


------------------------------

End of fieldtrip Digest, Vol 115, Issue 22
******************************************



------------------------------

Message: 5
Date: Mon, 22 Jun 2020 17:35:42 +0200
From: Stephen Whitmarsh <stephen.whitmarsh at gmail.com>
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] Errors with downsampling and artifact
	rejection
Message-ID:
	<CAFrxm=wFXM-y1XBHbrVCTPwgjD2OWSG0c3Wx+v=Roiy7dprdPA at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Dear Gaëlle,

You are using default settings for downsampling, which will then try to
downsample to 256Hz. Your original samplerate is 1000Hz, so that isn't a
neat integer division.
I tried the following, and could reproduce your problem:

Fs = 1000;
data_eeg = [];
data_eeg.label = {'a','b','c'};
data_eeg.time{1} = 0:1/Fs:10;
data_eeg.trial{1} = rand(length(data_eeg.label),length(data_eeg.time{1}));
data_eeg.Fs = Fs;
data_eeg.sampleinfo = [1, length(data_eeg.time{1})];

% Doesn't work:
cfg = [];
[data_eeg] = ft_resampledata(cfg, data_eeg);

% Does work:
cfg = [];
cfg.resamplefs = 250;
[data_eeg] = ft_resampledata(cfg, data_eeg);

So that deals with your first problem. Not sure why it has a problem with
the downsampling to non-integer values, but it's good practice and much
faster to stick to that anyway.

Not sure what to do with the artefact detection though, or what you
expect;  it seems you are running it with some contradictory settings/ways
perhaps:
- use cfg.dataset if reading from disk directly OR give datastructure to
function is you already have data in memory
- use cfg.continuous when data is not segmented
- the comment "jump" suggests you use settings for SQUID jumps, i.e.
optimized for MEG, but that should not give an error :-)

I suspect you probably want to run artefact detection on your
segmented data, so remove those references to the data on disk (datafile,
headerfile), and the trl from the cfg, and give your segmented data as an
argument as you did here:
%[cfg, artifact_jump] = ft_artifact_zvalue(cfg, data_eeg); %no plot error,
but each trial has the same graph, also error using zeros

Let us know how it goes,

All the best,
Stephen











Op ma 22 jun. 2020 om 17:02 schreef Gaëlle Leys <gaelle.leys at kuleuven.be>:

> Dear Stephen,
>
> I have included the data structures and cfg's involved in the functions.
>
> 1)      A. data structure for resampling data (raw data after reading it
> in):
> data_eeg =
>   struct with fields:
> hdr: [1×1 struct]
> label: {129×1 cell}
> time: {[1×245726 double]}
> trial: {[129×245726 double]}
> fsample: 1000
> sampleinfo: [1 245726]
> elec: [1×1 struct]
> cfg: [1×1 struct]
>
> 1)      B. cfg for resampling data (I’m using all the default options for
> resampling):
>
> Cfg=[];
> [data_eeg] = ft_resampledata(cfg, data_eeg); % defaults are all OK
>
> 2)      A. data structure for artifact rejection (my data already epoched):
> data_eeg =
> struct with fields:
> hdr: [1×1 struct]
> label: {129×1 cell}
>  time: {1×108 cell}
>  trial: {1×108 cell}
>  fsample: 1000
>  sampleinfo: [108×2 double]
>  elec: [1×1 struct]
>  cfg: [1×1 struct]
>
>
> 2)      B. cfg for artifact rejection (taken from the automatic artifact
> rejection example):
> % jump
> cfg = [];
> cfg.trl = trl;
> cfg.datafile = '100_1_20200305.mff';
> cfg.headerfile = '100_1_20200305.mff';
> cfg.continuous = 'yes';
>
> % channel selection, cutoff and padding
> cfg.artfctdef.zvalue.channel = 'EEG';
> cfg.artfctdef.zvalue.cutoff = 20;
> cfg.artfctdef.zvalue.trlpadding = 0;
> cfg.artfctdef.zvalue.artpadding = 0;
> cfg.artfctdef.zvalue.fltpadding = 0;
>
> % algorithmic parameters
> cfg.artfctdef.zvalue.cumulative = 'yes';
> cfg.artfctdef.zvalue.medianfilter = 'yes';
> cfg.artfctdef.zvalue.medianfiltord = 9;
> cfg.artfctdef.zvalue.absdiff = 'yes';
>
> % make the process interactive
> cfg.artfctdef.zvalue.interactive = 'yes';
>
> [cfg, artifact_jump] = ft_artifact_zvalue(cfg); %plot error and error
> using zeros
> %[cfg, artifact_jump] = ft_artifact_zvalue(cfg, data_eeg); %no plot error,
> but each trial has the same graph, also error using zeros
>
>
> Kind regards,
> Gaëlle Leys
>
>
>
> -----Original Message-----
> From: fieldtrip <fieldtrip-bounces at science.ru.nl> On Behalf Of
> fieldtrip-request at science.ru.nl
> Sent: zaterdag 20 juni 2020 12:00
> To: fieldtrip at science.ru.nl
> Subject: fieldtrip Digest, Vol 115, Issue 22
>
> Send fieldtrip mailing list submissions to
>         fieldtrip at science.ru.nl
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> or, via email, send a message with subject or body 'help' to
>         fieldtrip-request at science.ru.nl
>
> You can reach the person managing the list at
>         fieldtrip-owner at science.ru.nl
>
> When replying, please edit your Subject line so it is more specific than
> "Re: Contents of fieldtrip digest..."
>
>
> Today's Topics:
>
>    1. Errors with downsampling and artifact rejection (Gaëlle Leys)
>    2. Re: Errors with downsampling and artifact rejection
>       (Stephen Whitmarsh)
>    3. MNI coordinates for the EEG easycap-M1 layout
>       (SILVA PEREIRA, SILVANA)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 19 Jun 2020 12:48:26 +0000
> From: Gaëlle Leys <gaelle.leys at kuleuven.be>
> To: "fieldtrip at science.ru.nl" <fieldtrip at science.ru.nl>
> Subject: [FieldTrip] Errors with downsampling and artifact rejection
> Message-ID:
>         <ccb89b4d31af42d3b4cd22485438f4ef at ICTS-S-EXMBX17.luna.kuleuven.be>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Dear Fieldtrip community,
>
> I have recently started with Fieldtrip for my EEG data processing and I am
> encountering some problems which I can't seem to resolve.
> I'm working with mff files from an EGI EEG system. I have no problem
> reading in and preprocessing the data. However, when trying to downsample
> and setup the automatic artifact removal, I'm getting some errors.
>
>
> 1)      When trying to downsample with the default options, these are the
> errors that I get:
> Error using resample>getSamples (line 357) The number of elements of Tx
> must match the number of rows of X when X is a matrix
>
> Error in resample>nonUniformResample (line 123) [x, tx] =
> getSamples(varargin{1:2});
>
> Error in resample (line 116)
>   [varargout{1:max(1,nargout)}] = nonUniformResample(method,varargin{:});
>
> Error in ft_resampledata (line 228)
>         newdat = transpose(resample(transpose(olddat),fsres,fsorig));
>
>                 I have tried downsampling before filtering, after
> filtering, on continuous data, or already segmented data. None of these
> things seem to resolve the error.
>
>
> 2)      When trying to set up the automatic artifact removal process and
> choosing yes for the interactive plot, I get a plotting error:
>
> Error using plot
>
> Vectors must be the same length.
>
>
>
> Error in ft_artifact_zvalue>redraw_cb (line 973)
>
>     plot(opt.h1, xval, yval, 'linestyle', '-', 'color', 'b',
> 'displayname', 'data');
>
>
>
> Error in ft_artifact_zvalue (line 512)
>
>   redraw_cb(h);
>
>         I've noticed that the xval and yval are different numbers, which
> of course doesn't allow plotting. It seems like the xval changes according
> to the epoch length, however the yval remains the same and equals the
> amount of samples in my continuous data.
>
>
> 3)      When choosing no for the interactive plot, I also get an error:
> Error using zeros
> Size inputs must be integers.
>
> Error in ft_artifact_zvalue (line 568)
> dum = zeros(1,max(opt.trl(:,2)));
>
> I've been looking into the functions and where it goes wrong, but I can't
> seem to pinpoint what exactly is causing these issues. Anyone here that can
> help or provide me some tips?
>
> Thanks in advance!
>
> Kind regards,
>
> Gaëlle Leys
>
> Research Associate
> Brain & Cognition
> Tiensestraat 102 box 3714
> 3000 Leuven
> Room PSI 02.33
> tel. +32 16 37 61 98
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200619/e7e1bde8/attachment-0001.htm
> >
>
> ------------------------------
>
> Message: 2
> Date: Fri, 19 Jun 2020 15:08:21 +0200
> From: Stephen Whitmarsh <stephen.whitmarsh at gmail.com>
> To: FieldTrip discussion list <fieldtrip at science.ru.nl>
> Subject: Re: [FieldTrip] Errors with downsampling and artifact
>         rejection
> Message-ID:
>         <CAFrxm=
> w44QZ0C7xB4cpsqdy0D0ou5UcpHNM-q3bjyaqwwJxRwg at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Dear Gaëlle,
>
> To understand the problem it would be helpful to have 1) description of
> the data structures going in ft_resampledata (just type in command line and
> copy-paste the output) and the artefact detection function you are using,
> and 2) the configuration (cfg) you are using for those functions.
>
> Cheers,
> Stephen
>
>
> Op vr 19 jun. 2020 om 14:56 schreef Gaëlle Leys <gaelle.leys at kuleuven.be>:
>
> > Dear Fieldtrip community,
> >
> >
> >
> > I have recently started with Fieldtrip for my EEG data processing and
> > I am encountering some problems which I can’t seem to resolve.
> >
> > I’m working with mff files from an EGI EEG system. I have no problem
> > reading in and preprocessing the data. However, when trying to
> > downsample and setup the automatic artifact removal, I’m getting some
> errors.
> >
> >
> >
> > 1)      When trying to downsample with the default options, these are the
> > errors that I get:
> >
> > Error using resample>getSamples (line 357)
> >
> > The number of elements of Tx must match the number of rows of X when X
> > is a matrix
> >
> >
> >
> > Error in resample>nonUniformResample (line 123)
> >
> > [x, tx] = getSamples(varargin{1:2});
> >
> >
> >
> > Error in resample (line 116)
> >
> >   [varargout{1:max(1,nargout)}] =
> > nonUniformResample(method,varargin{:});
> >
> >
> >
> > Error in ft_resampledata (line 228)
> >
> >         newdat = transpose(resample(transpose(olddat),fsres,fsorig));
> >
> >
> >
> >                 I have tried downsampling before filtering, after
> > filtering, on continuous data, or already segmented data. None of
> > these things seem to resolve the error.
> >
> >
> >
> > 2)      When trying to set up the automatic artifact removal process and
> > choosing yes for the interactive plot, I get a plotting error:
> >
> > Error using plot
> >
> > Vectors must be the same length.
> >
> >
> >
> > Error in ft_artifact_zvalue>redraw_cb (line 973)
> >
> >     plot(opt.h1, xval, yval, 'linestyle', '-', 'color', 'b',
> > 'displayname', 'data');
> >
> >
> >
> > Error in ft_artifact_zvalue (line 512)
> >
> >   redraw_cb(h);
> >
> >
> >
> >         I’ve noticed that the xval and yval are different numbers,
> > which of course doesn’t allow plotting. It seems like the xval changes
> > according to the epoch length, however the yval remains the same and
> > equals the amount of samples in my continuous data.
> >
> >
> >
> > 3)      When choosing no for the interactive plot, I also get an error:
> >
> > Error using zeros
> >
> > Size inputs must be integers.
> >
> >
> >
> > Error in ft_artifact_zvalue (line 568)
> >
> > dum = zeros(1,max(opt.trl(:,2)));
> >
> >
> >
> > I’ve been looking into the functions and where it goes wrong, but I
> > can’t seem to pinpoint what exactly is causing these issues. Anyone
> > here that can help or provide me some tips?
> >
> >
> >
> > Thanks in advance!
> >
> >
> >
> > Kind regards,
> >
> >
> >
> > Gaëlle Leys
> >
> >
> >
> > Research Associate
> > Brain & Cognition
> > Tiensestraat 102 box 3714
> > 3000 Leuven
> >
> > Room PSI 02.33
> > tel. +32 16 37 61 98
> >
> >
> > _______________________________________________
> > fieldtrip mailing list
> > https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> > https://doi.org/10.1371/journal.pcbi.1002202
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200619/137e31b1/attachment-0001.htm
> >
>
> ------------------------------
>
> Message: 3
> Date: Fri, 19 Jun 2020 18:58:36 +0200
> From: "SILVA PEREIRA, SILVANA" <silvana.silva at upf.edu>
> To: fieldtrip at science.ru.nl
> Subject: [FieldTrip] MNI coordinates for the EEG easycap-M1 layout
> Message-ID:
>         <
> CA+_MWm1NufDWa-fjR71OzQ5ab88ioyUT8OJ-QFYX9ABr7gNQrA at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Dear community,
>
> I've been struggling to find the 3D positions (montages) for the
> Acticap-64ch-standard2 on the web, which is a modified version of the
> easycap-M1, but I have not succeeded. In the Fieldtrip page
> http://www.fieldtriptoolbox.org/template/electrode/ you have the
> following:
>
> You can find the template 3-D electrode sets included in FieldTrip here <
> https://github.com/fieldtrip/fieldtrip/tree/master/template/electrode>.
>
> But in that link you only find a txt file with theta-phi coordinates
> (easycap-M1.txt). Is there any place where I could find these positions in
> MNI space?
>
> Thank you and best regards,
> Silvana
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200619/c0adf7df/attachment-0001.htm
> >
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202
>
>
> ------------------------------
>
> End of fieldtrip Digest, Vol 115, Issue 22
> ******************************************
>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200622/3ef1e021/attachment-0001.htm>

------------------------------

Message: 6
Date: Mon, 22 Jun 2020 21:38:39 +0000
From: Andrade Rey René <rene.andrade at edu.uah.es>
To: "fieldtrip at science.ru.nl" <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] fieldtrip Digest, Vol 115, Issue 23
Message-ID: <0CED8809-357C-49C1-B255-9CCE26A7EC75 at edu.uah.es>
Content-Type: text/plain; charset="utf-8"

Is it normal that 16GB of RAM aren't sufficient for a normal EEG? May be I am doing something wrong and that is the reason my RAM isn't enough.

Sent from my iPhone

> On 22 Jun 2020, at 12:16, "fieldtrip-request at science.ru.nl" <fieldtrip-request at science.ru.nl> wrote:
> 
> Send fieldtrip mailing list submissions to
>    fieldtrip at science.ru.nl
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>    https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> or, via email, send a message with subject or body 'help' to
>    fieldtrip-request at science.ru.nl
> 
> You can reach the person managing the list at
>    fieldtrip-owner at science.ru.nl
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of fieldtrip digest..."
> 
> 
> Today's Topics:
> 
>   1. Running out of memory (RAM) (Andrade Rey René)
>   2. Re: Running out of memory (RAM) (Schoffelen, J.M. (Jan Mathijs))
>   3. Re: DICS question (Schoffelen, J.M. (Jan Mathijs))
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Sun, 21 Jun 2020 20:34:49 +0000
> From: Andrade Rey René <rene.andrade at edu.uah.es>
> To: "fieldtrip at science.ru.nl" <fieldtrip at science.ru.nl>
> Subject: [FieldTrip] Running out of memory (RAM)
> Message-ID: <C30BBEE6-8A40-4668-8F48-E8244C205963 at edu.uah.es>
> Content-Type: text/plain; charset="utf-8"
> 
> Dear experts:
> I am running this code
> 
> 
> cfg = [];
> cfg.headmodel = headmodel;
> cfg.sourcemodel = leadfield;
> cfg.method = 'lcmv';
> cfg.lcmv.projectmom = 'yes'; % project dipole time series in direction of maximal power (see below)
> cfg.lcmv.kurtosis = 'yes'; % compute kurtosis at each location
> source = ft_sourceanalysis(cfg, cov_matrix);
> 
> Of http://www.fieldtriptoolbox.org/tutorial/epilepsy/. And I think  I run out of memory because with “top” I can see the computer stops responding when near 85% of RAM memory(16GB).
> 
> I cannot report any error because the only problem seems to be that either wrong code or wrong data or I don’t know.
> 
> Best,
> Andrade.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200621/8b61eaac/attachment-0001.htm>
> 
> ------------------------------
> 
> Message: 2
> Date: Mon, 22 Jun 2020 06:51:30 +0000
> From: "Schoffelen, J.M. (Jan Mathijs)" <jan.schoffelen at donders.ru.nl>
> To: FieldTrip discussion list <fieldtrip at science.ru.nl>
> Subject: Re: [FieldTrip] Running out of memory (RAM)
> Message-ID: <308CD012-C138-486C-9B4C-E7F7487D3426 at donders.ru.nl>
> Content-Type: text/plain; charset="utf-8"
> 
> Dear Andrade,
> 
> Without any more specific information, the only meaningful comment that can be given here, is ‘get yourself a more powerful computer’.
> 
> Memory usage depends highly on the operating system (in particular: matlab on windows machines used to be much less memory friendly, but it’s been a while that I have been running real computations on a window machine so perhaps this has changed), the total size of all variables that need to be kept in memory, etc.
> 
> Best wishes,
> Jan-Mathijs
> 
> 
> 
> On 21 Jun 2020, at 22:34, Andrade Rey René <rene.andrade at edu.uah.es<mailto:rene.andrade at edu.uah.es>> wrote:
> 
> Dear experts:
> I am running this code
> 
> 
> cfg = [];
> cfg.headmodel = headmodel;
> cfg.sourcemodel = leadfield;
> cfg.method = 'lcmv';
> cfg.lcmv.projectmom = 'yes'; % project dipole time series in direction of maximal power (see below)
> cfg.lcmv.kurtosis = 'yes'; % compute kurtosis at each location
> source = ft_sourceanalysis(cfg, cov_matrix);
> 
> Of http://www.fieldtriptoolbox.org/tutorial/epilepsy/. And I think  I run out of memory because with “top” I can see the computer stops responding when near 85% of RAM memory(16GB).
> 
> I cannot report any error because the only problem seems to be that either wrong code or wrong data or I don’t know.
> 
> Best,
> Andrade.
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202
> 
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200622/2a12ebf1/attachment-0001.htm>
> 
> ------------------------------
> 
> Message: 3
> Date: Mon, 22 Jun 2020 07:52:03 +0000
> From: "Schoffelen, J.M. (Jan Mathijs)" <jan.schoffelen at donders.ru.nl>
> To: FieldTrip discussion list <fieldtrip at science.ru.nl>
> Cc: Sanjeev Nara <s.nara at bcbl.eu>, "m.lizarazu at bcbl.eu"
>    <m.lizarazu at bcbl.eu>,  Nicola Molinaro <nicolaml at gmail.com>, Craig
>    Richter <craiggrichter at gmail.com>
> Subject: Re: [FieldTrip] DICS question
> Message-ID: <40F6A2CA-6DB9-453A-B33B-6E2413DA4EA8 at donders.ru.nl>
> Content-Type: text/plain; charset="utf-8"
> 
> Dear Craig,
> 
> Let me forward this e-mail to the discussion list, in order to widen the scope to all of Donostia and beyond.
> 
> Indeed, the estimation of spectrally resolved GC requires a full bandwidth signal. I have not extensively played with the different options here, but the scenario that you describe, i.e. compute a DICS spatial filter on a narrow bandwidth-of-interest signal, and subjecting the broadband sensor signals to this spatial filter, will, in my opinion, not be really optimal. The reason for this is that the beamformer then can only suppress interference from that particular bandwidth. Signal components that lie outside this range might still leak into the estimated time courses, which may lead to distortion and invalid GC estimates.
> 
> So, if you would be using an LCMV beamformer, I’d always recommend a broadband spatial filter, optionally on mildly highpass-filtered data. Then, the risk could be that the 1/f characteristic of the signals results in a covariance matrix whose signal components are dominated by low-frequency stuff. One could then worry about suboptimal spatial filtering of the higher frequency components. This is probably true, and I have worried about this myself, but in my experience this is the least of the worries one should have. (as a side note: I have played around with spectral whitening of the data prior to the beamforming. The reasoning behind this is that the individual variance components in the data are more evenly balanced across the frequency range, but the long story short is that this does not seem to influence the final GC estimate).
> 
> A larger worry would be the fact that source-estimated GC spectra very often have a canonical shape, unless you use extremely well-defined data such a visual attention experiment that induces strong gamma band oscillations. If you are into applying connectivity analysis in a more ethereal context, such as a cognitive or language experiment, you will see that source-level GC spectra will be always dominated by the low-frequency components (i.e. most of the time you’ll find a large peak at low frequencies). This of course can reflect genuine neuronal coupling, but my suspicion is that this is most of the time due to ‘weak signal asymmetries’, in other words due to asymmetries in SNR and location specific leakage of power. This can be further investigated using time-flipping and an appropriate statistical evaluation. For inspiration, you can of course always consult my 2017 PNAS paper :).
> 
> Another worry of course would be the fact that you’d be working with Elekta data :).
> 
> Practically, what I typically do, is to compute the broadband spatial filter with LCMV, and apply these filters (as is, or dimensionality reduced after a parcellation step) to the sensor level cross-spectral density data (from DC to Nyquist). The spectral factorization algorithm should be applied to the source-level data, which in my experience is most stable if you do this pairwise. I know that this is suboptimal in the context of an interpretation of direct versus indirect interactions, but I have always found this an argument that is part of a non-discussion at this stage of the analysis. One should first trust the estimates overall, before a discussion about direct versus indirect coupling becomes relevant.
> 
> Best wishes,
> JM
> 
> 
> 
> 
> 
> 
> 
> 
> On 19 Jun 2020, at 18:06, Craig Richter <craiggrichter at gmail.com<mailto:craiggrichter at gmail.com>> wrote:
> 
> Hey JM,
> 
> How’s it going? Covid treating you ok? Been a bit crazy here, but normalcy is resuming.
> 
> I have a question about DICS for you… :-/... Anyhow, so for coherence at a given frequency DICS is superior, since the spatial-filter is specific to that frequency, which is about the same as a building a noise-covariance matrix from a narrow-band filtered signal? But to do source-level GC, we need the broadband time-series, so we’re forced to use the unfiltered data and LCMV. But… what if we know the frequency we want to analyse, so we build the spatial filter on this frequency, or narrow-band filtered data, then compute virtual time series from the raw data, and compute GC. Then we simply look at our frequency of interest in the spectral results. Would this potentially generate a better GC estimate at the frequency of interest, or would it just mess everything up?
> 
> PS - I’ve cc’ed some other interested folks.
> 
> Thanks!
> 
> C.
> 
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200622/1a7e6793/attachment-0001.htm>
> 
> ------------------------------
> 
> Subject: Digest Footer
> 
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202
> 
> 
> ------------------------------
> 
> End of fieldtrip Digest, Vol 115, Issue 23
> ******************************************



------------------------------

Message: 7
Date: Tue, 23 Jun 2020 06:42:03 +0000
From: "Schoffelen, J.M. (Jan Mathijs)" <jan.schoffelen at donders.ru.nl>
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] Errors with downsampling and artifact
	rejection
Message-ID: <184602F0-A203-406F-B278-32CD899D4532 at donders.ru.nl>
Content-Type: text/plain; charset="utf-8"

Hi Gaëlle,

Adding to Stephen’s comment: reading through the code and comments (highly recommended to occasionally do this, then you get a feel what’s going on under the hood) I saw that there’s a discrepancy between the comments in the help section of ft_resampledata, where it states that the default resamplefs=256, and the actually implemented default resamplefs, which is []. Apparently, MATLAB is lenient with respect to mathematical operations involving empty variables. Specifically, it doesn’t throw an error on lines 160/161 in ft_resampledata, where an empty variable is multiplied and divided by a scalar. Long story short, the silently accepted empty variable is the acual cause of the reported problem in ft_resampledata.

I look forward to a PR that fixes this. I suggest making the documentation consistent, i.e. stating that cfg.resamplefs is an argument that needs to be defined, and explicitly check this in the code, i.e. throw an error if it isn’t defined. This is typically done with a call to ft_checkconfig using the key-value pair ‘required’, and ‘resamplefs’ (in this case).

Thanks for your contribution,

Jan-Mathijs





On 22 Jun 2020, at 17:35, Stephen Whitmarsh <stephen.whitmarsh at gmail.com<mailto:stephen.whitmarsh at gmail.com>> wrote:

Dear Gaëlle,

You are using default settings for downsampling, which will then try to downsample to 256Hz. Your original samplerate is 1000Hz, so that isn't a neat integer division.
I tried the following, and could reproduce your problem:

Fs = 1000;
data_eeg = [];
data_eeg.label = {'a','b','c'};
data_eeg.time{1} = 0:1/Fs:10;
data_eeg.trial{1} = rand(length(data_eeg.label),length(data_eeg.time{1}));
data_eeg.Fs = Fs;
data_eeg.sampleinfo = [1, length(data_eeg.time{1})];

% Doesn't work:
cfg = [];
[data_eeg] = ft_resampledata(cfg, data_eeg);

% Does work:
cfg = [];
cfg.resamplefs = 250;
[data_eeg] = ft_resampledata(cfg, data_eeg);

So that deals with your first problem. Not sure why it has a problem with the downsampling to non-integer values, but it's good practice and much faster to stick to that anyway.

Not sure what to do with the artefact detection though, or what you expect;  it seems you are running it with some contradictory settings/ways perhaps:
- use cfg.dataset if reading from disk directly OR give datastructure to function is you already have data in memory
- use cfg.continuous when data is not segmented
- the comment "jump" suggests you use settings for SQUID jumps, i.e. optimized for MEG, but that should not give an error :-)

I suspect you probably want to run artefact detection on your segmented data, so remove those references to the data on disk (datafile, headerfile), and the trl from the cfg, and give your segmented data as an argument as you did here:
%[cfg, artifact_jump] = ft_artifact_zvalue(cfg, data_eeg); %no plot error, but each trial has the same graph, also error using zeros

Let us know how it goes,

All the best,
Stephen











Op ma 22 jun. 2020 om 17:02 schreef Gaëlle Leys <gaelle.leys at kuleuven.be<mailto:gaelle.leys at kuleuven.be>>:
Dear Stephen,

I have included the data structures and cfg's involved in the functions.

1)      A. data structure for resampling data (raw data after reading it in):
data_eeg =
  struct with fields:
hdr: [1×1 struct]
label: {129×1 cell}
time: {[1×245726 double]}
trial: {[129×245726 double]}
fsample: 1000
sampleinfo: [1 245726]
elec: [1×1 struct]
cfg: [1×1 struct]

1)      B. cfg for resampling data (I’m using all the default options for resampling):

Cfg=[];
[data_eeg] = ft_resampledata(cfg, data_eeg); % defaults are all OK

2)      A. data structure for artifact rejection (my data already epoched):
data_eeg =
struct with fields:
hdr: [1×1 struct]
label: {129×1 cell}
 time: {1×108 cell}
 trial: {1×108 cell}
 fsample: 1000
 sampleinfo: [108×2 double]
 elec: [1×1 struct]
 cfg: [1×1 struct]


2)      B. cfg for artifact rejection (taken from the automatic artifact rejection example):
% jump
cfg = [];
cfg.trl = trl;
cfg.datafile = '100_1_20200305.mff';
cfg.headerfile = '100_1_20200305.mff';
cfg.continuous = 'yes';

% channel selection, cutoff and padding
cfg.artfctdef.zvalue.channel = 'EEG';
cfg.artfctdef.zvalue.cutoff = 20;
cfg.artfctdef.zvalue.trlpadding = 0;
cfg.artfctdef.zvalue.artpadding = 0;
cfg.artfctdef.zvalue.fltpadding = 0;

% algorithmic parameters
cfg.artfctdef.zvalue.cumulative = 'yes';
cfg.artfctdef.zvalue.medianfilter = 'yes';
cfg.artfctdef.zvalue.medianfiltord = 9;
cfg.artfctdef.zvalue.absdiff = 'yes';

% make the process interactive
cfg.artfctdef.zvalue.interactive = 'yes';

[cfg, artifact_jump] = ft_artifact_zvalue(cfg); %plot error and error using zeros
%[cfg, artifact_jump] = ft_artifact_zvalue(cfg, data_eeg); %no plot error, but each trial has the same graph, also error using zeros


Kind regards,
Gaëlle Leys



-----Original Message-----
From: fieldtrip <fieldtrip-bounces at science.ru.nl<mailto:fieldtrip-bounces at science.ru.nl>> On Behalf Of fieldtrip-request at science.ru.nl<mailto:fieldtrip-request at science.ru.nl>
Sent: zaterdag 20 juni 2020 12:00
To: fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>
Subject: fieldtrip Digest, Vol 115, Issue 22

Send fieldtrip mailing list submissions to
        fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>

To subscribe or unsubscribe via the World Wide Web, visit
        https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
or, via email, send a message with subject or body 'help' to
        fieldtrip-request at science.ru.nl<mailto:fieldtrip-request at science.ru.nl>

You can reach the person managing the list at
        fieldtrip-owner at science.ru.nl<mailto:fieldtrip-owner at science.ru.nl>

When replying, please edit your Subject line so it is more specific than "Re: Contents of fieldtrip digest..."


Today's Topics:

   1. Errors with downsampling and artifact rejection (Gaëlle Leys)
   2. Re: Errors with downsampling and artifact rejection
      (Stephen Whitmarsh)
   3. MNI coordinates for the EEG easycap-M1 layout
      (SILVA PEREIRA, SILVANA)


----------------------------------------------------------------------

Message: 1
Date: Fri, 19 Jun 2020 12:48:26 +0000
From: Gaëlle Leys <gaelle.leys at kuleuven.be<mailto:gaelle.leys at kuleuven.be>>
To: "fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>" <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
Subject: [FieldTrip] Errors with downsampling and artifact rejection
Message-ID:
        <ccb89b4d31af42d3b4cd22485438f4ef at ICTS-S-EXMBX17.luna.kuleuven.be<mailto:ccb89b4d31af42d3b4cd22485438f4ef at ICTS-S-EXMBX17.luna.kuleuven.be>>
Content-Type: text/plain; charset="iso-8859-1"

Dear Fieldtrip community,

I have recently started with Fieldtrip for my EEG data processing and I am encountering some problems which I can't seem to resolve.
I'm working with mff files from an EGI EEG system. I have no problem reading in and preprocessing the data. However, when trying to downsample and setup the automatic artifact removal, I'm getting some errors.


1)      When trying to downsample with the default options, these are the errors that I get:
Error using resample>getSamples (line 357) The number of elements of Tx must match the number of rows of X when X is a matrix

Error in resample>nonUniformResample (line 123) [x, tx] = getSamples(varargin{1:2});

Error in resample (line 116)
  [varargout{1:max(1,nargout)}] = nonUniformResample(method,varargin{:});

Error in ft_resampledata (line 228)
        newdat = transpose(resample(transpose(olddat),fsres,fsorig));

                I have tried downsampling before filtering, after filtering, on continuous data, or already segmented data. None of these things seem to resolve the error.


2)      When trying to set up the automatic artifact removal process and choosing yes for the interactive plot, I get a plotting error:

Error using plot

Vectors must be the same length.



Error in ft_artifact_zvalue>redraw_cb (line 973)

    plot(opt.h1, xval, yval, 'linestyle', '-', 'color', 'b', 'displayname', 'data');



Error in ft_artifact_zvalue (line 512)

  redraw_cb(h);

        I've noticed that the xval and yval are different numbers, which of course doesn't allow plotting. It seems like the xval changes according to the epoch length, however the yval remains the same and equals the amount of samples in my continuous data.


3)      When choosing no for the interactive plot, I also get an error:
Error using zeros
Size inputs must be integers.

Error in ft_artifact_zvalue (line 568)
dum = zeros(1,max(opt.trl(:,2)));

I've been looking into the functions and where it goes wrong, but I can't seem to pinpoint what exactly is causing these issues. Anyone here that can help or provide me some tips?

Thanks in advance!

Kind regards,

Gaëlle Leys

Research Associate
Brain & Cognition
Tiensestraat 102 box 3714
3000 Leuven
Room PSI 02.33
tel. +32 16 37 61 98

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200619/e7e1bde8/attachment-0001.htm>

------------------------------

Message: 2
Date: Fri, 19 Jun 2020 15:08:21 +0200
From: Stephen Whitmarsh <stephen.whitmarsh at gmail.com<mailto:stephen.whitmarsh at gmail.com>>
To: FieldTrip discussion list <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
Subject: Re: [FieldTrip] Errors with downsampling and artifact
        rejection
Message-ID:
        <CAFrxm=w44QZ0C7xB4cpsqdy0D0ou5UcpHNM-q3bjyaqwwJxRwg at mail.gmail.com<mailto:w44QZ0C7xB4cpsqdy0D0ou5UcpHNM-q3bjyaqwwJxRwg at mail.gmail.com>>
Content-Type: text/plain; charset="utf-8"

Dear Gaëlle,

To understand the problem it would be helpful to have 1) description of the data structures going in ft_resampledata (just type in command line and copy-paste the output) and the artefact detection function you are using, and 2) the configuration (cfg) you are using for those functions.

Cheers,
Stephen


Op vr 19 jun. 2020 om 14:56 schreef Gaëlle Leys <gaelle.leys at kuleuven.be<mailto:gaelle.leys at kuleuven.be>>:

> Dear Fieldtrip community,
>
>
>
> I have recently started with Fieldtrip for my EEG data processing and
> I am encountering some problems which I can’t seem to resolve.
>
> I’m working with mff files from an EGI EEG system. I have no problem
> reading in and preprocessing the data. However, when trying to
> downsample and setup the automatic artifact removal, I’m getting some errors.
>
>
>
> 1)      When trying to downsample with the default options, these are the
> errors that I get:
>
> Error using resample>getSamples (line 357)
>
> The number of elements of Tx must match the number of rows of X when X
> is a matrix
>
>
>
> Error in resample>nonUniformResample (line 123)
>
> [x, tx] = getSamples(varargin{1:2});
>
>
>
> Error in resample (line 116)
>
>   [varargout{1:max(1,nargout)}] =
> nonUniformResample(method,varargin{:});
>
>
>
> Error in ft_resampledata (line 228)
>
>         newdat = transpose(resample(transpose(olddat),fsres,fsorig));
>
>
>
>                 I have tried downsampling before filtering, after
> filtering, on continuous data, or already segmented data. None of
> these things seem to resolve the error.
>
>
>
> 2)      When trying to set up the automatic artifact removal process and
> choosing yes for the interactive plot, I get a plotting error:
>
> Error using plot
>
> Vectors must be the same length.
>
>
>
> Error in ft_artifact_zvalue>redraw_cb (line 973)
>
>     plot(opt.h1, xval, yval, 'linestyle', '-', 'color', 'b',
> 'displayname', 'data');
>
>
>
> Error in ft_artifact_zvalue (line 512)
>
>   redraw_cb(h);
>
>
>
>         I’ve noticed that the xval and yval are different numbers,
> which of course doesn’t allow plotting. It seems like the xval changes
> according to the epoch length, however the yval remains the same and
> equals the amount of samples in my continuous data.
>
>
>
> 3)      When choosing no for the interactive plot, I also get an error:
>
> Error using zeros
>
> Size inputs must be integers.
>
>
>
> Error in ft_artifact_zvalue (line 568)
>
> dum = zeros(1,max(opt.trl(:,2)));
>
>
>
> I’ve been looking into the functions and where it goes wrong, but I
> can’t seem to pinpoint what exactly is causing these issues. Anyone
> here that can help or provide me some tips?
>
>
>
> Thanks in advance!
>
>
>
> Kind regards,
>
>
>
> Gaëlle Leys
>
>
>
> Research Associate
> Brain & Cognition
> Tiensestraat 102 box 3714
> 3000 Leuven
>
> Room PSI 02.33
> tel. +32 16 37 61 98
>
>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200619/137e31b1/attachment-0001.htm>

------------------------------

Message: 3
Date: Fri, 19 Jun 2020 18:58:36 +0200
From: "SILVA PEREIRA, SILVANA" <silvana.silva at upf.edu<mailto:silvana.silva at upf.edu>>
To: fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>
Subject: [FieldTrip] MNI coordinates for the EEG easycap-M1 layout
Message-ID:
        <CA+_MWm1NufDWa-fjR71OzQ5ab88ioyUT8OJ-QFYX9ABr7gNQrA at mail.gmail.com<mailto:CA%2B_MWm1NufDWa-fjR71OzQ5ab88ioyUT8OJ-QFYX9ABr7gNQrA at mail.gmail.com>>
Content-Type: text/plain; charset="utf-8"

Dear community,

I've been struggling to find the 3D positions (montages) for the
Acticap-64ch-standard2 on the web, which is a modified version of the easycap-M1, but I have not succeeded. In the Fieldtrip page http://www.fieldtriptoolbox.org/template/electrode/ you have the following:

You can find the template 3-D electrode sets included in FieldTrip here <https://github.com/fieldtrip/fieldtrip/tree/master/template/electrode>.

But in that link you only find a txt file with theta-phi coordinates (easycap-M1.txt). Is there any place where I could find these positions in MNI space?

Thank you and best regards,
Silvana
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200619/c0adf7df/attachment-0001.htm>

------------------------------

Subject: Digest Footer

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202


------------------------------

End of fieldtrip Digest, Vol 115, Issue 22
******************************************

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200623/62aa978f/attachment-0001.htm>

------------------------------

Subject: Digest Footer

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202


------------------------------

End of fieldtrip Digest, Vol 115, Issue 24
******************************************



More information about the fieldtrip mailing list