<div dir="ltr">hi Luisa,<div><br></div><div>Regarding ICA, I recently had a somewhat related issue and managed to solve it with custom code (and help from this list), partly because I wasn't all too sure about eeglab2fieldtrip.</div><div><br></div><div>First off: eeglab and fieldtrip rely on the exact same underlying ica implementation (at least for runica, and I suspect for other variants as well). If you have no specific requirement to run ica from eeglab, I think it would be easiest to just import your (pre-ica) data into fieldtrip, and run ica/reject components from fieldtrip (and let fieldtrip handle all the bookkeeping).</div><div><br></div><div>If you somehow must convert eeglab's ica decomposition to fieldtrip you could construct a fieldtrip component structure as follows (assuming <i>data_ft </i>is your data in fieldtrip format, and <i>EEG </i>the eeglab format):</div><div><br></div><div><i>cfg_comp = [];<br>cfg_comp.demean    = 'no';           % This has to be explicitly stated, as the default is to demean.<br>cfg_comp.unmixing  = pinv(EEG.icawinv);  % Supply the matrix necessary to 'unmix' the channel-series data into components<br>cfg_comp.topolabel = data_ft.label(:); % Supply the original channel label information<br><br>%calculate component topographies and time courses for entire data<br>comp = ft_componentanalysis(cfg_comp, data_ft);</i></div><div><i><br></i></div><div>you should get something like this (I ran ICA with pca 64 option):</div><div><i><br></i></div><div><i>comp = <br><br>  struct with fields:<br><br>       fsample: 250<br>          time: {[1×7747289 double]}<br>         trial: {[64×7747289 double]}<br>          topo: [249×64 double]<br>      unmixing: [64×249 double]<br>         label: {64×1 cell}<br>     topolabel: {249×1 cell}<br>          elec: [1×1 struct]<br>    sampleinfo: [1 7747289]</i><br>           cfg: [1×1 struct]<br><br></div><div>Rejecting components can then be done as follows:</div><div><br></div><div><i>cfg=[];<br>cfg.component=badCompInds;<br>data=ft_rejectcomponent(cfg, comp);</i><br></div><div><br></div><div>where you could get <i>badCompInds </i>from inspecting components within fieldtrip, or from somewhere in<i> EEG.reject</i> to remove already marked components (you'd have to check what field exactly).</div><div><br></div><div>Roy</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 31, 2022 at 5:43 PM Julian Keil via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" target="_blank">fieldtrip@science.ru.nl</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Dear Luisa,<div><br></div><div>Regarding your first question, it is im my experience easier to recreate the .trialinfo field from the EEGLab event-info after exporting from EEGLab to FieldTrip.</div><div>You can find an example from a recent project here:</div><div><a href="https://osf.io/ph5xm/" target="_blank">https://osf.io/ph5xm/</a> for the export to Fieldtrip</div><div><a href="https://osf.io/n27pe/" target="_blank">https://osf.io/n27pe/</a> for the function to get the trial-info</div><div><br></div><div>Regarding your ICA-questions, in the aforementioned project, I did the whole preprocessing in EEGLab, including the IC rejection, as I only needed the „clean“ data later on. However, I guess this strongly depends on what you want to do with your data later on.</div><div><br></div><div>Hope this helps,</div><div><br></div><div>Julian</div><div><br></div><div>________________</div><div><div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Prof. Dr. Julian Keil<br><br>Biologische Psychologie<br>Olshausenstraße 62 - R. 306<br>24118 Kiel<br><br>0431 / 880 - 4872<br><a href="http://www.biopsych.uni-kiel.de/" target="_blank">http://www.biopsych.uni-kiel.de/</a><br><br></div>
</div>
<div><br><blockquote type="cite"><div>Am 31.03.2022 um 16:35 schrieb Luisa Roeder via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" target="_blank">fieldtrip@science.ru.nl</a>>:</div><br><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">Dear Community,<span> </span><u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">My name is Luisa Roeder and I am a postdoc in Prof Joachim Hermsdoerfer’s lab at Technical University Munich. Currently, we are working on a grip force control project, and I am analysing combined EEG-EMG data.<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">I hope my email is not too long; I have a few questions re importing data from EEGLAB to Fieldtrip.<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">I have pre-processed the data in EEGLAB and would now like to import them into Fieldtrip. For this, I used ft_preprocessing with the details shown below. However, in the Fieldtrip structure I receive, I cannot seem to find any information on the events/triggers I had in the .set file.<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">Where do I find the event information that was saved in the eeglab (.set) file as EEG.event? Is it possible to also import this event information (i.e. their indices and type of event) into Fieldtrip, or do I need to save this information separately and then use ft_definetrial to re-create my events in fieldtrip? If this is the case, what would be the best way/structure and file format for saving the events from eeglab?<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">Below are the details of my code and output:<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">cfg = []; cfg.dataset = 'data01_cond1.set'; ft_data1 = ft_preprocessing(cfg);<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">and receive the output<span> </span><u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">ft_data1 =<span> </span><u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">  struct with fields:<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">           hdr: [1×1 struct]<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">         label: {61×1 cell}<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">          time: {[1×692901 double]}<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">         trial: {[61×692901 double]}<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">       fsample: 500<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">    sampleinfo: [1 692901]<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">          elec: [1×1 struct]<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">           cfg: [1×1 struct]<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">I noticed when I use<span> </span><u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">ft_data1 = eeglab2fieldtrip(EEG, ‘raw’);<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">with segmented (epoched) EEGLAB data, I receive some information on my trigger events I used for segmenting (in ft_data1.trialinfo), but this does not include the indices of the events (‘latency’ in EEG.event), nor the other types of events I had in EEGLAB in addition to the trigger I used for segmenting (also saved in EEG.event). In my case I have six different types of events in EEG.event which I would like to import into Fieldtrip.<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">The output from eeglab2fieldtrip(EEG,’raw’) is<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">ft_data1 =<span> </span><u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">  struct with fields:<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">         elec: [1×1 struct]<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">      fsample: 500<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">        trial: {1×99 cell}<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">         time: {1×99 cell}<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">        label: {1×61 cell}<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">    trialinfo: [99×2 table]<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">          cfg: [1×1 struct]<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">In general, is it best to import continuous data into Fieldtrip or segmented data?<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">I have another few questions re importing/book-keep the ICA results from EEGLAB once I import my data into Fieldtrip.<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">Is it best to exclude ICs in EEGLAB, then back project onto channels and then export the clean channel data into Fieldtrip? How do I keep track of the rank/dimensionality of the clean data then? Should I additionally also export the ICA results via ft_ICdata = eeglab2fieldtrip(EEG, 'comp'); and save those results separately? In the EEGLAB tutorials it is recommended to only mark/flag the ICs but not to reject artefact ICs – if I do that, how do get this information across to Fieldtrip?<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">Thank you for your help.<span> </span><u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">Best,<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">Luisa<u></u><u></u></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">_______________________________________________</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">fieldtrip mailing list</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><a href="https://doi.org/10.1371/journal.pcbi.1002202" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://doi.org/10.1371/journal.pcbi.1002202</a></div></blockquote></div><br></div></div>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<a href="https://doi.org/10.1371/journal.pcbi.1002202" rel="noreferrer" target="_blank">https://doi.org/10.1371/journal.pcbi.1002202</a><br>
</blockquote></div>