[FieldTrip] convert .nii files to .mri files.

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Tue Jan 24 10:13:09 CET 2023


Hi Siamak,

As far as I can see, the page works with an anatomical file of a certain format, which happens to be *.mri. I don’t see why one would conclude that a file of another format needs to be converted into the *.mri format in order to be able to use the tutorial code for their own purpose.

Regarding the error you got: the lower level reading routine, based on the freesurfer toolbox, typically catches errors, and thus doesn’t lead to a hard crash if something goes wrong. These errors are indicated by the lines starting with ‘ERROR’ in your e-mail report. This suggests that something goes wrong with the low-level reading of the data. Perhaps the file is corrupt, or something else is wrong. Either way, this is out of fieldtrip hands.

The matlab error message you get, about the dot-indexing can subsequently be interpreted as follows: the tmp variable, which is accessed on said line 409 in ft_read_mri, in order to extract the field called vol, does not allow for dot indexing. Thinking a bit further this means that the tmp variable, which is assumed to be a struct (because structs are matlab variables that allow for dot-indexing in order to access the struct’s fields) apparently in your case is not a struct.

It is perhaps a bit suboptimal to get this particular error message, so we look forward to a pull request that suggests a more elegant error handling in this case.

Best wishes,
Jan-Mathijs


On 24 Jan 2023, at 09:21, Siamak Sorooshyari <siamak_sorooshyari at yahoo.com<mailto:siamak_sorooshyari at yahoo.com>> wrote:


Thanks so much for your response. To answer your question, this is the page that told me to do this:
https://urldefense.com/v3/__https://www.fieldtriptoolbox.org/tutorial/headmodel_meg/__;!!HJOPV4FYYWzcc1jazlU!4tWN2DzBdcrmQL8uy6zpUoPy_TjxQJ63OE7LS07eWO9qX1ARpWau2vklDPr6WOQgD1w74Qdv2I6JuUPTqxt16zLdv0oph4VEyenlgg$ <https://urldefense.com/v3/__https://www.fieldtriptoolbox.org/tutorial/headmodel_meg/__;!!HJOPV4FYYWzcc1jazlU!_YWDWs51vAwHGcxlNVFhN2v0kKGxiWDWciY9BuJs-UwCRap5VOu1gE3mvgbd4cUbTbS3EtWpuIfpjmVkTd3KLR9ElP3uS6tRCHXCNWNdKQ$>
Notice where they mention the following:

Then, you can read in the mri data.
mri = ft_read_mri('Subject01.mri');

When I give the above command with either .nii or .nii.gz I get an error:

ERROR: D:\MEG_OMEGA_data\controls\sub-0229_Siamak\ses-01\anat\sub-0229_ses-01_run-1_T1w.nii, read in 23592960 voxels, expected 11796480
ERROR: loading D:\MEG_OMEGA_data\controls\sub-0229_Siamak\ses-01\anat\sub-0229_ses-01_run-1_T1w.nii as analyze
Dot indexing is not supported for variables of this type.

Error in ft_read_mri (line 409)
    ndims = numel(size(tmp.vol));

Error in my_process_MEG_via_FT_1 (line 8)
mri = ft_read_mri('D:\MEG_OMEGA_data\controls\sub-0229_Siamak\ses-01\anat\sub-0229_ses-01_run-1_T1w.nii');

I am not clear at all what I'm doing wrong or what the best remedy would be?

Best,
Siamak


On Tuesday, January 24, 2023 at 12:11:47 AM PST, Schoffelen, J.M. (Jan Mathijs) via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:


Hi Siamak,

Why do you think that you need to convert anything? As far as I can tell, the help documentation of ft_read_mri (https://urldefense.com/v3/__https://github.com/fieldtrip/fieldtrip/blob/master/fileio/ft_read_mri.m__;!!HJOPV4FYYWzcc1jazlU!4tWN2DzBdcrmQL8uy6zpUoPy_TjxQJ63OE7LS07eWO9qX1ARpWau2vklDPr6WOQgD1w74Qdv2I6JuUPTqxt16zLdv0oph4WwsrtCIA$ <https://urldefense.com/v3/__https://github.com/fieldtrip/fieldtrip/blob/master/fileio/ft_read_mri.m__;!!HJOPV4FYYWzcc1jazlU!7npeRmvEN0Icn0O6P3WP_0hVkGO6DX5oScMzlLeYJvAl0qGUrBEuHvSoEXsHmolWWJ0n0DYUNJ5VRqw0nuH2zkpKMl-Eu_mEt_pQnw$>) clearly mentions that it directly supports *.nii and *.nii.gz files. If there’s some other documentation that you came across, which mentions otherwise, and this documentation is one of the subpages of fieldtriptoolbox.org<https://urldefense.com/v3/__http://fieldtriptoolbox.org__;!!HJOPV4FYYWzcc1jazlU!7npeRmvEN0Icn0O6P3WP_0hVkGO6DX5oScMzlLeYJvAl0qGUrBEuHvSoEXsHmolWWJ0n0DYUNJ5VRqw0nuH2zkpKMl-Eu_lNRaAPnw$>, please adjust the text accordingly in a pull request on github (https://urldefense.com/v3/__https://github.com/fieldtrip/website__;!!HJOPV4FYYWzcc1jazlU!4tWN2DzBdcrmQL8uy6zpUoPy_TjxQJ63OE7LS07eWO9qX1ARpWau2vklDPr6WOQgD1w74Qdv2I6JuUPTqxt16zLdv0oph4WyD6th-A$ <https://urldefense.com/v3/__https://github.com/fieldtrip/website__;!!HJOPV4FYYWzcc1jazlU!7npeRmvEN0Icn0O6P3WP_0hVkGO6DX5oScMzlLeYJvAl0qGUrBEuHvSoEXsHmolWWJ0n0DYUNJ5VRqw0nuH2zkpKMl-Eu_nX0tFnJA$>) or equivalently press the ‘edit page with github’ link on the relevant page.

Best wishes,
Jan-Mathijs


On 24 Jan 2023, at 08:14, Siamak Sorooshyari via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:


How do you convert .nii (or I guess .nii.gz) files to .mri files. This is because I've been given .nii.gz files by the OMEGA dataset and I want to feed them into FieldTrip via the FieldTrip ft_read_mri() function. I am trying to get anatomical information so I can feed that into the MEG source localization that I'm trying.

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!8Zu0-0EWmjs35RiZa4_KQLPCjFq1llUC0eWkKZg1QeNSUq4KR9vZoNlJGh6pjecl0GOWEICJXhM1b678lB9c4zlmK3mIMQpDBPLC9g$

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!4tWN2DzBdcrmQL8uy6zpUoPy_TjxQJ63OE7LS07eWO9qX1ARpWau2vklDPr6WOQgD1w74Qdv2I6JuUPTqxt16zLdv0oph4WhRwjHaA$ <https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!_YWDWs51vAwHGcxlNVFhN2v0kKGxiWDWciY9BuJs-UwCRap5VOu1gE3mvgbd4cUbTbS3EtWpuIfpjmVkTd3KLR9ElP3uS6tRCHVk34TVvw$>


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


More information about the fieldtrip mailing list