{"id":213,"date":"2017-03-05T18:44:02","date_gmt":"2017-03-05T16:44:02","guid":{"rendered":"http:\/\/benediktehinger.de\/blog\/science\/?p=213"},"modified":"2018-02-11T10:57:02","modified_gmt":"2018-02-11T08:57:02","slug":"eeglab-gracefully-overwrite-the-default-colormap","status":"publish","type":"post","link":"https:\/\/benediktehinger.de\/blog\/science\/eeglab-gracefully-overwrite-the-default-colormap\/","title":{"rendered":"EEGlab: Gracefully overwrite the default colormap"},"content":{"rendered":"<p>EEGlab has &#8216;jet&#8217; as the default colormap. But jet is pretty terrible<\/p>\n<div style=\"width: 706px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"size-large\" src=\"https:\/\/3.bp.blogspot.com\/-mNVpcIxosyQ\/T49UZSQMkqI\/AAAAAAAAABk\/Q7wiklw2LmE\/s1600\/different+colormaps+jet+bad+crop.tiff\" width=\"696\" height=\"348\" \/><p class=\"wp-caption-text\">https:\/\/www.reddit.com\/r\/matlab\/comments\/1jqk8t\/you_should_never_use_the_default_colors_in_matlab\/<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>You see structure where there is none (e.g. rings in the third example).<\/p>\n<p>&nbsp;<\/p>\n<h3>The problem:<\/h3>\n<p>Eeglabs sets the default colormap to &#8216;jet&#8217;, thus overwriting a system wide default set e.g. by<\/p>\n<p>&#8220;`<\/p>\n<p><code>set(0,'DefaultFigureColormap',parula); <\/code><\/p>\n<p>&#8220;`<\/p>\n<p>It does so by calling &#8220;`icadefs.m &#8220;` in various functions (e.g. topoplot, erpimage) and defining:<\/p>\n<p>&#8220;`<\/p>\n<p>DEFAULT_COLORMAP = &#8216;jet&#8217;<\/p>\n<p>&#8220;`<\/p>\n<p>We want to overwrite the one line, but keep it forward compatible i.e. we do not want to copy the whole icadefs file, but just replace the single line whenever icadefs is called.<\/p>\n<h3>Solutions<\/h3>\n<h4>Overwrite the line in icadefs.m default<\/h4>\n<p>This has the benefit that it will always work irrespective of your path-ordering. The con is, you will loose the change if you switch eeglab versions or update eeglab.<\/p>\n<h4>Change\/create your eeglab &#8220;`eeg_options.txt&#8220;`.<\/h4>\n<p>This has the benefit that it will carry over to the next version of eeglab, but it is an extra file you need to have somewhere completly different than your project-folder (your user-folder ~\/eeg_options.txt). It is thereby hard to make selfcontained code.<\/p>\n<h4>Make a new icadefs.m<\/h4>\n<p>Make a file called icadefs.m (this script will be called instead of the eeglab &#8220;`icadef&#8220;`) and add the following code:<\/p>\n<p>&#8220;`<\/p>\n<p>run([fileparts(which(&#8216;eegrej&#8217;)) filesep &#8216;icadefs.m&#8217;]);<br \/>\nDEFAULT_COLORMAP = &#8216;parula&#8217;;<\/p>\n<p>&#8220;`<\/p>\n<p>This will call the\u00a0original &#8220;`icadef&#8220;` (in the same folder as &#8220;`eegrej.m&#8220;` and then overwrite the eeglab-default<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Important: The folder to your icadef file must be above eeglab in your path.\u00a0<\/strong><\/p>\n<p>Try this: &#8220;`edit(&#8216;icadefs.m&#8217;)&#8220;` to see which function comes up. If the eeglab-one comes up you have a path conflict here. Your own &#8220;`icadefs&#8220;` has to be above the eeglab one.<\/p>\n<p>In my &#8220;`project_init.m&#8220;` where I add all paths, I make sure that eeglab is started before adding the path to the new &#8220;`icadefs.m&#8220;`<\/p>\n<p>&nbsp;<\/p>\n<h3>Examples:<\/h3>\n<p>ICA &#8211; Topoplots of a single subject<\/p>\n<p><a href=\"https:\/\/raw.githubusercontent.com\/behinger\/ica_goodBadUgly\/master\/brainproduct64\/bs_1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large\" src=\"https:\/\/raw.githubusercontent.com\/behinger\/ica_goodBadUgly\/master\/brainproduct64\/bs_1.png\" width=\"1500\" height=\"800\" \/><\/a><\/p>\n<p>Single component of an IC-Decomposition that included noisy data portions\u00a0(and thus, I would say, is not usable)<\/p>\n<p><a href=\"https:\/\/raw.githubusercontent.com\/behinger\/ica_goodBadUgly\/master\/brainproduct64\/bs_1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large\" src=\"https:\/\/raw.githubusercontent.com\/behinger\/ica_goodBadUgly\/master\/uncleaned_component8.png\" width=\"802\" height=\"796\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>EEGlab has &#8216;jet&#8217; as the default colormap. But jet is pretty terrible &nbsp; You see structure where there is none (e.g. rings in the third example). &nbsp; The problem: Eeglabs sets the default colormap to &#8216;jet&#8217;, thus overwriting a system wide default set e.g. by &#8220;` set(0,&#8217;DefaultFigureColormap&#8217;,parula); &#8220;` It does so by calling &#8220;`icadefs.m &#8220;` in various functions (e.g. topoplot, erpimage) and defining: &#8220;` DEFAULT_COLORMAP = &#8216;jet&#8217; &#8220;` We want to overwrite the one line, but keep it forward compatible i.e. we do not want to copy the whole icadefs file, but just replace the single line whenever icadefs is&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-213","post","type-post","status-publish","format-standard","hentry","category-blog"],"_links":{"self":[{"href":"https:\/\/benediktehinger.de\/blog\/science\/wp-json\/wp\/v2\/posts\/213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/benediktehinger.de\/blog\/science\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/benediktehinger.de\/blog\/science\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/benediktehinger.de\/blog\/science\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/benediktehinger.de\/blog\/science\/wp-json\/wp\/v2\/comments?post=213"}],"version-history":[{"count":0,"href":"https:\/\/benediktehinger.de\/blog\/science\/wp-json\/wp\/v2\/posts\/213\/revisions"}],"wp:attachment":[{"href":"https:\/\/benediktehinger.de\/blog\/science\/wp-json\/wp\/v2\/media?parent=213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/benediktehinger.de\/blog\/science\/wp-json\/wp\/v2\/categories?post=213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/benediktehinger.de\/blog\/science\/wp-json\/wp\/v2\/tags?post=213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}