Back to the main page.

Bug 2193 - reading of AAL atlas is broken since revision 8179

Reported 2013-06-10 10:40:00 +0200
Modified 2014-03-12 12:20:40 +0100
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P3 normal
Assigned to: Jörn M. Horschig
Depends on:
See also:

Eelke Spaak - 2013-06-10 10:40:06 +0200

As of r8179 (, reading the AAL atlas (template/atlas/aal/ROI_MNI_V4.nii) seems to be broken. No matter which anatomical coordinates you put in (e.g. when browsing in sourceplot), the answer is always 'NA' or 'no_label_found'. The change seems a small one, but there must have been some reason for it :) Jörn, can you easily fix this?

Johanna - 2013-06-10 10:44:48 +0200

Jorn's change was in bug 2003 and bug 2024. in response to also bug 1783.

Jörn M. Horschig - 2013-06-10 11:09:55 +0200

Hi Eelke, I made the change due to two reasons: first, it obeys the description somewhat further up (around line 600), second I am reading in the atlas from spm8, there it needs to be like that. I was under the impression that an AAL atlas is an AAL atlas, and if it is described and matches one, it should be a general format. Of course I could just revert it, or make a general if exist(C{1}{3}) && isnumeric(C{1}{3}) then use the old way else do it the other way, but is there maybe some convention for the AAL atlas?

Robert Oostenveld - 2013-06-10 11:15:08 +0200

I created a test script with data on home/common mac001> svn commit test_bug2193.m Adding test_bug2193.m Transmitting file data . Committed revision 8221. The test script works fine for me using ft_read_atlas. I now notice that the bug pertains to ft_prepare_atlas. That function is deprecated and should be replaced by ft_read_atlas. I have extended the test script mac001> svn commit Sending test/test_bug2193.m Transmitting file data . Committed revision 8222. With num = C{1}{1}; in ft_prepare_atlas it works fine with me. I was using /home/common/matlab/spm8/toolbox/wfu_pickatlas/MNI_atlas_templates/aal_MNI_V4.* for testing (now in fieldtrip/test/bug2193). Might it be that there are different versions of the WFU atlasses around?

Johanna - 2013-06-10 11:20:09 +0200

The versions to test I would suggest are: /home/common/matlab/spm8/toolbox/wfu_pickatlas /home/common/matlab/spm8/toolbox/wfu_pickatlas_3.03-old2 /home/common/matlab/spm8/toolbox/wfu_pickatlas-old

Robert Oostenveld - 2013-06-10 11:23:48 +0200

(In reply to comment #2) > I was under the impression that an AAL atlas is an > AAL atlas, and if it is described and matches one, it should be a general > format. Please do not mix up AAL and WFU. the aal atlas is from the wfu_pickatlas is from and is a toolbox (i.e. m-functions) that extends spm8 and includes a bunch of atlasses (i.e. nii files). The confusion might be that the WFU toolbox includes a binary representation of the AAL atlas. I extended the test script, it now does both versions (without problem). mac001> svn commit Sending test/test_bug2193.m Transmitting file data . Committed revision 8223.

Robert Oostenveld - 2013-06-10 11:26:33 +0200

(In reply to comment #4) good idea. More specifically roboos@mentat001> pwd /home/common/matlab/spm8/toolbox roboos@mentat001> ll wfu_pickatlas*/MNI_atlas_templates/aal_MNI_V4.* -rwxr-xr-x 1 martyc tg 902981 May 2 15:07 wfu_pickatlas_3.03-old2/MNI_atlas_templates/aal_MNI_V4.nii -rwxr-xr-x 1 martyc tg 2030 May 2 15:07 wfu_pickatlas_3.03-old2/MNI_atlas_templates/aal_MNI_V4.txt -rwxr-xr-x 1 martyc tg 902981 May 2 15:06 wfu_pickatlas/MNI_atlas_templates/aal_MNI_V4.nii -rwxr-xr-x 1 martyc tg 2030 May 2 15:06 wfu_pickatlas/MNI_atlas_templates/aal_MNI_V4.txt -rwxr-xr-x 1 martyc tg 348 May 2 15:07 wfu_pickatlas-old/MNI_atlas_templates/aal_MNI_V4.hdr -rwxr-xr-x 1 martyc tg 902629 May 2 15:07 wfu_pickatlas-old/MNI_atlas_templates/aal_MNI_V4.img -rwxr-xr-x 1 martyc tg 368 May 2 15:07 wfu_pickatlas-old/MNI_atlas_templates/aal_MNI_V4.mat -rwxr-xr-x 1 martyc tg 2030 May 2 15:07 wfu_pickatlas-old/MNI_atlas_templates/aal_MNI_V4.txt

Jörn M. Horschig - 2013-06-10 11:29:53 +0200

(In reply to comment #5) oh, good to know, the please ignore that I mentioned the AAL atlas

Robert Oostenveld - 2013-06-10 11:34:00 +0200

(In reply to comment #6) I have added them, see mac001> svn commit Sending test/test_bug2193.m Transmitting file data . Committed revision 8224. I cannot reproduce the original problem, although I do get the following error for '/home/common/matlab/spm8/toolbox/wfu_pickatlas-old/MNI_atlas_templates/aal_MNI_V4.img' Index exceeds matrix dimensions. Error in avw_hdr_read (line 44) fprintf('\nAVW_HDR_READ [v%s]\n',version(12:16)); tic; Error in avw_img_read (line 110) [ avw, machine ] = avw_hdr_read(fileprefix,machine,verbose); Error in ft_read_mri (line 131) avw = avw_img_read(filename, 0); % returned volume is LAS* Error in ft_prepare_atlas (line 570) atlas = ft_read_mri(cfg.atlas); Error in test_bug2193 (line 44) aal3a = ft_prepare_atlas(cfg);

Robert Oostenveld - 2013-06-10 11:35:41 +0200

@eelke, can you please check the test script and extend it to reproduce the problem that you observed.

Eelke Spaak - 2013-06-10 11:51:01 +0200

(In reply to comment #9) I would, but I am rather confused at the moment. The test script reads in a totally different atlas from the one I use. I use the one in template/atlas/aal/ROI_MNI_V4.nii. When I use this one and ft_volumelookup my volume structure (with a mask which I know corresponds to some brain regions), I get 'no_label_found'. When I use the corresponding (?) one from the test script (test/bug2193/aal/ROI_MNI_V4.nii) I get a big (117x1) list with abbreviations, possibly including every single entry from the atlas. Furthermore, I've noticed that ft_sourceplot uses ft_prepare_atlas, and not ft_read_atlas. To add to the confusion, it uses atlas_lookup (a private function) to do the actual lookup, and never calls ft_volumelookup. Also, there is an atlas_init, which is apparently never used (although the documentation for atlas_lookup states it should be called prior to atlas_lookup). </confusiondata>

Jörn M. Horschig - 2013-06-10 12:09:44 +0200

Hi Eelke, I can understand your confusion, but see bug 1725. As Robert said, ft_prepare_atlas will get deprecated, and JM has to merge changes into ft_sourceplot and other functions to make this happen.

Jörn M. Horschig - 2013-06-10 12:13:57 +0200

and just to add, I am also (still) confused by the different atlases and their formats, although they have all something about aal in their file or directory name.

Robert Oostenveld - 2013-06-10 12:37:53 +0200

(In reply to comment #10) roboos@mentat001> diff /home/common/matlab/fieldtrip/data/test/bug2193/aal/ROI_MNI_V4.nii /home/common/matlab/fieldtrip/template/atlas/aal/ROI_MNI_V4.nii [shows no difference] I want the test script to stand on its own and not change in the next years, hence I copied the atlas to a test directory. Might it be that the problem is in ft_volumelookup? Might it be a difference in mm and cm?

Johanna - 2013-06-10 12:52:53 +0200

Are the differences here relevant? diff /home/common/matlab/fieldtrip/data/test/bug2193/aal/ROI_MNI_V4.txt /home/common/matlab/spm8/toolbox/wfu_pickatlas/MNI_atlas_templates/aal_MNI_V4.txt

Jörn M. Horschig - 2013-06-10 12:53:10 +0200

\\\home\common\matlab\spm8\toolbox\wfu_pickatlas\MNI_atlas_templates\ROI_MNI_V4.nii is different though, and I think the associated .txt files are also bad guys (different)

Robert Oostenveld - 2013-06-10 16:18:17 +0200

(In reply to comment #14) the spm version on home/common is a mess, so I recommend not to look in those three versions. Better download the proper versions from the respective original places. Otherwise we will be wasting time on changing our code to accommodate the mess of home/common/spm. roboos@mentat001> diff /home/common/matlab/fieldtrip/data/test/bug2193/aal/ROI_MNI_V4.txt /home/common/matlab/fieldtrip/template/atlas/aal/ROI_MNI_V4.txt [shows no difference] I believe that the one in fieldtrip/template/atlas/aal was downloaded from the wfu site. Perhaps someone could check there?

Johanna - 2013-06-10 16:27:32 +0200

(In reply to comment #16) Sorry, that mess on spm was created by me and Marek. (bug 1783) In my opinion, the one that is just in /wfu_pickatlas/ (without _old or version number) is the most recent version (3.04). I hope that at least that one should work with current fieldtrip (but not necessarily the others, but I was just suggesting the others as a way to know why FT code may have existed differently in the past).

Jörn M. Horschig - 2013-06-10 16:49:00 +0200

(In reply to comment #17) my code change in r8179 was made to make the code compatible with that said version (spm8/toolboxes/wfu_pickatlas/) Johanna, does the FT atlas need to be updated then as well?

Johanna - 2013-06-10 16:54:14 +0200

(In reply to comment #18) The FT version is fine, w.r.t. the reason for bug 1783, namely an incorrect label name in the *.txt file. No need to change for that reason.

Jörn M. Horschig - 2013-06-10 17:17:29 +0200

sorry, I don't get that. The FT version on home/common/matlab/fieldtrip/template/atlas/aal is about 1.7MB, and the .txt is in format FAG Precentral_L 2001 FAD Precentral_R 2002 ... The SPM version in /home/common/matlab/spm8/toolboxes/wfu_pickatlas/MNI_atlas_templates/ is 881k, and the corresponding .txt file is in the format: 1 Precentral_L 2 Precentral_R ... So both versions are obviously different. I just downloaded the new version from, and the .nii file is 881k and the .txt format is the same as the SPM version. Hence, I would propose to replace the FT version with the new WFU pickatlas (or current SPM) version of the atlas. Any other atlases that might need an update?

Jörn M. Horschig - 2013-06-10 17:21:28 +0200

ah, now I get that the FT atlas is from here: which is indeed the same as the one on template/atlas/aal/ very confusing... so that one is *the* AAL atlas and the aal one of the WFU pickatlas is bullshit?

Robert Oostenveld - 2013-06-11 09:19:55 +0200

(In reply to comment #21) please mind your wording, the WFU folks are also just trying to do their best and share. So there is the original version of the AAL atlas, and the WFU version of the AAL atlas, and they differ in the text file. WFU copied the original version and modified the txt file to make it consistent with the other atlasses that are included in the WFU PickAtlas toolbox. The one we are sharing and that is documented is the one from the original authors, not the modified copy. I consider that we should be sharing and referring to the original one. See The two differ in the number of columns and in the absence of the header line in the WFU txt file. I suggest to check whether the first character of the file is a "[", and if so read it in the 2-column format, skipping the first line. Otherwise it reflects the original and it should read it in the 3-column format.

Jörn M. Horschig - 2013-06-11 09:26:27 +0200

okidoki, and sorry for the wording :) do you know why the size of the niftii files differs, are there substantial differences?

Robert Oostenveld - 2013-06-11 09:56:03 +0200

(In reply to comment #23) don't know. Try ft_read_mri and check the content.

Jörn M. Horschig - 2013-06-11 10:07:48 +0200

done and tested with test_bug2193 incl. the temporary spm part. Reading of the official aal atlas and the wfu adapted version are possible now (In reply to comment #24) I did, the only difference I can find is the labels are indexed differently (1:116 vs > 2000).

Jörn M. Horschig - 2013-06-11 10:11:15 +0200

and to make sure that this won't happen again, I added a test of the fieldtrip/template version: