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

Siamak Sorooshyari siamak_sorooshyari at yahoo.com
Wed Jan 25 10:01:05 CET 2023


 
I am using Windows 10 OS, is that not an adequate system for this? 
It seems like the unziping the nii.gz files to .nii (I use 7Zip for this) would forgo the zcat step below. Is that what you mean? 
     On Wednesday, January 25, 2023, 12:32:29 AM PST, Schoffelen, J.M. (Jan Mathijs) <janmathijs.schoffelen at donders.ru.nl> wrote:  
 
 Hi Siamak,
Again: this appears not to be a FieldTrip problem. All code that is under fieldtrip/external is included in the toolbox to make life easier for the users, but it’s code from an external origin, and not maintained/written by the contributors to the FieldTrip project. In this case the code is from the freesurfer folks.
The problem you face, is that your windows machine does not seem to be able to deal with the ‘zcat’ command, which is used in order to unzip the zipped files. The best remedy is to get yourself a computer with a decent operating system (mac or linux) and do your analysis there. Alternatively, you may want to reach out to your PI, or the technical support staff at your institute to get help. Alternatively, you may try to unzip the nii.gz files to .nii using some other software tool and take it from there.
Best wishes,Jan-Mathijs


On 25 Jan 2023, at 05:13, Siamak Sorooshyari <siamak_sorooshyari at yahoo.com> wrote:
Hi, Thanks so much, the below info is very helpful. Indeed, I tried what I'm doing with several different files to see if the one I used was corrupt, but they all fail. It is not my own MEG data, it is from the OMEGA dataset which has been used by others. 
I believe I've traced the first "ERROR" that you mention to the following file:   C:\...\FieldTrip\fieldtrip-20210709\external\freesurfer\load_nifti.m  this is under FieldTrip, correct? 
In this load_nifti.m  file I put some print statements to show me what's going on. I see the following when I run: 
>> my_process_MEG_via_FT_1
WARNING: fsgettmppath: could not find a temporary folder, using current folder
new_niftifile =
    '.\tp26929383_9f52_4df6_8426_0e85742b2768.load_nifti.m.nii'
cmd =

    'zcat D:\MEG_OMEGA_data\controls\sub-0249\ses-01\anat\sub-0249_ses-01_run-1_T1w.nii.gz > .\tp26929383_9f52_4df6_8426_0e85742b2768.load_nifti.m.nii' status =
     1
result =
    ''zcat' is not recognized as an internal or external command,     operable program or batch file.     '
cd C:\...\FieldTrip\fieldtrip-20210709zcat D:\MEG_OMEGA_data\controls\sub-0249\ses-01\anat\sub-0249_ses-01_run-1_T1w.nii.gz > .\tp26929383_9f52_4df6_8426_0e85742b2768.load_nifti.m.niiERROR: 'zcat' is not recognized as an internal or external command,operable program or batch file.
I'm not clear what is going on with "zcat" above - I googled it and found a file for it here: https://urldefense.com/v3/__https://github.com/penghou620/matlab-toolbox/tree/master/spfirst__;!!HJOPV4FYYWzcc1jazlU!-7aCq4cocFZtTPn_CmfR9-PNAl2ARI-8ECtg99fa4Z6NSC6GJVPxk3eMql4qYTmAQigx_5bqgXDejWxfwvmcVFCZIHOEhT0$   
and included the file in running the above. I am not sure if this is the issue.  
I am definitely not clear how/why/where the assignment that I've mentioned above: 
new_niftifile =
    '.\tp26929383_9f52_4df6_8426_0e85742b2768.load_nifti.m.nii'
comes about. 
Please let me know what is wrong and how to remedy? 
Best,Siamak

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

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> 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!-7aCq4cocFZtTPn_CmfR9-PNAl2ARI-8ECtg99fa4Z6NSC6GJVPxk3eMql4qYTmAQigx_5bqgXDejWxfwvmcVFCZUG917t4$ 
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 11796480ERROR: loading D:\MEG_OMEGA_data\controls\sub-0229_Siamak\ses-01\anat\sub-0229_ses-01_run-1_T1w.nii as analyzeDot 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> 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!-7aCq4cocFZtTPn_CmfR9-PNAl2ARI-8ECtg99fa4Z6NSC6GJVPxk3eMql4qYTmAQigx_5bqgXDejWxfwvmcVFCZzUFSOdU$ ) 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 offieldtriptoolbox.org, please adjust the text accordingly in a pull request on github (https://urldefense.com/v3/__https://github.com/fieldtrip/website__;!!HJOPV4FYYWzcc1jazlU!-7aCq4cocFZtTPn_CmfR9-PNAl2ARI-8ECtg99fa4Z6NSC6GJVPxk3eMql4qYTmAQigx_5bqgXDejWxfwvmcVFCZymJt7BY$ ) 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> 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!-7aCq4cocFZtTPn_CmfR9-PNAl2ARI-8ECtg99fa4Z6NSC6GJVPxk3eMql4qYTmAQigx_5bqgXDejWxfwvmcVFCZ2lDbwz4$ 



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


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


More information about the fieldtrip mailing list